+ All Categories
Home > Technology > Java EE 6 workshop at Dallas Tech Fest 2011

Java EE 6 workshop at Dallas Tech Fest 2011

Date post: 27-May-2015
Category:
Upload: arun-gupta
View: 4,522 times
Download: 2 times
Share this document with a friend
Description:
Java EE 6 workshop at Dallas Tech Fest 2011
Popular Tags:
39
1 Java EE 6 = Less Code + More Power Arun Gupta, Java EE & GlassFish Guy blogs.oracle.com/arungupta, @arungupta
Transcript
Page 1: Java EE 6 workshop at Dallas Tech Fest 2011

1

Java EE 6 = Less Code + More Power

Arun Gupta, Java EE & GlassFish Guyblogs.oracle.com/arungupta, @arungupta

Page 2: Java EE 6 workshop at Dallas Tech Fest 2011

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.

Page 3: Java EE 6 workshop at Dallas Tech Fest 2011

The Java EE 6 Platform

Servlets 3.0

JSP 2.2

JSF 2.0

EJB 3.1 Lite

JTA 1.1 ManagedBeans 1.0

JPA 2.0

CDI 1.0

BeanValidation1.0

Interceptors1.1

JAX-WS

JAX-RS

JAXB

EJB 3.1

JASPIC

JDBC

JNDI

JMS

JAXP

JAX-RPC . . .

SAAJ

JACC

JavaMail

StAX

New Updated Contributed by RedHat Web Profile 1.0

Page 4: Java EE 6 workshop at Dallas Tech Fest 2011

● Java EE 6 Web Profile● Pruning

● Pruned today, means– Optional in the next release– Deleted in the subsequent releases

● Technologies marked in Javadocs– EJB 2.x Entity Beans, JAX-RPC, JAXR, JSR 88

Light-weight

Page 5: Java EE 6 workshop at Dallas Tech Fest 2011

● EJB-in-WAR● No-interface EJB● Optional

“web.xml”/”faces-config.xml”

● Annotation-driven● @Schedule● @Path● @Inject● . . .

Page 6: Java EE 6 workshop at Dallas Tech Fest 2011

<web-fragment> <filter> <filter-name>wicket.helloworld</filter-name> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class> <init-param> <param-name>applicationClassName</param-name> <param-value>...</param-value> </init-param> </filter>

