SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Downloaden Sie, um offline zu lesen
1
<Insert Picture Here>




The Java EE 6 Programming Model Explained:
How to Write Better Applications
Jerome Dochez
GlassFish Architect
Oracle
The following is intended to outline our general
product direction. It is intended for information
purposes only, and may not be incorporated into any
contract. It is not a commitment to deliver any
material, code, or functionality, and should not be
relied upon in making purchasing decisions.
The development, release, and timing of any
features or functionality described for Oracle’s
products remains at the sole discretion of Oracle.




                                                      3
Contents


• What's new in Java EE 6?
• The core programming model explained
• Features you should know about




                                         4
What's New in Java EE 6




                          5
What's new in the Java EE 6 Platform
New and updated components


•   EJB 3.1 (+Lite)          •   Managed Beans 1.0
•   JPA 2.0                  •   Interceptors 1.1
•   Servlet 3.0              •   JSP 2.2
•   JSF 2.0                  •   EL 2.2
•   JAX-RS 1.1               •   JSR-250 1.1
•   Bean Validation 1.0      •   JASPIC 1.1
•   DI 1.0                   •   JACC 1.5
•   CDI 1.0                  •   JAX-WS 2.2
•   Connectors 1.6           •   JSR-109 1.3



                                                     6
Java EE 6 Web Profile
New, updated and unchanged components


•   EJB 3.1 Lite            •   Managed Beans 1.0
•   JPA 2.0                 •   Interceptors 1.1
•   Servlet 3.0             •   JSP 2.2
•   JSF 2.0                 •   EL 2.2
                            •   JSR-250 1.1
• Bean Validation 1.0
• DI 1.0                    • JSR-45 1.0
• CDI 1.0                   • JSTL 1.2
                            • JTA 1.1



                                                    7
What's New?


•   Several new APIs
•   Web Profile
•   Pluggability/extensibility
•   Dependency injection
•   Lots of improvements to existing APIs




                                            8
The Core Programming Model Explained




                                   9
Core of the Java EE 6 Programming Model

  JAX-RS 1.1         JSF 2.0             JSP 2.2    B
                                                    E
                                        JSTL 1.2    A
                                                    N
               SERVLET 3.0 · EL 2.2                 V
                                                    A
                                                    L
                                                    I
 DI 1.0 · CDI 1.0 · INTERCEPTORS 1.1· JSR-250 1.1   D
                                                    A
                                                    T
 MANAGED BEANS 1.0                   EJB 3.1        I
                                                    O
                                                    N
                 JPA 2.0 · JTA 1.1                  1.0




                                                          10
EJB 3.1 Lite


• Session bean programming model
  – Stateful, stateless, singleton beans
• Declarative security and transactions
• Annotation-based
• Descriptor OK but optional




                                           11
Managed Beans


•   Plain Java objects (POJOs)
•   Foundation for other component types
•   Fully support injection (@Resource, @Inject)
•   @PostConstruct, @PreDestroy callbacks
•   Optional name
•   Interceptors




                                                   12
Sample Managed Beans



@ManagedBean            @ManagedBean(“foo”)
public class A {        public class B {
    @Resource               @Resource A a;
    DataSource myDB;
                            @PostConstruct
    public doWork() {       init() { ... }
        // ...          }
    }
}




                                              13
EJB Components are Managed Beans Too!


• All managed beans core services available in EJBs
• EJB component model extends managed beans
• New capabilities engaged on demand via annotations
  –   @Statefull, @Stateless, @Singleton
  –   @TransactionAttribute
  –   @RolesAllowed, @DenyAll, @PermitAll
  –   @Remote
  –   @WebService




                                                       14
Incremental Programming Model


•   Start with POJOs (@ManagedBean)
•   Use all the basic services
•   Turn them into session beans as needed
•   Take advantage of new capabilities
•   No changes to (local) clients




                                             15
Incremental Programming Model


•   Start with POJOs (@ManagedBean)
•   Use all the basic services
•   Turn them into session beans as needed
•   Take advantage of new capabilities
•   No changes to (local) clients

@ManagedBean
public class A {
      @Resource DataSource myDB;
      // ...
}



                                             16
Incremental Programming Model


•   Start with POJOs (@ManagedBean)
•   Use all the basic services
•   Turn them into session beans as needed
•   Take advantage of new capabilities
•   No changes to (local) clients

@Stateful
public class A {
      @Resource DataSource myDB;
      // ...
}



                                             17
Contexts and Dependency Injection (CDI)


• Managed beans on steroids
• Opt-in technology on a per-module basis
  – META-INF/beans.xml
  – WEB-INF/beans.xml
• @Resource only for container-provided objects
• Use @Inject for application classes


@Inject @LoggedIn User user;




