Goncalves | Beginning Java EE 6 with GlassFish 3 | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 536 Seiten

Goncalves Beginning Java EE 6 with GlassFish 3


2. ed
ISBN: 978-1-4302-2890-5
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

E-Book, Englisch, 536 Seiten

ISBN: 978-1-4302-2890-5
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



Java Enterprise Edition (Java EE) continues to be one of the leading Java technologies and platforms from Oracle (previously Sun). Beginning Java EE 6 Platform with GlassFish 3, Second Edition is this first tutorial book on the final version of the Java EE 6 Platform. Step by step and easy to follow, this book describes many of the Java EE 6 specifications and reference implementations, and shows them in action using practical examples. This book uses the new version of GlassFish 3 to deploy and administer the code examples. Written by an expert member of the Java EE 6 specification request and review board in the Java Community Process (JCP), this book contains the best information possible, from an expert's perspective on enterprise Java technologies.

Antonio Goncalves is a senior software architect specializing in Java/Java EE. As a former BEA Systems consultant, he has expertise in application servers (Weblogic, JBoss, and GlassFish). He is the author of a Java EE 5 book in France and is also an Expert Member on Java EE 6, EJB 3.1, and JPA 2.0. He is the cofounder of the Paris Java User Group. For more, visit http://www.antoniogoncalves.org.