<filter-mapping> <filter-name>wicket.helloworld</filter-name> <url-pattern>/*</url-pattern> </filter-mapping></web-fragment>

Page 7: Java EE 6 workshop at Dallas Tech Fest 2011
Page 8: Java EE 6 workshop at Dallas Tech Fest 2011

From the real users ...Developers can concentrateon business logic, Java EE 6 is providing a standard for the infrastructure.

Jigsaw puzzle, Modular, standard, less xml, easy, easy, have I said easy?

Higher integrated specs,simple and annotation driven,single-classloader WARs,next level of industry standard

Standards compliance, vendor independence, milliseconds and kilobyte deployment

http://blogs.oracle.com/arungupta/tags/community+feedback

Faster development, less frameworks, less complexity, more great code shipped

Not your fat grandfather's enterprise Java anymore, enterprise Java renaissance

Definite excuse to avoid Spring forever

Simplified Java Development, Focus on building great products

Page 9: Java EE 6 workshop at Dallas Tech Fest 2011

Compatible Java EE 6 Impls

Today:

Announced:

Web Profile Only

Page 10: Java EE 6 workshop at Dallas Tech Fest 2011

3.1 Overview

● Built on GlassFish 3● Modular and Extensible HK2 Kernel

● ~260+ modules● OSGi/Java EE Hybrid Apps

● Clustering and High Availability● HTTP, EJB, IIOP, SSO, Metro

● Containers start on demand● End-to-end extensibility

Page 11: Java EE 6 workshop at Dallas Tech Fest 2011

Sample App Overview

DatabaseEJB

CLI

Servlet

JSFJAX-RSCDI

JPA

Page 12: Java EE 6 workshop at Dallas Tech Fest 2011

What will we do ?

1. Generate JPA Entities from the database table

2. Refactor generated entities for a more intuitive O/R mapping

3. Create an EJB for querying the database

4. Create a Servlet for testing the EJB and displaying values from the database table

5. Enable CDI and make the EJB EL-injectable

6. Display the values in JSF2/Facelets-based view

7. Expose JPA entities as a RESTful resource by using JAX-RS

Page 13: Java EE 6 workshop at Dallas Tech Fest 2011

What will we use ?

Page 14: Java EE 6 workshop at Dallas Tech Fest 2011

Generate JPA EntitiesAnd customize them

DatabaseEJB

CLI

Servlet

JSFJAX-RSCDI

JPA

Page 15: Java EE 6 workshop at Dallas Tech Fest 2011

Java Persistence API 2● Improved O/R mapping● Type-safe Criteria API● Expanded and Richer JPQL● 2nd-level Cache● New locking modes

● PESSIMISTIC_READ – grab shared lock● PESSIMISTIC_WRITE – grab exclusive lock● PESSIMISTIC_FORCE_INCREMENT – update version

● Standard configuration options● javax.persistence.jdbc.[driver | url | user | password]

Page 16: Java EE 6 workshop at Dallas Tech Fest 2011

Create an EJBFor querying the database

DatabaseEJB

CLI

Servlet

JSFJAX-RSCDI

JPA

Page 17: Java EE 6 workshop at Dallas Tech Fest 2011

Create an EJB – Sample CodeFor querying the database

@PersistenceContextEntityManager em;

public List<Customer> getCustomers() {return (List<Customer>)em.createNamedQuery("Customer.findAll").getResultList();}

Page 18: Java EE 6 workshop at Dallas Tech Fest 2011

EJB 3.1● Simplified Packaging● No interface view – one source file per bean● Embeddable API● @Singleton

● Initialization in @PostContruct● Simplified Cron-like syntax for Timer● Asynchronous Session Bean● Portable Global JNDI Name

Page 19: Java EE 6 workshop at Dallas Tech Fest 2011

Create a ServletFor testing EJB and display values from the database

DatabaseEJB

CLI

Servlet

JSFJAX-RSCDI

JPA

Page 20: Java EE 6 workshop at Dallas Tech Fest 2011

Create a Servlet – Sample CodeFor testing EJB and display values from the database

@EJB CustomerSessionBean ejb;

out.println(ejb.getCustomers());

http://localhost:8080/JavaEE6SampleApp/TestServlet

Page 21: Java EE 6 workshop at Dallas Tech Fest 2011

Servlets 3.0● @WebServlet, @WebListener, @WebFilter, …● Asynchronous Servlets

● @WebServlet(asyncSupported=true)● Plugin libraries using web fragments● Dynamic registration of Servlets● WEB-INF/lib/[*.jar]/META-INF/resources

accessible in the root● Programmatic authentication login/logout● Default Error Page● . . .

Page 22: Java EE 6 workshop at Dallas Tech Fest 2011

Enable CDIMake the EJB EL-injectable

DatabaseEJB

CLI

Servlet

JSFJAX-RSCDI

JPA

Page 23: Java EE 6 workshop at Dallas Tech Fest 2011

Enable CDI – Sample CodeMake the EJB EL-injectable

@javax.inject.Named

Page 24: Java EE 6 workshop at Dallas Tech Fest 2011

Contexts & Dependency Injection

● Standards-based Dependency Injection● Type-safe – Buids on @Inject API● Context/Scope management● Strong Typing, Loose Coupling● Includes ELResolver

@Inject @LoggedIn User user

RequestInjection What ?

(Type)Which one ?

(Qualifier)

@Inject @LoggedIn User

Page 25: Java EE 6 workshop at Dallas Tech Fest 2011

CDI

● Qualifiers● Events● Stereotypes● Interceptors● Decorators● Alternatives● . . .

Page 26: Java EE 6 workshop at Dallas Tech Fest 2011

Display the valuesIn JSF2/Facelets-based view

DatabaseEJB

CLI

Servlet

JSFJAX-RSCDI

JPA

Page 27: Java EE 6 workshop at Dallas Tech Fest 2011

Display the values – Sample CodeIn JSF2/Facelets-based view

http://localhost:8080/JavaEE6SampleApp/faces/index.xhtml

<h1>Java EE 6 Sample App</h1>

<center>Powered by GlassFish!</center>

<h:dataTable value="#{customerSessionBean.customers}" var="c"><h:column>#{c.name}</h:column><h:column>#{c.customerId}</h:column></h:dataTable>

Page 28: Java EE 6 workshop at Dallas Tech Fest 2011

Java Server Faces 2.0

● Facelets as “templating language” for the page● Custom components much easier to develop

● Integrated Ajax● “faces-config.xml” optional in common cases● Default navigation rules● Much more …

● Runs on Servlet 2.5+● Bookmarkable URLs● Conditional navigation● ...

Page 29: Java EE 6 workshop at Dallas Tech Fest 2011

RESTful resourceUsing JAX-RS

DatabaseEJB

CLI

Servlet

JSFJAX-RSCDI

JPA

Page 30: Java EE 6 workshop at Dallas Tech Fest 2011

RESTful resource – Sample CodeUsing JAX-RS

@Path("/customers")

http://localhost:8080/JavaEE6SampleApp/resources/customers/customer/1

@Produces({"application/xml", "application/json"})

@GET@Path("/customer/{id}")@Produces("application/xml")public Customer getCustomer(@PathParam("id")Integer id) {return(Customer)em.createNamedQuery("Customer.findByCustomerId").setParameter("customerId", id).getSingleResult();}

Page 31: Java EE 6 workshop at Dallas Tech Fest 2011

JAX-RS 1.1

● Java API for building RESTful Web Services● POJO based● Annotation-driven● Server-side API● HTTP-centric

Page 32: Java EE 6 workshop at Dallas Tech Fest 2011

Sample App Review

DatabaseEJB

CLI

Servlet

JSFJAX-RSCDI

JPA

Page 33: Java EE 6 workshop at Dallas Tech Fest 2011

Java EE for the Cloud : JSR 342● More easily operate on private/public clouds

● Multi-tenancy● Elasticity● Service Provisioning

● Tighter requirements for resource/state management● Better isolation between applications● Potential standard APIs for NRDBMS, Caching, other● Common management and monitoring interfaces● Better packaging● Evolution, not revolution

Page 34: Java EE 6 workshop at Dallas Tech Fest 2011

Java EE 7 : Technology Refresh

● Ease-of-development: JMS 2.0● Latest web standards

● New JSRs: Web Sockets, Java JSON API● HTTP Client API (JAX-RS 2.0)

● Possible JSRs inclusion● Concurrency Utilities for Java EE (JSR 236)● JCache (JSR 107)

Page 35: Java EE 6 workshop at Dallas Tech Fest 2011

Java EE 7 – When ?

● Late 2012● Date-driven release

● Anything not ready will be deferred to Java EE 8● Participate

● Expert Groups forming● Public discussion lists● JCP membership free for individuals

Page 36: Java EE 6 workshop at Dallas Tech Fest 2011

Transparency Checklisthttp://jcp.org/en/resources/transparency

● EG members names● EG business reported on a publicly

readable alias● Schedule is public, current and updated

regularly● Public can read/write to a wiki● Discussion board on jcp.org● Public read-only issue tracker

NEW

Page 37: Java EE 6 workshop at Dallas Tech Fest 2011

● Find out what's new with Java technology● See new tools and techniques● Learn how to create solutions● Network with peers● Meet with experts● Influence the future of the Java platform● 400+ sessions/BoFs/HOLs● . . . oracle.com/javaone

Page 38: Java EE 6 workshop at Dallas Tech Fest 2011

References

● oracle.com/javaee● glassfish.org● oracle.com/goto/glassfish● blogs.oracle.com/theaquarium● youtube.com/GlassFishVideos● Follow @glassfish

Page 39: Java EE 6 workshop at Dallas Tech Fest 2011

39

Java EE 6 = Less Code + More Power

Arun Gupta, Java EE & GlassFish Guyblogs.oracle.com/arungupta, @arungupta


Recommended