                                                  18
Contexts and Dependency Injection (CDI)


• Managed beans on steroids
• Opt-in technology on a per-module basis
  – META-INF/beans.xml
  – WEB-INF/beans.xml
• @Resource only for container-provided objects
• Use @Inject for application classes


@Inject @LoggedIn User user;


The type describes the capabilities (= methods)

                                                  19
Contexts and Dependency Injection (CDI)


• Managed beans on steroids
• Opt-in technology on a per-module basis
  – META-INF/beans.xml
  – WEB-INF/beans.xml
• @Resource only for container-provided objects
• Use @Inject for application classes


@Inject @LoggedIn User user;


Qualifiers describe qualities/characteristics/identity.

                                                          20
APIs That Work Better Together
Example: Bean Validation


• Bean Validation integrated in JSF, JPA
• All fields on a JSF page validated during the “process
  validations” stage
• JPA entities validated at certain lifecycle points (pre-
  persist, post-update, pre-remove)
• Low-level validation API supports equivalent
  integration with other frameworks/APIs




                                                             21
Uniformity
Combinations of annotations “just work”


• Example: JAX-RS resource classes are POJOs
• Use JAX-RS-specific injection capabilities
• But you can turn resource classes into managed
  beans or EJB components...
• ... and use all new services!




                                                   22
JAX-RS Sample
    Using JAX-RS injection annotations

@Path(“root”)
public class RootResource {
    @Context UriInfo ui;


    public RootResource() { ... }


    @Path(“{id}”)
    public SubResource find(@PathParam(“id”) String id) {
         return new SubResource(id);
    }
}




                                                            23
JAX-RS Sample
    As a managed bean, using @Resource

@Path(“root”)
@ManagedBean
public class RootResource {
    @Context UriInfo ui;
    @Resource DataSource myDB;


    public RootResource() { ... }


    @Path(“{id}”)
    public SubResource find(@PathParam(“id”) String id) {
        return new SubResource(id);
    }
}



                                                            24
JAX-RS Sample
    As an EJB, using @Resource and security annotations

@Path(“root”)
@Stateless
public class RootResource {
    @Context UriInfo ui;
    @Resource DataSource myDB;


    public RootResource() { ... }


    @Path(“{id}”)
    @RolesAllowed(“manager”)
    public SubResource find(@PathParam(“id”) String id) {
        return new SubResource(id);
    }
}

                                                            25
JAX-RS Sample
    As a CDI bean, using @Inject and scope annotations

@Path(“root”)
@ApplicationScoped
public class RootResource {
    @Context UriInfo ui;
    @Inject @CustomerDB DataSource myDB;
    @Inject @LoggedIn User user;


    public RootResource() { ... }


    @Path(“{id}”)
    public SubResource find(@PathParam(“id”) String id) {
         // ...
    }
}

                                                            26
How to Obtain Uniformity
Combinations of annotations “just work”


• Annotations are additive
• New behaviors refine pre-existing ones
• Strong guidance for new APIs



   ➱ Classes can evolve smoothly




                                           27
Extensibility


• Level playing field for third-party frameworks
• Pluggability contracts make extensions look like built-
  in technologies
• Two main sets of extension points:
  – Servlet 3.0 pluggability
  – CDI extensions




                                                            28
Servlet 3.0 Pluggability


• Drag-and-drop model
• Web frameworks as fully configured libraries
  – contain “fragments” of web.xml
  – META-INF/web-fragment.xml
• Extensions can register listeners, servlets, filters
  dynamically
• Extensions can discover and process annotated
  classes
@HandlesTypes(WebService.class)
public class MyWebServiceExtension
    implements ServletContanerInitializer { ... }


                                                         29
Extensibility in CDI


• Drag-and-drop model here too
• Bean archives can contain reusable sets of beans
• Extensions can process any annotated types and
  define beans on-the-fly
• Clients only need to use @Inject
  – No XYZFactoryManagerFactory horrors!



@Inject @Reliable PayBy(CREDIT_CARD) PaymentProcessor;




                                                         30
Using Extensibility


• Look for ready-to-use frameworks, extensions
• Refactor your libraries into reusable, autoconfigured
  frameworks
• Take advantage of resource jars
• Package reusable beans into libraries




                                                          31
Extensive Tooling from Schema to GUI
NetBeans 6.9


•   Database tables to entity classes
•   Entity classes to session beans
•   Entity classes to JAX-RS resources
•   Entity classes to JSF front-end
•   JAX-RS resources to JavaScript client




                                            32
Features You Should Know About




                                 33
Interceptors and Managed Beans


• Interceptors can be engaged directly
@Interceptors(Logger.class)
@ManagedBean
public class A { ... }


• This kind of strong coupling is a code smell




