SlideShare une entreprise Scribd logo
1  sur  47
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 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