Goncalves Beginning Java EE 6 with GlassFish 3 jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Title Page;1
2;Copyright Page;2
3;Contents at a Glance;4
4;Table of Contents;5
5;Foreword;17
6;About the Author;18
7;About the Technical Reviewer;19
8;Acknowledgments;20
9;Preface;21
9.1;How Is This Book Structured?;21
9.2;Downloading and Running the Code;22
9.3;Contacting the Author;23
10;CHAPTER 1 Java EE 6 at a Glance;24
10.1;Understanding Java EE;24
10.1.1;A Bit of History;25
10.1.2;Standards;27
10.1.3;Architecture;27
10.1.3.1;Components;28
10.1.3.2;Containers;29
10.1.3.3;Services;29
10.1.3.4;Network Protocols;31
10.1.3.5;Packaging;32
10.1.3.6;Java Standard Edition;33
10.1.4;Java EE 6 Specifications;33
10.2;What’s New in Java EE 6?;35
10.2.1;Lighter;36
10.2.1.1;Pruning;36
10.2.1.2;Profiles;37
10.2.2;Easier to Use;38
10.2.3;Richer;39
10.2.4;More Portable;41
10.3;The CD-BookStore Application;41
10.4;Setting Up Your Environment;43
10.4.1;JDK 1.6;43
10.4.2;Maven 2;44
10.4.2.1;A Bit of History;44
10.4.2.2;Project Descriptor;45
10.4.2.3;Managing Artifacts;46
10.4.2.4;Project Modularity;47
10.4.2.5;Plug-ins and Life Cycle;48
10.4.2.6;Installation;49
10.4.2.7;Usage;49
10.4.3;JUnit 4;50
10.4.3.1;A Bit of History;50
10.4.3.2;How Does It Work?;50
10.4.3.3;Test Methods;53
10.4.3.4;Assert Methods;53
10.4.3.5;Fixtures;53
10.4.3.6;Launching JUnit;54
10.4.3.7;JUnit Integration;54
10.4.4;Derby 10.6;54
10.4.4.1;Installation;55
10.4.4.2;Usage;55
10.4.5;GlassFish v3.0.1;57
10.4.5.1;A Bit of History;57
10.4.5.2;GlassFish v3 Architecture;57
10.4.5.3;Update Center;59
10.4.5.4;GlassFish Subprojects;59
10.4.5.5;Administration;60
10.4.5.5.1;Admin Console;60
10.4.5.5.2;The asadmin CLI;61
10.4.5.6;Installing GlassFish;62
10.5;Summary;64
11;CHAPTER 2 Java Persistence;65
11.1;JPA Specification Overview;66
11.1.1;A Brief History of the Specification;66
11.1.2;What’s New in JPA 2.0?;67
11.1.3;Reference Implementation;67
11.2;Understanding Entities;68
11.2.1;Object-Relational Mapping;68
11.2.2;Querying Entities;70
11.2.3;Callbacks and Listeners;71
11.3;Putting it all Together;72
11.3.1;Writing the Book Entity;73
11.3.2;Writing the Main Class;74
11.3.3;Persistence Unit for the Main Class;75
11.3.4;Compiling with Maven;76
11.3.5;Running the Main Class with Derby;78
11.3.6;Writing the BookTest Class;79
11.3.7;Persistence Unit for the BookTest Class;81
11.3.8;Running the BookTest Class with Embedded Derby;82
11.4;Summary;82
12;CHAPTER 3 Object-Relational Mapping;83
12.1;How to Map an Entity;83
12.1.1;Configuration by Exception;85
12.2;Elementary Mapping;86
12.2.1;Tables;87
12.2.1.1;@Table;87
12.2.1.2;@SecondaryTable;88
12.2.2;Primary Keys;90
12.2.2.1;@Id and @GeneratedValue;90
12.2.2.2;Composite Primary Keys;91
12.2.2.2.1;@EmbeddedId;91
12.2.2.2.2;@IdClass;92
12.2.3;Attributes;94
12.2.3.1;@Basic;94
12.2.3.2;@Column;95
12.2.3.3;@Temporal;97
12.2.3.4;@Transient;98
12.2.3.5;@Enumerated;99
12.2.4;Access Type;100
12.2.5;Collection of Basic Types;103
12.2.6;Map of Basic Types;105
12.3;Mapping with XML;106
12.4;Embeddables;109
12.4.1;Access Type of an Embeddable Class;111
12.5;Relationship Mapping;113
12.5.1;Relationships in Relational Databases;114
12.5.2;Entity Relationships;115
12.5.2.1;Unidirectional and Bidirectional;116
12.5.2.2;@OneToOne Unidirectional;119
12.5.2.3;@OneToMany Unidirectional;122
12.5.2.4;@ManyToMany Bidirectional;126
12.5.3;Fetching Relationships;127
12.5.4;Ordering Relationships;129
12.5.4.1;@OrderBy;129
12.5.4.2;@OrderColumn;130
12.6;Inheritance Mapping;132
12.6.1;Inheritance Strategies;132
12.6.1.1;Single-Table-per-Class Hierarchy Strategy;133
12.6.1.2;Joined-Subclass Strategy;137
12.6.1.3;Table-per-Concrete-Class Strategy;138
12.6.1.3.1;Overriding Attributes;139
12.6.2;Type of Classes in the Inheritance Hierarchy;140
12.6.2.1;Abstract Entity;140
12.6.2.2;Nonentity;141
12.6.2.3;Mapped Superclass;142
12.7;Summary;143
13;CHAPTER 4 Managing Persistent Objects;144
13.1;How to Query an Entity;144
13.2;Entity Manager;148
13.2.1;Obtaining an Entity Manager;149
13.2.2;Persistence Context;151
13.2.3;Manipulating Entities;153
13.2.3.1;Persisting an Entity;155
13.2.3.2;Finding by ID;156
13.2.3.3;Removing an Entity;156
13.2.3.4;Orphan Removal;157
13.2.3.5;Synchronizing with the Database;158
13.2.3.5.1;Flushing Data;158
13.2.3.5.2;Refreshing an Entity;158
13.2.3.6;Content of the Persistence Context;159
13.2.3.6.1;Contains;159
13.2.3.6.2;Clear and Detach;159
13.2.3.7;Merging an Entity;160
13.2.3.8;Updating an Entity;161
13.2.3.9;Cascading Events;161
13.2.4;Cache API;163
13.3;JPQL;166
13.3.1;Select;167
13.3.2;From;169
13.3.3;Where;169
13.3.3.1;Binding Parameters;170
13.3.3.2;Subqueries;170
13.3.4;Order By;171
13.3.5;Group By and Having;171
13.3.6;Bulk Delete;171
13.3.7;Bulk Update;172
13.4;Queries;172
13.4.1;Dynamic Queries;175
13.4.2;Named Queries;176
13.4.3;Native Queries;179
13.4.4;Criteria API (or Object-Oriented Queries);179
13.4.4.1;Type-Safe Criteria API;180
13.5;Concurrency;182
13.5.1;Versioning;184
13.5.2;Optimistic Locking;185
13.5.3;Pessimistic Locking;187
13.6;Summary;187
14;CHAPTER 5 Callbacks and Listeners;188
14.1;Entity Life Cycle;188
14.2;Callbacks;190
14.3;Listeners;193
14.4;Summary;198
15;CHAPTER 6 Enterprise Java Beans;199
15.1;Understanding EJBs;199
15.1.1;Types of EJBs;201
15.1.2;Anatomy of an EJB;201
15.1.3;EJB Container;203
15.1.4;Embedded Container;204
15.1.5;Dependency Injection and JNDI;205
15.1.6;Callback Methods and Interceptors;206
15.1.7;Packaging;206
15.2;EJB Specification Overview;207
15.2.1;History of the Specification;207
15.2.2;What’s New in EJB 3.1;208
15.2.3;EJB Lite;209
15.2.4;Reference Implementation;209
15.3;Putting It All Together;210
15.3.1;Writing the Book Entity;211
15.3.2;Writing the BookEJB Stateless Session Bean;211
15.3.3;Persistence Unit for the BookEJB;213
15.3.4;Writing the Main Class;214
15.3.5;Compiling and Packaging with Maven;214
15.3.6;Deploying on GlassFish;216
15.3.7;Running the Main Class with the Application Client Container;217
15.3.8;Writing the BookEJBTest Class;217
15.4;Summary;219
16;CHAPTER 7 Session Beans and the Timer Service ;220
16.1;Session Beans;220
16.1.1;Stateless Beans;221
16.1.2;Stateful Beans;224
16.1.3;Singletons;226
16.1.3.1;Initialization;228
16.1.3.2;Chaining Singletons;229
16.1.3.3;Concurrency;230
16.1.3.3.1;Container-Managed Concurrency;230
16.1.3.3.2;Bean-Managed Concurrency;232
16.1.3.3.3;Concurrent Access Timeouts and Not Allowing Concurrency;232
16.1.4;Session Bean Model;233
16.1.4.1;Interfaces and Bean Class;233
16.1.4.1.1;Remote, Local, and No-Interface Views;234
16.1.4.1.2;Web Services Interface;236
16.1.4.1.3;Bean Class;236
16.1.4.2;Client View;237
16.1.4.2.1;@EJB;237
16.1.4.3;Portable JNDI Name;238
16.1.4.4;Session Context;240
16.1.4.5;Deployment Descriptor;241
16.1.4.6;Dependency Injection;242
16.1.4.7;Environment Naming Context;243
16.1.5;Asynchronous Calls;245
16.1.6;Embeddable Usage;247
16.2;The Timer Service;249
16.2.1;Calendar-Based Expression;250
16.2.2;Automatic Timer Creation;252
16.2.3;Programmatic Timer Creation;253
16.3;Summary;254
17;CHAPTER 8 Callbacks and Interceptors;256
17.1;Session Beans Life Cycle;256
17.1.1;Stateless and Singleton;256
17.1.2;Stateful;258
17.1.3;Callbacks;259
17.2;Interceptors;262
17.2.1;Around-Invoke Interceptors;263
17.2.2;Method Interceptors;266
17.2.3;Life-Cycle Interceptor;268
17.2.4;Chaining and Excluding Interceptors;269
17.3;Summary;271
18;CHAPTER 9 Transactions and Security;272
18.1;Transactions;272
18.1.1;ACID;273
18.1.2;Local Transactions;273
18.1.3;Distributed Transactions and XA;275
18.2;Transaction Support in EJB;278
18.2.1;Container-Managed Transactions;278
18.2.1.1;Marking a CMT for Rollback;282
18.2.1.2;Exception Handling;283
18.2.2;Bean-Managed Transactions;285
18.3;Security;287
18.3.1;Principals and Roles;287
18.3.2;Authentication and Authorization;288
18.4;Security Support in EJB;288
18.4.1;Declarative Security;289
18.4.2;Programmatic Security;292
18.5;Summary;294
19;CHAPTER 10 JavaServer Faces;295
19.1;Understanding JSF;296
19.1.1;FacesServlet and faces-config.xml;297
19.1.2;Pages and Components;297
19.1.3;Renderer;298
19.1.4;Converters and Validators;299
19.1.5;Managed Beans and Navigation;299
19.1.6;Ajax Support;300
19.2;Web Interface Specifications Overview;300
19.2.1;A Brief History of Web Interfaces;301
19.2.2;JSP 2.2, EL 2.2, and JSTL 1.2;301
19.2.3;JSF 2.0;301
19.2.4;What’s New in JSF 2.0;302
19.2.5;Reference Implementation;302
19.3;Putting It All Together;302
19.3.1;Writing the Book Entity;304
19.3.2;Writing the BookEJB;304
19.3.3;Writing the BookController Managed Bean;305
19.3.4;Writing the newBook.xhtml Page;306
19.3.5;Writing the listBooks.xhtml Page;308
19.3.6;Configuration with web.xml;310
19.3.7;Compiling and Packaging with Maven;311
19.3.8;Deploying on GlassFish;312
19.3.9;Running the Example;312
19.4;Summary;313
20;CHAPTER 11 Pages and Components;314
20.1;Web Pages;314
20.1.1;HTML;314
20.1.2;XHTML;316
20.1.3;CSS;318
20.1.4;DOM;320
20.1.5;JavaScript;321
20.2;Java Server Pages;323
20.2.1;Directive Elements;324
20.2.2;Scripting Elements;325
20.2.3;Action Elements;326
20.2.4;Putting It All Together;327
20.3;Expression Language;329
20.4;JSP Standard Tag Library;331
20.4.1;Core Actions;331
20.4.2;Formatting Actions;333
20.4.3;SQL Actions;334
20.4.4;XML Actions;336
20.4.5;Functions;338
20.5;Facelets;339
20.6;JavaServer Faces;340
20.6.1;Life Cycle;341
20.6.2;Standard HTML Components;343
20.6.2.1;Commands;343
20.6.2.2;Inputs;344
20.6.2.3;Outputs;345
20.6.2.4;Selections;346
20.6.2.5;Graphics;347
20.6.2.6;Grid and Tables;347
20.6.2.7;Error Messages;349
20.6.2.8;Miscellaneous;350
20.6.2.9;Templating;350
20.6.3;Resource Management;353
20.6.4;Composite Components;354
20.6.5;Implicit Objects;359
20.7;Summary;360
21;CHAPTER 12 Processing and Navigation;361
21.1;The MVC Pattern;361
21.1.1;FacesServlet;362
21.1.2;FacesContext;365
21.1.3;Faces Config;366
21.2;Managed Beans;367
21.2.1;How to Write a Managed Bean;367
21.2.2;Managed Bean Model;368
21.2.2.1;@ManagedBean;368
21.2.2.2;Scopes;369
21.2.2.3;@ManagedProperty;371
21.2.2.4;Life Cycle and Callback Annotations;372
21.2.3;Navigation;372
21.2.4;Message Handling;377
21.3;Conversion and Validation;379
21.3.1;Converters;379
21.3.2;Custom Converters;381
21.3.3;Validators;382
21.3.4;Custom Validators;383
21.4;Ajax;384
21.4.1;General Concepts;384
21.4.2;Support in JSF;386
21.4.3;Putting It All Together;388
21.5;Summary;392
22;CHAPTER 13 Sending Messages;393
22.1;Understanding Messages;393
22.1.1;JMS;394
22.1.2;MDB;394
22.2;Messaging Specification Overview;395
22.2.1;A Brief History of Messaging;395
22.2.2;JMS 1.1;395
22.2.3;EJB 3.1;395
22.2.4;Reference Implementation;396
22.3;How to Send and Receive a Message;396
22.4;Java Messaging Service;398
22.4.1;Point-to-Point;399
22.4.2;Publish-Subscribe;400
22.4.3;JMS API;401
22.4.3.1;Administered Objects;402
22.4.3.1.1;ConnectionFactory;402
22.4.3.1.2;Destination;403
22.4.3.1.3;Injection;403
22.4.3.2;Connection;405
22.4.3.3;Session;405
22.4.3.4;Messages;406
22.4.3.4.1;Header;406
22.4.3.4.2;Properties;408
22.4.3.4.3;Body;408
22.4.3.5;MessageProducer;408
22.4.3.6;MessageConsumer;410
22.4.3.6.1;Synchronous Delivery;410
22.4.3.6.2;Asynchronous Delivery;411
22.4.4;Selectors;413
22.4.5;Reliability Mechanisms;413
22.4.5.1;Setting Message Time-to-Live;414
22.4.5.2;Specifying Message Persistence;414
22.4.5.3;Controlling Acknowledgment;414
22.4.5.4;Creating Durable Subscribers;415
22.4.5.5;Setting Priorities;416
22.5;Message-Driven Beans;416
22.5.1;How to Write an MDB;416
22.5.2;MDB Model;417
22.5.2.1;@MessageDriven;418
22.5.2.2;@ActivationConfigProperty;418
22.5.2.3;Dependencies Injection;420
22.5.2.4;MDB Context;420
22.5.2.5;Life Cycle and Callback Annotations;421
22.5.3;MDB as a Consumer;421
22.5.4;MDB as a Producer;422
22.5.5;Transaction;423
22.5.6;Handling Exceptions;424
22.6;Putting It All Together;425
22.6.1;Writing the OrderDTO;425
22.6.2;Writing the OrderSender;425
22.6.3;Writing the OrderMDB;426
22.6.4;Compiling and Packaging with Maven;427
22.6.5;Creating the Administered Objects;429
22.6.6;Deploying the MDB on GlassFish;429
22.6.7;Running the Example;430
22.7;Summary;430
23;CHAPTER 14 SOAP Web Services;431
23.1;Understanding SOAP Web Services;431
23.1.1;XML;432
23.1.2;WSDL;433
23.1.3;SOAP;433
23.1.4;UDDI;433
23.1.5;Transport Protocol;434
23.2;SOAP Web Services Specification Overview;434
23.2.1;A Brief History of SOAP Web Services;434
23.2.2;Java EE Specifications;434
23.2.2.1;JAX-WS 2.2;435
23.2.2.2;Web Services 1.2;435
23.2.2.3;JAXB 2.2;435
23.2.2.4;WS-Metadata 2.0;435
23.2.2.5;JAXR 1.0;435
23.2.3;Reference Implementation;436
23.3;How to Invoke a SOAP Web Service;436
23.4;Java Architecture for XML Binding;438
23.4.1;Binding;439
23.4.2;Annotations;441
23.5;The Invisible Part of the Iceberg;444
23.5.1;WSDL;444
23.5.2;SOAP;447
23.6;Java API for XML-Based Web Services;448
23.6.1;JAX-WS Model;448
23.6.1.1;Web Service Endpoints;449
23.6.1.2;Annotations;449
23.6.1.2.1;@WebService;450
23.6.1.2.2;@WebMethod;451
23.6.1.2.3;@WebResult;451
23.6.1.2.4;@WebParam;452
23.6.1.2.5;@OneWay;452
23.6.1.2.6;All Together;452
23.6.1.3;Life Cycle and Callback;455
23.6.1.4;Web Service Context;456
23.6.2;Invoking a SOAP Web Service;456
23.7;Putting It All Together;458
23.7.1;Writing the CreditCard Class;458
23.7.2;Writing the CardValidator SOAP Web Service;458
23.7.3;Compiling and Packaging with Maven;459
23.7.4;Deploying on GlassFish;460
23.7.5;Writing the Web Service Consumer;462
23.7.6;Generating Consumer’s Artifacts and Packaging with Maven;463
23.7.7;Running the Main Class;465
23.8;Summary;466
24;CHAPTER 15 RESTful Web Services;467
24.1;Understanding RESTful Web Services;467
24.1.1;Resources and URIs;467
24.1.2;Representations;468
24.1.3;WADL;469
24.1.4;HTTP;469
24.1.4.1;Request and Response;469
24.1.4.2;HTTP Methods;471
24.1.4.2.1;GET;471
24.1.4.2.2;POST;471
24.1.4.2.3;PUT;471
24.1.4.2.4;DELETE;471
24.1.4.2.5;Others;472
24.1.4.3;Content Negotiation;472
24.1.4.4;Content Types;472
24.1.4.5;Status Codes;473
24.1.4.6;Caching and Conditional Requests;474
24.2;RESTful Web Services Specification;474
24.2.1;A Brief History of REST;475
24.2.2;JAX-RS 1.1;475
24.2.3;What’s New in JAX-RS 1.1?;475
24.2.4;Reference Implementation;476
24.3;The REST Approach;476
24.3.1;From the Web to Web Services;476
24.3.2;A Web-Browsing Experience;476
24.3.3;Uniform Interface;477
24.3.4;Addressability;477
24.3.5;Connectedness;478
24.3.6;Statelessness;479
24.4;Java API for RESTful Web Services;479
24.4.1;The JAX-RS Model;480
24.4.2;How to Write a REST Service;480
24.4.3;URI Definition;481
24.4.4;Extracting Parameters;483
24.4.5;Consuming and Producing Content Types;484
24.4.6;Entity Provider;487
24.4.7;Methods or the Uniform Interface;489
24.4.8;Contextual Information;490
24.4.8.1;Headers;490
24.4.8.2;Building URIs;491
24.4.9;Exception Handling;491
24.4.10;Life Cycle;492
24.5;Putting It All Together;493
24.5.1;Writing the Book Entity;493
24.5.2;Writing the BookResource;494
24.5.2.1;Header;494
24.5.2.2;Creating a New Book;494
24.5.2.3;Getting a Book by ID;495
24.5.2.4;Deleting a Book;496
24.5.3;Configuring Jersey;497
24.5.4;Compiling and Packaging with Maven;497
24.5.5;Deploying on GlassFish;498
24.5.6;Running the Example;499
24.6;Summary;500
25;Index;501



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.