                                                 34
Interceptor Bindings

• With CDI, you can use interceptor bindings
  @Logged
  @ManagedBean
  public class A { ... }
where
  @InterceptorBinding
  public @interface Logged { ... }
and
  @Interceptor
  @Logged
  public class Logger {
      @AroundInvoke void do(InvocationContext c) { ... }
  }


                                                           35
Interceptors vs Decorators


• Decorators are type-safe
• Decorators are bound unobtrusively
   @Decorator
   class ActionLogger {


       @Inject @Delegate Action action;


       Result execute(Data someData) {
           // ...log the action here...
           return action.execute(someData);
       }
   }


                                              36
Two Ways to Connect Beans in CDI


• Dependencies (@Inject)
• Strongly coupled
• Clients hold references to beans
@Inject @Reliable OrderProcessor;




                                     37
Two Ways to Connect Beans in CDI


• Dependencies (@Inject)
• Strongly coupled
• Clients hold references to beans
@Inject @Reliable OrderProcessor;


• Events (@Observes)
• Loosely coupled
• Observers don't hold references to event sources
public void
onProcessed(@Observes OrderProcessedEvent e) { .. . }


                                                        38
Events are Transaction-Aware


• Events queued and delivered near at boundaries
• Specify a TransactionPhase
  –   BEFORE_COMPLETION
  –   IN_PROGRESS
  –   AFTER_COMPLETION
  –   AFTER_FAILURE, AFTER_SUCCESS
• Supersedes TransactionSynchronizationRegistry API
• Mix transactional and non-transactional observers
public void
onProcessed(@Observes(during=AFTER_SUCCESS)
              OrderProcessedEvent e) { .. . }


                                                      39
Global JNDI Names


• Standard names to refer to remote beans in other
  applications
• java:global/application/module/bean!interface
• Also used to lookup EJB components within the
  standalone container API (EJBContainer)




                                                     40
What is java:global?


• New JNDI namespaces to match the packaging hierarchy
   java:global
   java:app
   java:module
   java:comp   (legacy semantics)
• Share resources as widely as possible
   java:app/env/customerDB
• Refer to resources from any module in the application
   @Resource(lookup=”java:app/env/customerDB”)
   DataSource db;



