1 1
11
<Insert Picture Here>
Java EE 6, a Technical Overview
3
Java EE
• Scalable and maintainable enterprise apps• Container vs. Developer
– Life-cycle, resource injection, security, ...• Portable code
– Portable skills– Vendor independence
• Industry standard– large developer community,– books, training, best practices, consultants, ...
4
Java EE 6 Overview
• New features– Web Profile, REST, managed beans,
standard dependency injection, validation
• Enhanced APIs– EJB 3.1, JSF 2.0, JPA 2.0, Servlet 3.0
• More ease of use– Optional XML, simpler packaging, extensibility
• Usable “as is”– The end of the 100's MB .war
5
May 1998
Project JPE
Dec 199910 specs
J2EE 1.2
EnterpriseApplication
ServletJSPEJBJMSRMI/IIOP
Sept 200113 specs
J2EE 1.3
RobustScalable
CMPJCA
Nov 200320 specs
J2EE 1.4
Web Services
WSManagementDeployment
May 200623 specs
Java EE 5
Ease ofdevelopment
AnnotationsEJB 3JPA 1.0WS-*JSF
Q4 200928 specs
Java EE 6
Ease ofdevelopment
(web)
EJB 3.1JPA 2.0Servlet 3.0JSF 2.0JAX-RS 1.1CDI 1.0@InjectBean Validat°
Web Profile
ManagedBean
Java EE – a brief History
6
EJB 3.1 JPA 2.0 Servlet 3.0 JSF 2.0 JAX-RS 1.1 Connectors 1.6 Bean Validation 1.0
DI 1.0 CDI 1.0 Managed Beans 1.0 Interceptors 1.1 JAX-WS 2.2 JSR-109 1.3 JSP 2.2 / EL 2.2 JSR-250 1.1
New and improved specifications
7
This is no science fiction
Java EE 6 and GlassFish Server 3 shipped final releases on
December 10th 2009
8
JAX-RS
• RESTful web services API• Already widely adopted• Really a general, high-level HTTP API• Annotation-based programming model• Programmatic API when needed• JAX-RS 1.1 integration with EJBs
9
JAX-RS sample code
@Path("widgets/{id}")@Produces("application/widgets+xml")public class WidgetResource { public WidgetResource( @PathParam("id") String id) { ... }
@GET Widget getWidget() { ... }}
10
Bean Validation 1.0
public class Address { @NotNull @Size(max=30, message="longer than {max} characters") private String street1; ... @NotNull @Valid private Country country;}
public class Country { @NotNull @Size(max=20) private String name; ...}
request recursiveobject graphvalidation
11
Build your own!
@Size(min=5, max=5)@ConstraintValidator(ZipcodeValidator.class)@Documented@Target({ANNOTATION_TYPE, METHOD, FIELD})@Retention(RUNTIME)public @interface ZipCode { String message() default "Wrong zipcode"; String[] groups() default {};}
Integrated in JPA and JSF Bootstrap APIs
12
“Web” Profile
• First Java EE profile to be defined• A fully-functional, mid-size stack for modern web application development
• Complete, but not the kitchen sink
13
Java EE 6 Web Profile
Servlet 3.0 JSP 2.2 / EL 2.2 JSR-45 1.0 JSTL 1.2 JSF 2.0 Bean Validation 1.0 EJB 3.1 Lite
JPA 2.0 JTA 1.1 DI 1.0 CDI 1.0 Managed Beans 1.0 Interceptors 1.1 JSR-250 1.1
14
Extensible & Pluggable
• Focus on the web tier in this release• Create a level playing ground forthird-party libraries and frameworks
• Simplify packaging of web apps
15
Modular Web Applications
• Libraries can contain web-fragment.xml•web.xml is optional•@WebServlet, @WebFilter annotations•ServletContainerInitializer interface• Programmatic registration• Resource jars
16
JSF 2.0
• Optional faces-config.xml• Standardized facelets• Auto-discovery of component libraries• Composite components• Ajax support (with or without JavaScript)• Even a JavaScript API !
17
EJB 3.1
•@Singleton beans•@Startup beans•@Asynchronous invocations•@Schedule tasks•EJBContainer API works on Java SE• No-interface view (1 EJB = 1 class!)• Define EJBs directly inside a web app
18
Packaging in a war
foo.ear
com/acme/Foo.class
WEB-INF/web.xmlWEB-INF/classes com/acme/FooServlet.class
com/acme/FooEJB.classcom/acme/FooEJBLocal.class
lib/foo_common.jar
foo_web.war
foo_ejb.jar
foo.war
WEB-INF/classes com/acme/Foo.class com/acme/FooServlet.class com/acme/FooEJB.class
19
Dependency Injection
• Context & Dependency Injection (CDI)• JSR 299 with JSR-330 (@Inject)• Context management (conversation), events,
alternatives, stereotypes, decorators & more
• Beans discovered at startup• Injection metamodel (BeanManager API)•@Resource still around
20
Qualified injection
@Inject @Premium Customer cust;
qualifier (user-defined label)
i.e. « which one? »
typ
e
inje
ctio
n p
oin
t
21
Qualifier Annotation
@Target({TYPE,METHOD,PARAMETER,FIELD})@Retention(RUNTIME)@Documented@Qualifierpublic @interface Premium {…}
@Premium // my own qualifierpublic class SpecialCustomer implements Customer { public void buy() {…}}
22
Qualified injection
@Inject @Premium Customer cust;
qualifier (user-defined label)
i.e. « which one? »
typ
e
inje
ctio
n p
oin
t
23
Contexts (the 'C' in CDI)
• Built-in “Web” Scopes :– @RequestScoped, @SessionScoped, @ApplicationScoped
– @ConversationScoped
public class CheckoutHandler { @Inject CheckoutHandler(@LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) PaymentProcessor processor, @Default Cart cart) { ... }}
Client is not context-aware
24
A lot more to CDI
• Alternatives• Events• Stereotypes• Consumer/Producer• Decorator• Portable extensions• etc...
25
This is no science fiction
Java EE 6 and GlassFish Server 3 shipped final releases on
December 10th 2009
26
A word on GlassFish
• Production-Quality Open Source Server• Java EE 6 (full platform, web profile)• Modular (HK2, OSGi)• Developer-friendly (you judge!)
• GlassFish 3.1 now available!• Clustering, centralized admin• Load-balancing, HA• more...
• http://glassfish.org
GlassFish and WebLogic Together
WebLogic Server
Production Java Application Deployment
GlassFish Server
Production Java Application Deployment
• Best open source application server with support from Oracle
• Open source platform of choice for light- weight Web applications
• Focus on latest Java EE standards and community driven innovation
• Certified interoperability with Fusion Middleware
• Differentiated innovation, scout thread
• Best commercial application server for transactional Java EE applications
• Platform of choice for standardization
• Focus on lowest operational cost and mission critical applications
• integration with Oracle Database, Fusion Middleware & Fusion Applications
28
The following/preceding 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.
29
References
• glassfish.org• oracle.com/goto/glassfish• blogs.sun.com/theaquarium• glassfish.org/roadmap• youtube.com/user/GlassFishVideos• Follow @glassfish
<Insert Picture Here>
Java EE 6, a Technical Overview
http://oracle.com/javaeehttp://glassfish.org