                                                          41
DataSource Definitions


• New annotation @DataSourceDefinition
• Define a data source once for the entire app
  @DataSourceDefinition(
      name="java:app/env/customerDB",
      className="com.acme.ACMEDataSource",
      portNumber=666,
      serverName="acmeStore.corp”)
  @Singleton
  public class MyBean {}




                                                 42
Using Producer Fields for Resources
• Expose container resources via CDI
  public MyResources {
    @Produces
    @Resource(lookup=”java:app/env/customerDB”)
    @CustomerDB DataSource ds;


      @Produces
      @PersistenceContext(unitName=”payrollDB”)
      @Payroll EntityManager em;
  }




                                                  43
Using Producer Fields for Resources
• Expose container resources via CDI
  public MyResources {
    @Produces
    @Resource(lookup=”java:app/env/customerDB”)
    @CustomerDB DataSource ds;


      @Produces
      @PersistenceContext(unitName=”payrollDB”)
      @Payroll EntityManager em;
  }
• Clients use @Inject
@Inject @CustomerDB DataSource customers;
@Inject @Payroll EntityManager payroll;


                                                  44
The Verdict




              45
A Better Platform


•   Less boilerplate code than ever
•   Fewer packaging headaches
•   Uniform use of annotations
•   Sharing of resources to avoid duplication
•   Transaction-aware observer pattern for beans
•   Strongly-typed decorators
•   ... and more!


      http://www.oracle.com/javaee

                                                   46
We encourage you to use the newly minted corporate tagline
“Software. Hardware. Complete.” at the end of all your presentations.
This message should replace any reference to our previous corporate
tagline “Oracle Is the Information Company.”




                                                                        47

Weitere ähnliche Inhalte

Was ist angesagt?

What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6Gal Marder
 
Java EE 6 & GlassFish 3
Java EE 6 & GlassFish 3Java EE 6 & GlassFish 3
Java EE 6 & GlassFish 3Arun Gupta
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questionsArun Vasanth
 
Java Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCJava Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCIMC Institute
 
Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Ryan Cuprak
 
Java IO, Serialization
Java IO, Serialization Java IO, Serialization
Java IO, Serialization Hitesh-Java
 
AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7Kevin Sutter
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qconYiwei Ma
 
Java EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise SystemsJava EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise SystemsHirofumi Iwasaki
 
Spring dependency injection
Spring dependency injectionSpring dependency injection
Spring dependency injectionsrmelody
 
Dependency Injection in Spring in 10min
Dependency Injection in Spring in 10minDependency Injection in Spring in 10min
Dependency Injection in Spring in 10minCorneil du Plessis
 
04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment WorkshopChuong Nguyen
 
A first Draft to Java Configuration
A first Draft to Java ConfigurationA first Draft to Java Configuration
A first Draft to Java ConfigurationAnatole Tresch
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentationsourabh aggarwal
 

Was ist angesagt? (19)

What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
Java EE 6 & GlassFish 3
Java EE 6 & GlassFish 3Java EE 6 & GlassFish 3
Java EE 6 & GlassFish 3
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
 
Oracle History #5
Oracle History #5Oracle History #5
Oracle History #5
 
Java Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCJava Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVC
 
jsf2 Notes
jsf2 Notesjsf2 Notes
jsf2 Notes
 
Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)
 
Java IO, Serialization
Java IO, Serialization Java IO, Serialization
Java IO, Serialization
 
AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7
 
Java EE and Glassfish
Java EE and GlassfishJava EE and Glassfish
Java EE and Glassfish
 
Spring design-juergen-qcon
Spring design-juergen-qconSpring design-juergen-qcon
Spring design-juergen-qcon
 
Java EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise SystemsJava EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise Systems
 
Glass Fishv3 March2010
Glass Fishv3 March2010Glass Fishv3 March2010
Glass Fishv3 March2010
 
Spring dependency injection
Spring dependency injectionSpring dependency injection
Spring dependency injection
 
Dependency Injection in Spring in 10min
Dependency Injection in Spring in 10minDependency Injection in Spring in 10min
Dependency Injection in Spring in 10min
 
04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop
 
JBoss AS / EAP and Java EE6
JBoss AS / EAP and Java EE6JBoss AS / EAP and Java EE6
JBoss AS / EAP and Java EE6
 
A first Draft to Java Configuration
A first Draft to Java ConfigurationA first Draft to Java Configuration
A first Draft to Java Configuration
 
Spring 4 final xtr_presentation
Spring 4 final xtr_presentationSpring 4 final xtr_presentation
Spring 4 final xtr_presentation
 

Andere mochten auch

How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.Markus Eisele
 
Building an Effective Enterprise Architecture Capability Using TOGAF and the ...
Building an Effective Enterprise Architecture Capability Using TOGAF and the ...Building an Effective Enterprise Architecture Capability Using TOGAF and the ...
Building an Effective Enterprise Architecture Capability Using TOGAF and the ...Iver Band
 
Always-On Services for Consumer Web, Mobile and the Internet of Things
Always-On Services for Consumer Web, Mobile and the Internet of ThingsAlways-On Services for Consumer Web, Mobile and the Internet of Things
Always-On Services for Consumer Web, Mobile and the Internet of ThingsIver Band
 
Metodología para el Alineamiento de Procesos de Negocio y Sistemas de Informa...
Metodología para el Alineamiento de Procesos de Negocio y Sistemas de Informa...Metodología para el Alineamiento de Procesos de Negocio y Sistemas de Informa...
Metodología para el Alineamiento de Procesos de Negocio y Sistemas de Informa...Fernando Javier Aguirre Guzmán
 
Developing in the Cloud
Developing in the CloudDeveloping in the Cloud
Developing in the CloudRyan Cuprak
 
Ejemplo de Archimate. Depositario Central de Valores en México
Ejemplo de Archimate. Depositario Central de Valores en MéxicoEjemplo de Archimate. Depositario Central de Valores en México
Ejemplo de Archimate. Depositario Central de Valores en MéxicoDavid Solis
 
Designing JEE Application Structure
Designing JEE Application StructureDesigning JEE Application Structure
Designing JEE Application Structureodedns
 
EJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and StrategyEJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and StrategyDavid Delabassee
 
Gobierno de TI - COBIT 5 y TOGAF
Gobierno de TI - COBIT 5 y TOGAFGobierno de TI - COBIT 5 y TOGAF
Gobierno de TI - COBIT 5 y TOGAFCarlos Francavilla
 
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Ryan Cuprak
 
Java EE microservices architecture - evolving the monolith
Java EE microservices architecture - evolving the monolithJava EE microservices architecture - evolving the monolith
Java EE microservices architecture - evolving the monolithMarkus Eisele
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Ryan Cuprak
 
ArchiMate 3.0: A New Standard for Architecture
ArchiMate 3.0: A New Standard for ArchitectureArchiMate 3.0: A New Standard for Architecture
ArchiMate 3.0: A New Standard for ArchitectureIver Band
 
Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reza Rahman
 
Down-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEDown-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEReza Rahman
 
Modeling and Evolving a Web Portal with the TOGAF Framework and the ArchiMate...
Modeling and Evolving a Web Portal with the TOGAF Framework and the ArchiMate...Modeling and Evolving a Web Portal with the TOGAF Framework and the ArchiMate...
Modeling and Evolving a Web Portal with the TOGAF Framework and the ArchiMate...Iver Band
 
Pros and Cons of a MicroServices Architecture talk at AWS ReInvent
Pros and Cons of a MicroServices Architecture talk at AWS ReInventPros and Cons of a MicroServices Architecture talk at AWS ReInvent
Pros and Cons of a MicroServices Architecture talk at AWS ReInventSudhir Tonse
 

Andere mochten auch (18)

How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.How would ESBs look like, if they were done today.
How would ESBs look like, if they were done today.
 
Building an Effective Enterprise Architecture Capability Using TOGAF and the ...
Building an Effective Enterprise Architecture Capability Using TOGAF and the ...Building an Effective Enterprise Architecture Capability Using TOGAF and the ...
Building an Effective Enterprise Architecture Capability Using TOGAF and the ...
 
Always-On Services for Consumer Web, Mobile and the Internet of Things
Always-On Services for Consumer Web, Mobile and the Internet of ThingsAlways-On Services for Consumer Web, Mobile and the Internet of Things
Always-On Services for Consumer Web, Mobile and the Internet of Things
 
Metodología para el Alineamiento de Procesos de Negocio y Sistemas de Informa...
Metodología para el Alineamiento de Procesos de Negocio y Sistemas de Informa...Metodología para el Alineamiento de Procesos de Negocio y Sistemas de Informa...
Metodología para el Alineamiento de Procesos de Negocio y Sistemas de Informa...
 
Developing in the Cloud
Developing in the CloudDeveloping in the Cloud
Developing in the Cloud
 
Ejemplo de Archimate. Depositario Central de Valores en México
Ejemplo de Archimate. Depositario Central de Valores en MéxicoEjemplo de Archimate. Depositario Central de Valores en México
Ejemplo de Archimate. Depositario Central de Valores en México
 
Designing JEE Application Structure
Designing JEE Application StructureDesigning JEE Application Structure
Designing JEE Application Structure
 
EJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and StrategyEJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and Strategy
 
Gobierno de TI - COBIT 5 y TOGAF
Gobierno de TI - COBIT 5 y TOGAFGobierno de TI - COBIT 5 y TOGAF
Gobierno de TI - COBIT 5 y TOGAF
 
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
 
Presentacion: Usando Archimate
Presentacion: Usando ArchimatePresentacion: Usando Archimate
Presentacion: Usando Archimate
 
Java EE microservices architecture - evolving the monolith
Java EE microservices architecture - evolving the monolithJava EE microservices architecture - evolving the monolith
Java EE microservices architecture - evolving the monolith
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
 
ArchiMate 3.0: A New Standard for Architecture
ArchiMate 3.0: A New Standard for ArchitectureArchiMate 3.0: A New Standard for Architecture
ArchiMate 3.0: A New Standard for Architecture
 
Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!
 
Down-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EEDown-to-Earth Microservices with Java EE
Down-to-Earth Microservices with Java EE
 
Modeling and Evolving a Web Portal with the TOGAF Framework and the ArchiMate...
Modeling and Evolving a Web Portal with the TOGAF Framework and the ArchiMate...Modeling and Evolving a Web Portal with the TOGAF Framework and the ArchiMate...
Modeling and Evolving a Web Portal with the TOGAF Framework and the ArchiMate...
 
Pros and Cons of a MicroServices Architecture talk at AWS ReInvent
Pros and Cons of a MicroServices Architecture talk at AWS ReInventPros and Cons of a MicroServices Architecture talk at AWS ReInvent
Pros and Cons of a MicroServices Architecture talk at AWS ReInvent
 

Ähnlich wie S313557 java ee_programming_model_explained_dochez

Overview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGMarakana Inc.
 
Java EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConJava EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConLudovic Champenois
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Arun Gupta
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Arun Gupta
 
Java EE 8: On the Horizon
Java EE 8:  On the HorizonJava EE 8:  On the Horizon
Java EE 8: On the HorizonJosh Juneau
 
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010Arun Gupta
 
AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7WASdev Community
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Arun Gupta
 
WildFly AppServer - State of the Union
WildFly AppServer - State of the UnionWildFly AppServer - State of the Union
WildFly AppServer - State of the UnionDimitris Andreadis
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Kile Niklawski
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크Yoonki Chang
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Arun Gupta
 
Java EE 6, Eclipse, GlassFish @EclipseCon 2010
Java EE 6, Eclipse, GlassFish @EclipseCon 2010Java EE 6, Eclipse, GlassFish @EclipseCon 2010
Java EE 6, Eclipse, GlassFish @EclipseCon 2010Ludovic Champenois
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGArun Gupta
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionArun Gupta
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerArun Gupta
 
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJosh Juneau
 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopArun Gupta
 

Ähnlich wie S313557 java ee_programming_model_explained_dochez (20)

Overview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUG
 
Java EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConJava EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseCon
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010
 
Whats New In Java Ee 6
Whats New In Java Ee 6Whats New In Java Ee 6
Whats New In Java Ee 6
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ JAX London ...
 
Java EE 8: On the Horizon
Java EE 8:  On the HorizonJava EE 8:  On the Horizon
Java EE 8: On the Horizon
 
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
Tools Coverage for the Java EE Platform @ Silicon Valley Code Camp 2010
 
AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7AAI-1713 Introduction to Java EE 7
AAI-1713 Introduction to Java EE 7
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011
 
WildFly AppServer - State of the Union
WildFly AppServer - State of the UnionWildFly AppServer - State of the Union
WildFly AppServer - State of the Union
 
JavaEE 6 tools coverage
JavaEE 6 tools coverageJavaEE 6 tools coverage
JavaEE 6 tools coverage
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann
 
스프링 프레임워크
스프링 프레임워크스프링 프레임워크
스프링 프레임워크
 
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
Java EE 6 & GlassFish 3: Light-weight, Extensible, and Powerful @ Silicon Val...
 
Java EE 6, Eclipse, GlassFish @EclipseCon 2010
Java EE 6, Eclipse, GlassFish @EclipseCon 2010Java EE 6, Eclipse, GlassFish @EclipseCon 2010
Java EE 6, Eclipse, GlassFish @EclipseCon 2010
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
 
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnitionJava EE 6 & GlassFish = Less Code + More Power @ DevIgnition
Java EE 6 & GlassFish = Less Code + More Power @ DevIgnition
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
 
Java EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVCJava EE 8 Web Frameworks: A Look at JSF vs MVC
Java EE 8 Web Frameworks: A Look at JSF vs MVC
 
Spark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 WorkshopSpark IT 2011 - Java EE 6 Workshop
Spark IT 2011 - Java EE 6 Workshop
 

Kürzlich hochgeladen

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

S313557 java ee_programming_model_explained_dochez

  • 1. 1
  • 2. <Insert Picture Here> The Java EE 6 Programming Model Explained: How to Write Better Applications Jerome Dochez GlassFish Architect Oracle
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3
  • 4. Contents • What's new in Java EE 6? • The core programming model explained • Features you should know about 4
  • 5. What's New in Java EE 6 5
  • 6. What's new in the Java EE 6 Platform New and updated components • EJB 3.1 (+Lite) • Managed Beans 1.0 • JPA 2.0 • Interceptors 1.1 • Servlet 3.0 • JSP 2.2 • JSF 2.0 • EL 2.2 • JAX-RS 1.1 • JSR-250 1.1 • Bean Validation 1.0 • JASPIC 1.1 • DI 1.0 • JACC 1.5 • CDI 1.0 • JAX-WS 2.2 • Connectors 1.6 • JSR-109 1.3 6
  • 7. Java EE 6 Web Profile New, updated and unchanged components • EJB 3.1 Lite • Managed Beans 1.0 • JPA 2.0 • Interceptors 1.1 • Servlet 3.0 • JSP 2.2 • JSF 2.0 • EL 2.2 • JSR-250 1.1 • Bean Validation 1.0 • DI 1.0 • JSR-45 1.0 • CDI 1.0 • JSTL 1.2 • JTA 1.1 7
  • 8. What's New? • Several new APIs • Web Profile • Pluggability/extensibility • Dependency injection • Lots of improvements to existing APIs 8
  • 9. The Core Programming Model Explained 9
  • 10. Core of the Java EE 6 Programming Model JAX-RS 1.1 JSF 2.0 JSP 2.2 B E JSTL 1.2 A N SERVLET 3.0 · EL 2.2 V A L I DI 1.0 · CDI 1.0 · INTERCEPTORS 1.1· JSR-250 1.1 D A T MANAGED BEANS 1.0 EJB 3.1 I O N JPA 2.0 · JTA 1.1 1.0 10
  • 11. EJB 3.1 Lite • Session bean programming model – Stateful, stateless, singleton beans • Declarative security and transactions • Annotation-based • Descriptor OK but optional 11
  • 12. Managed Beans • Plain Java objects (POJOs) • Foundation for other component types • Fully support injection (@Resource, @Inject) • @PostConstruct, @PreDestroy callbacks • Optional name • Interceptors 12
  • 13. Sample Managed Beans @ManagedBean @ManagedBean(“foo”) public class A { public class B { @Resource @Resource A a; DataSource myDB; @PostConstruct public doWork() { init() { ... } // ... } } } 13
  • 14. EJB Components are Managed Beans Too! • All managed beans core services available in EJBs • EJB component model extends managed beans • New capabilities engaged on demand via annotations – @Statefull, @Stateless, @Singleton – @TransactionAttribute – @RolesAllowed, @DenyAll, @PermitAll – @Remote – @WebService 14
  • 15. Incremental Programming Model • Start with POJOs (@ManagedBean) • Use all the basic services • Turn them into session beans as needed • Take advantage of new capabilities • No changes to (local) clients 15
  • 16. Incremental Programming Model • Start with POJOs (@ManagedBean) • Use all the basic services • Turn them into session beans as needed • Take advantage of new capabilities • No changes to (local) clients @ManagedBean public class A { @Resource DataSource myDB; // ... } 16
  • 17. Incremental Programming Model • Start with POJOs (@ManagedBean) • Use all the basic services • Turn them into session beans as needed • Take advantage of new capabilities • No changes to (local) clients @Stateful public class A { @Resource DataSource myDB; // ... } 17
  • 18. Contexts and Dependency Injection (CDI) • Managed beans on steroids • Opt-in technology on a per-module basis – META-INF/beans.xml – WEB-INF/beans.xml • @Resource only for container-provided objects • Use @Inject for application classes @Inject @LoggedIn User user; 18
  • 19. Contexts and Dependency Injection (CDI) • Managed beans on steroids • Opt-in technology on a per-module basis – META-INF/beans.xml – WEB-INF/beans.xml • @Resource only for container-provided objects • Use @Inject for application classes @Inject @LoggedIn User user; The type describes the capabilities (= methods) 19
  • 20. Contexts and Dependency Injection (CDI) • Managed beans on steroids • Opt-in technology on a per-module basis – META-INF/beans.xml – WEB-INF/beans.xml • @Resource only for container-provided objects • Use @Inject for application classes @Inject @LoggedIn User user; Qualifiers describe qualities/characteristics/identity. 20
  • 21. APIs That Work Better Together Example: Bean Validation • Bean Validation integrated in JSF, JPA • All fields on a JSF page validated during the “process validations” stage • JPA entities validated at certain lifecycle points (pre- persist, post-update, pre-remove) • Low-level validation API supports equivalent integration with other frameworks/APIs 21
  • 22. Uniformity Combinations of annotations “just work” • Example: JAX-RS resource classes are POJOs • Use JAX-RS-specific injection capabilities • But you can turn resource classes into managed beans or EJB components... • ... and use all new services! 22
  • 23. JAX-RS Sample Using JAX-RS injection annotations @Path(“root”) public class RootResource { @Context UriInfo ui; public RootResource() { ... } @Path(“{id}”) public SubResource find(@PathParam(“id”) String id) { return new SubResource(id); } } 23
  • 24. JAX-RS Sample As a managed bean, using @Resource @Path(“root”) @ManagedBean public class RootResource { @Context UriInfo ui; @Resource DataSource myDB; public RootResource() { ... } @Path(“{id}”) public SubResource find(@PathParam(“id”) String id) { return new SubResource(id); } } 24
  • 25. JAX-RS Sample As an EJB, using @Resource and security annotations @Path(“root”) @Stateless public class RootResource { @Context UriInfo ui; @Resource DataSource myDB; public RootResource() { ... } @Path(“{id}”) @RolesAllowed(“manager”) public SubResource find(@PathParam(“id”) String id) { return new SubResource(id); } } 25
  • 26. JAX-RS Sample As a CDI bean, using @Inject and scope annotations @Path(“root”) @ApplicationScoped public class RootResource { @Context UriInfo ui; @Inject @CustomerDB DataSource myDB; @Inject @LoggedIn User user; public RootResource() { ... } @Path(“{id}”) public SubResource find(@PathParam(“id”) String id) { // ... } } 26
  • 27. How to Obtain Uniformity Combinations of annotations “just work” • Annotations are additive • New behaviors refine pre-existing ones • Strong guidance for new APIs ➱ Classes can evolve smoothly 27
  • 28. Extensibility • Level playing field for third-party frameworks • Pluggability contracts make extensions look like built- in technologies • Two main sets of extension points: – Servlet 3.0 pluggability – CDI extensions 28
  • 29. Servlet 3.0 Pluggability • Drag-and-drop model • Web frameworks as fully configured libraries – contain “fragments” of web.xml – META-INF/web-fragment.xml • Extensions can register listeners, servlets, filters dynamically • Extensions can discover and process annotated classes @HandlesTypes(WebService.class) public class MyWebServiceExtension implements ServletContanerInitializer { ... } 29
  • 30. Extensibility in CDI • Drag-and-drop model here too • Bean archives can contain reusable sets of beans • Extensions can process any annotated types and define beans on-the-fly • Clients only need to use @Inject – No XYZFactoryManagerFactory horrors! @Inject @Reliable PayBy(CREDIT_CARD) PaymentProcessor; 30
  • 31. Using Extensibility • Look for ready-to-use frameworks, extensions • Refactor your libraries into reusable, autoconfigured frameworks • Take advantage of resource jars • Package reusable beans into libraries 31
  • 32. Extensive Tooling from Schema to GUI NetBeans 6.9 • Database tables to entity classes • Entity classes to session beans • Entity classes to JAX-RS resources • Entity classes to JSF front-end • JAX-RS resources to JavaScript client 32
  • 33. Features You Should Know About 33
  • 34. Interceptors and Managed Beans • Interceptors can be engaged directly @Interceptors(Logger.class) @ManagedBean public class A { ... } • This kind of strong coupling is a code smell 34
  • 35. Interceptor Bindings • With CDI, you can use interceptor bindings @Logged @ManagedBean public class A { ... } where @InterceptorBinding public @interface Logged { ... } and @Interceptor @Logged public class Logger { @AroundInvoke void do(InvocationContext c) { ... } } 35
  • 36. Interceptors vs Decorators • Decorators are type-safe • Decorators are bound unobtrusively @Decorator class ActionLogger { @Inject @Delegate Action action; Result execute(Data someData) { // ...log the action here... return action.execute(someData); } } 36
  • 37. Two Ways to Connect Beans in CDI • Dependencies (@Inject) • Strongly coupled • Clients hold references to beans @Inject @Reliable OrderProcessor; 37
  • 38. Two Ways to Connect Beans in CDI • Dependencies (@Inject) • Strongly coupled • Clients hold references to beans @Inject @Reliable OrderProcessor; • Events (@Observes) • Loosely coupled • Observers don't hold references to event sources public void onProcessed(@Observes OrderProcessedEvent e) { .. . } 38
  • 39. Events are Transaction-Aware • Events queued and delivered near at boundaries • Specify a TransactionPhase – BEFORE_COMPLETION – IN_PROGRESS – AFTER_COMPLETION – AFTER_FAILURE, AFTER_SUCCESS • Supersedes TransactionSynchronizationRegistry API • Mix transactional and non-transactional observers public void onProcessed(@Observes(during=AFTER_SUCCESS) OrderProcessedEvent e) { .. . } 39
  • 40. Global JNDI Names • Standard names to refer to remote beans in other applications • java:global/application/module/bean!interface • Also used to lookup EJB components within the standalone container API (EJBContainer) 40
  • 41. What is java:global? • New JNDI namespaces to match the packaging hierarchy java:global java:app java:module java:comp (legacy semantics) • Share resources as widely as possible java:app/env/customerDB • Refer to resources from any module in the application @Resource(lookup=”java:app/env/customerDB”) DataSource db; 41
  • 42. DataSource Definitions • New annotation @DataSourceDefinition • Define a data source once for the entire app @DataSourceDefinition( name="java:app/env/customerDB", className="com.acme.ACMEDataSource", portNumber=666, serverName="acmeStore.corp”) @Singleton public class MyBean {} 42
  • 43. Using Producer Fields for Resources • Expose container resources via CDI public MyResources { @Produces @Resource(lookup=”java:app/env/customerDB”) @CustomerDB DataSource ds; @Produces @PersistenceContext(unitName=”payrollDB”) @Payroll EntityManager em; } 43
  • 44. Using Producer Fields for Resources • Expose container resources via CDI public MyResources { @Produces @Resource(lookup=”java:app/env/customerDB”) @CustomerDB DataSource ds; @Produces @PersistenceContext(unitName=”payrollDB”) @Payroll EntityManager em; } • Clients use @Inject @Inject @CustomerDB DataSource customers; @Inject @Payroll EntityManager payroll; 44
  • 46. A Better Platform • Less boilerplate code than ever • Fewer packaging headaches • Uniform use of annotations • Sharing of resources to avoid duplication • Transaction-aware observer pattern for beans • Strongly-typed decorators • ... and more! http://www.oracle.com/javaee 46
  • 47. We encourage you to use the newly minted corporate tagline “Software. Hardware. Complete.” at the end of all your presentations. This message should replace any reference to our previous corporate tagline “Oracle Is the Information Company.” 47