SlideShare ist ein Scribd-Unternehmen logo
1 von 113
Downloaden Sie, um offline zu lesen
<Insert Picture Here>
Deep Dive Hands-on in Java EE 6
Arun Gupta, Java EE & GlassFish Guy
blogs.sun.com/arungupta, @arungupta
2
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.
3
#javaee6
#glassfish
#oredev
Are you tweeting ?
4
Compatible Java EE 5 Impl
http://java.sun.com/javaee/overview/compatibility-javaee5.jsp
5
Compatible Java EE 6 Impls
Today:
Announced:
6
Goals for the Java EE 6 Platform
• Flexible & Light-weight
• Web Profile 1.0
• Pruning: JAX-RPC, EJB 2.x Entity Beans, JAXR, JSR 88
• Extensible
• Embrace Open Source Frameworks
• Easier to use, develop on
• Continue on path set by Java EE 5
7
Java EE 6 Web Profile 1.0
• Fully functional mid-sized profile
• Actively discussed in the Java EE 6 Expert
Group and outside it
• Technologies
• Servlets 3.0, JSP 2.2, EL 2.2, Debugging Support for
Other Languages 1.0, JSTL 1.2, JSF 2.0, Common
Annotations 1.1, EJB 3.1 Lite, JTA 1.1, JPA 2.0, Bean
Validation 1.0, Managed Beans 1.0, Interceptors 1.1,
Context & Dependency Injection 1.0, Dependency
Injection for Java 1.0
8
Java EE 6 - Done
• Specifications approved by the JCP
• Reference Implementation is GlassFish v3
• TCK D
ec
2009
9
Java EE 6 Specifications
• The Platform
• Java EE 6 Web Profile 1.0
• Managed Beans 1.0
10
Java EE 6 Specifications
New
• Contexts and Dependency Injection for
Java EE (JSR 299)
• Bean Validation 1.0 (JSR 303)
• Java API for RESTful Web Services (JSR 311)
• Dependency Injection for Java (JSR 330)
11
Java EE 6 Specifications
Extreme Makeover
• Java Server Faces 2.0 (JSR 314)
• Java Servlets 3.0 (JSR 315)
• Java Persistence 2.0 (JSR 317)
• Enterprise Java Beans 3.1 & Interceptors 1.1
(JSR 318)
• Java EE Connector Architecture 1.6 (JSR 322)
12
Java EE 6 Specifications
Updates
• Java API for XML-based Web Services 2.2 (JSR 224)
• Java API for XML Binding 2.2 (JSR 222)
• Web Services Metadata MR3 (JSR 181)
• JSP 2.2/EL 2.2 (JSR 245)
• Web Services for Java EE 1.3 (JSR 109)
• Common Annotations 1.1 (JSR 250)
• Java Authorization Contract for Containers 1.3 (JSR 115)
• Java Authentication Service Provider Interface for
Containers 1.0 (JSR 196)
13
Java EE 6 Specifications
As is
• JDBC 4.0 API
• Java Naming and Directory Interface 1.2
• Java Message Service 1.1
• Java Transaction API 1.1
• Java Transaction Service 1.0
• JavaMail API Specification 1.4
• JavaBeans Activation Framework 1.1
• Java API for XML Processing 1.3
• Java API for XML-based RPC 1.1
• SOAP with Attachments API for Java 1.3
• Java API for XML Registries 1.0
• Java EE Management Specification 1.1 (JSR 77)
• Java EE Deployment Specification 1.2 (JSR 88)
• Java Management Extensions 1.2
• Java Authentication and Authorization Service 1.0
• Debugging Support for Other Languages (JSR 45)
• Standard Tag Library for JSP 1.2 (JSR 52)
• Streaming API for XML 1.0 (JSR 173)
14
Managed Beans 1.0
EJB CDI JPAJAX-WS JAX-RSJSF ...
@Stateful
@Stateless
@Singleton
@Named @Entity
@Web
Service
@Path
@Managed
Bean
...
EJB
@javax.annotation.ManagedBean
15
Managed Beans 1.0
• POJO as managed component for the Java
EE container
• JavaBeans component model for Java EE
• Simple and Universally useful
• Advanced concepts in companion specs
• Basic Services
• Resource Injection, Lifecycle Callbacks, Interceptors
• Available as
• @Resource / @Inject
• java:app/<module-name>/<bean-name>
• java:module/<bean-name>
16
Code is king!
17
public class MyManagedBean {
public void setupResources() {
// setup your resources
}
public void cleanupResources() {
// collect them back here
}
public String sayHello(String name) {
return "Hello " + name;
}
}
Managed Beans 1.0 - Sample
@Resource
MyManagedBean bean;
@javax.annotation.ManagedBean
@PostConstruct
@PreDestroy
@Inject
MyManagedBean bean;
http://blogs.sun.com/arungupta/entry/totd_129_managed_beans_1
18
Interceptors 1.1
• Interpose on invocations and lifecycle events
on a target class
• Defined
• Using annotations or DD
• Default Interceptors (only in DD)
• Class & Method Interceptors
• In the same transaction & security context
• Cross-cutting concerns: logging, auditing,
profiling
19
Code is king!
20
Interceptors 1.1 - Code
@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface MyInterceptorBinding {
}
@Interceptor
@MyInterceptorBinding
public class MyInterceptor {
@AroundInvoke
public Object intercept(InvocationContext context) {
System.out.println(context.getMethod.getName());
System.out.println(context.getParameters());
Object result = context.proceed();
return result;
}
. . .
}
21
Interceptors 1.1 – Sample Code
@Interceptors(MyInterceptor.class)
public class MyManagedBean {
. . .
}
http://blogs.sun.com/arungupta/entry/totd_134_interceptors_1_1
@Inject
MyManagedBean bean;
public class MyManagedBean {
@Interceptors(MyInterceptor.class)
public String sayHello(String name) {
. . .
}
}
Single instance of
Interceptor per
target class instance
22
Interceptors 1.1 – Sample Code
@Named
@Interceptors(MyInterceptor.class)
public class MyManagedBean {
. . .
@Interceptors(AnotherInterceptor.class)
@ExcludeDefaultInterceptors
@ExcludeClassInterceptors
public void someMethod() {
. . .
}
}
23
Servlets in Java EE 5
At least 2 files
<!--Deployment descriptor
web.xml -->
<web-app>
<servlet>
<servlet-name>MyServlet
</servlet-name>
<servlet-class>
com.sun.MyServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet
</servlet-name>
<url-pattern>/myApp/*
</url-pattern>
</servlet-mapping>
...
</web-app>
/* Code in Java Class */
package com.sun;
public class MyServlet extends
HttpServlet {
public void
doGet(HttpServletRequest
req,HttpServletResponse res)
{
...
}
...
}
24
Servlets 3.0 (JSR 315)
Annotations-based @WebServlet
http://blogs.sun.com/arungupta/entry/totd_81_getting_started_with
package com.sun;
@WebServlet(name=”MyServlet”, urlPatterns={”/myApp/*”})
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse res)
{
...
}
<!--Deployment descriptor web.xml -->
<web-app>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>
com.sun.MyServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/myApp/*</url-pattern>
</servlet-mapping>
...
</web-app>
25
Code is king!
26
Servlets 3.0
Annotations-based @WebServlet
@WebServlet(name="mytest",
urlPatterns={"/myurl"},
initParams={
@InitParam(name="n1", value="v1"),
@InitParam(name="n2", value="v2")
}
)
public class TestServlet extends
javax.servlet.http.HttpServlet {
....
}
27
Servlets 3.0
Annotations-based @WebListeners
<listener>
<listener-class>
server.LoginServletListener
</listener-class>
</listener>
package server;
. . .
@WebListener()
public class LoginServletListener implements
ServletContextListener {
28
Servlets 3.0
Annotations-based @WebFilter
<filter>
<filter-name>PaymentFilter</filter-name>
<filter-class>server.PaymentFilter</filter-class>
<init-param>
<param-name>param1</param-name>
<param-value>value1</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PaymentFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>PaymentFilter</filter-name>
<servlet-name>PaymentServlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
package server;
. . .
@WebFilter(
filterName="PaymentFilter",
InitParams={
@WebInitParam(
name="param1",
value="value1")
}
urlPatterns={"/*"},
servletNames={"PaymentServlet"},
dispatcherTypes={DispatcherType.REQUEST}
)
public class PaymentFilter implements Filter {
. . .
29
Servlets 3.0
Asynchronous Servlets
• Useful for Comet, long waits
• Must declare
@WebServlet(asyncSupported=true)
AsyncContext context = request.startAsync();
context.addListener(new AsyncListener() { … });
context.dispatch(“/request.jsp”);
//context.start(Runnable action);
. . .
context.complete();
http://blogs.sun.com/arungupta/entry/totd_139_asynchronous_request_processing
30
Servlets 3.0
Extensibility
• Plugin libraries using web fragments
• Modular web.xml
• Bundled in framework JAR file in META-INF
directory
• Zero-configuration, drag-and-drop for web
frameworks
• Servlets, servlet filters, context listeners for a framework
get discovered and registered by the container
• Only JAR files in WEB-INF/lib are used
31
<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>
http://blogs.sun.com/arungupta/entry/totd_91_applying_java_ee
Servlets 3.0
Extensibility
32
<web-fragment>
<filter>
<filter-name>LiftFilter</filter-name>
<display-name>Lift Filter</display-name>
<description>The Filter that intercepts lift calls</description>
<filter-class>net.liftweb.http.LiftFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LiftFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-fragment>
http://blogs.sun.com/arungupta/entry/totd_101_applying_servlet_3
Servlets 3.0
Extensibility
33
Servlets 3.0
Extensibility - ServletContainerInitializer
• Provided by the apps or container
• Discovered using the service provider API
• Expresses interest in classes via
@HandlesTypes
• Who uses it ?
• Mojarra (JSF2) is bootstrapped into GlassFish
• No “faces-config.xml” or “web.xml”
• Jersey (JAX-RS) registers root Application
• No (or portable) “web.xml”
34
Servlets 3.0
Dynamic Registration – Java Server Faces
@SuppressWarnings({"UnusedDeclaration"})
@HandlesTypes({
ManagedBean.class,
FacesComponent.class,
FacesValidator.class,
FacesConverter.class,
FacesBehaviorRenderer.class,
ResourceDependency.class,
ResourceDependencies.class,
ListenerFor.class,
ListenersFor.class,
UIComponent.class,
Validator.class,
Converter.class,
Renderer.class
})
public class FacesInitializer implements ServletContainerInitializer {
// NOTE: Loggins should not be used with this class.
private static final String FACES_SERVLET_CLASS =
FacesServlet.class.getName();
35
Servlets 3.0
Dynamic Registration – Java Server Faces
public void onStartup(Set<Class<?>> classes, ServletContext servletContext)
throws ServletException {
if (shouldCheckMappings(classes, servletContext)) {
Map<String,? extends ServletRegistration> existing =
servletContext.getServletRegistrations();
for (ServletRegistration registration : existing.values()) {
if (FACES_SERVLET_CLASS.equals(registration.getClassName())) {
// FacesServlet has already been defined, so we're
// not going to add additional mappings;
return;
}
}
ServletRegistration reg =
servletContext.addServlet("FacesServlet",
"javax.faces.webapp.FacesServlet");
reg.addMapping("/faces/*", "*.jsf", "*.faces");
servletContext.setAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED,
Boolean.TRUE);
36
Servlets 3.0
Resource Sharing
• Static and JSP no longer confined to
document root of the web application
• May be placed in WEB-INF/lib/
[*.jar]/META-INF/resources
• Resources in document root take
precedence over those in bundled JAR
myapp.war
WEB-INF/lib/catalog.jar
/META-INF/resources/catalog/books.html
http://localhost:8080/myapp/catalog/books.html
37
Servlets 3.0
Much more ...
• Programmatic authentication, login, logout
> HttpServletRequest.authenticate
> HttpServletRequest.login
> HttpServletRequest.logout
• File upload support
• Servlet Security
> @ServletSecurity
• Default Error Page
> Any HTTP status code
> http://blogs.sun.com/arungupta/entry/
totd_136_default_error_page
<error-page>
<error-code>...</error-code>
<exception-type>...</exception-type>
<location>/404.html</location>
</error-page>
38
EJB 3.1 (JSR 318)
Package & Deploy in a WAR
foo.ear
foo_web.war
WEB-INF/web.xml
WEB-INF/classes
com.sun.FooServlet
com.sun.TickTock
foo_ejb.jar
com.sun.FooBean
com.sun.FooHelper
foo.war
WEB-INF/classes
com.sun.FooServlet
com.sun.TickTock
com.sun.FooBean
com.sun.FooHelper
web.xml ?
Java EE 5 Java EE 6
http://blogs.sun.com/arungupta/entry/totd_95_ejb_3_1
39
Code is king!
40
EJB 3.1
@Stateless
public class App {
public String sayHello(String name) {
return "Hello " + name;
}
}
41
EJB 3.1
• No interface view – one source file per bean
• Only for Local and within WAR
• Required for Remote
• No location transparency
• Component initialization in @PostConstruct
• No assumptions on no-arg ctor
42
EJB 3.1
Portable Global JNDI Name Syntax
• Portable
• Global
• Application/Module-scoped
• Derived from metadata such as name,
component name etc.
43
EJB 3.1
Portable Global JNDI Name Syntax
java:global[/<app-name>]/<module-name>/<bean-name>
[!<fully-qualified-interface-name>]
Only within EAR
Base name of EAR
(or application.xml)
Base name of ejb-jar/WAR
(or ejb-jar.xml/web.xml)
Unqualified name of the bean class
Annotation/name attribute
Or ejb-jar.xml
• Until now, only java:comp
• Local & Remote business
• No-interface
• Also in java:app, java:module
44
public void testEJB() throws NamingException {
EJBContainer ejbC =
EJBContainer.createEJBContainer();
Context ctx = ejbC.getContext();
App app = (App)
ctx.lookup("java:global/classes/App");
assertNotNull(app);
String NAME = "Duke";
String greeting = app.sayHello(NAME);
assertNotNull(greeting);
assertTrue(greeting.equals("Hello " + NAME));
ejbC.close();
}
EJB 3.1
Embeddable API – Deploy the Bean
http://blogs.sun.com/arungupta/entry/totd_128_ejbcontainer_createejbcontainer_embedded
45
Code is king!
46
EJB 3.1
Singleton Beans
• One instance per app/VM, not pooled
• Useful for caching state
• CMT/BMT
• Access to container services for injection, resource
manager, timers, startup/shutdown callbacks, etc.
• Enable eager initialization using @Startup
• Always supports concurrent access
• Define initialization ordering using @Depends
@Singleton
public class MyEJB {
. . .
}
47
EJB 3.1
Asynchronous Session Beans
• Control returns to the client before the
container dispatches invocation to a bean
instance
• @Asynchronous – method or class
• Return type – void or Future<V>
• Transaction context does not propagate
• REQUIRED → REQUIRED_NEW
• Security principal propagates
48
EJB 3.1
Asynchronous Session Beans – Code Sample
@Stateless
@Asynchronous
public class SimpleAsyncEJB {
public Future<Integer> addNumbers(int n1, int n2) {
Integer result;
result = n1 + n2;
try {
// simulate JPA queries + reading file system
Thread.currentThread().sleep(2000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
return new AsyncResult(result);
}
}
http://blogs.sun.com/arungupta/entry/totd_137_asynchronous_ejb_a
49
EJB 3.1
Timers
• Automatically created EJB Timers
• Calendar-based Timers – cron like semantics
• Every 14th
minute within the hour, for the hours 1 and 2 am
(minute=”*/14”, hour=”1,2”)
• Every 10 seconds starting at 30
(second=”30/10”)
• Every 5 minutes of every hour
(minute=”*/5”, hour=”*”)
• 2pm on Last Thur of Nov of every year
(hour=”14”, dayOfMonth=”Last Thu”,
month=”Nov”)
• Every Mon & Wed midnight
@Schedule(dayOfWeek=”Mon,Wed”)
50
Code is king!
51
EJB 3.1
Timers
• Single persistent timer across JVMs
• Automatically created EJB Timers
• @Schedule(hour=”15”,dayOfWeek=”Fri”)
• Can be chained
• @Schedules({
@Schedule(hour=”6”,dayOfWeek=”Tue,Thu,Fri-Sun”),
@Schedule(hour=”12”,dayOfWeek=”Mon,Wed”)
})
• May be associated with a TimeZone
• Non-persistent timer, e.g. Cache
• @Schedule(..., persistent=false)
52
EJB 3.1
EJB 3.1 Lite
A proper subset of the full EJB 3.1 API that
includes a small, powerful selection of EJB
features suitable for writing portable
transactional business logic
. . .
suitable for inclusion in a wider range
of Java products, many of which have much
smaller installation and runtime footprints
than a typical full Java EE implementation
53
EJB 3.1
EJB 3.1 Lite – Feature Comparison
54
Contexts & Dependency Injection - CDI
(JSR 299)
• Type-safe Dependency Injection
• No String-based identifiers
• Selected at development/deployment time
• Strong typing, Loose coupling
• Context & Scope management - extensible
• Works with Java EE modular and
component architecture
• Integration with Unified Expression Language (UEL)
55
CDI
Injection Points
• Field, Method, Constructor
• 0 or more qualifiers
• Type
@Inject @LoggedIn User user
Request
Injection
What ?
(Type)
Which one ?
(Qualifier)
@Inject @LoggedIn User user
56
CDI – Sample Client Code
Field and Method Injection
public class CheckoutHandler {
@Inject @LoggedIn User user;
@Inject PaymentProcessor processor;
@Inject void setShoppingCart(@Default Cart cart) {
…
}
}
57
CDI – Sample Client Code
Constructor Injection
public class CheckoutHandler {
@Inject
CheckoutHandler(@LoggedIn User user,
PaymentProcessor processor,
@Default Cart cart) {
...
}
}
• Only one constructor can have @Inject
58
CDI - Sample Client Code
Multiple Qualifiers and Qualifiers with Arguments
public class CheckoutHandler {
@Inject
CheckoutHandler(@LoggedIn User user,
@Reliable
@PayBy(CREDIT_CARD)
PaymentProcessor processor,
@Default Cart cart) {
...
}
}
59
CDI - Scopes
• Beans can be declared in a scope
• Everywhere: @ApplicationScoped, @RequestScoped
• Web app: @SessionScoped
• JSF app: @ConversationScoped
• Transient and long-running
• Pseudo-scope (default): @Dependent
• Custom scopes via @Scope
• CDI runtime makes sure the right bean is
created at the right time
• Client do NOT have to be scope-aware
60
CDI - Named Beans
Built-in support for the Unified EL
• Beans give themselves a name with
@Named(“cart”)
• Then refer to it from a JSF or JSP page
using the EL:
<h:commandButton
value=”Checkout”
action=“#{cart.checkout}”/>
61
CDI - Events
Even more decoupling
• Annotation-based event model
• A bean observes an event
void onLogin(@Observes LoginEvent event){…}
• Another bean fires an event
@Inject @Any Event<PrintEvent> myEvent;
void doPrint() {
. . .
myEvent.fire(new PrintEvent());
}
• Events can have qualifiers too
62
CDI
Much more ...
• Producer methods and fields
• Bridging Java EE resources
• Alternatives
• Interceptors
• Decorators
• Stereotypes
• . . .
63
Java Server Faces 2.0 (JSR 314)
• Facelets as “templating language” for the page
• Custom components much easier to develop
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Enter Name &amp; Password</title>
</h:head>
<h:body>
<h1>Enter Name &amp; Password</h1>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Name:"/>
<h:inputText value="#{simplebean.name}" title="name"
id="name" required="true"/>
<h:outputText value="Password:"/>
<h:inputText value="#{simplebean.password}" title="password"
id="password" required="true"/>
</h:panelGrid>
<h:commandButton action="show" value="submit"/>
</h:form>
</h:body>
</html>
64
Code is king!
65
JSF 2 Composite Components
66
JSF 2 Composite Components
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ez="http://java.sun.com/jsf/composite/ezcomp">
<h:head>
<title>Enter Name &amp; Password</title>
</h:head>
<h:body>
<h1>Enter Name &amp; Password</h1>
<h:form>
<ez:username-password/>
<h:commandButton action="show" value="submit"/>
</h:form>
</h:body>
</html>
http://blogs.sun.com/arungupta/entry/totd_135_jsf2_custom_components
. . .
WEB-INF
index.xhtml
resources/
ezcomp/
username-password.xhtml
67
Java Server Faces 2.0
Integrated Ajax Support
• f:ajax
<h:commandButton
actionListener="#{sakilabean.findActors}"
value="submit">
<f:ajax execute="length"
render="actorTable totalActors"/>
</h:commandButton>
http://blogs.sun.com/arungupta/entry/totd_123_f_ajax_bean
68
Java Server Faces 2.0
• “faces-config.xml” optional in common cases
• <managed-bean> → @ManagedBean or @Named
• Validator, Renderer, Listener, ...
• Default navigation rules – match a view on the disk
@Named(“simplebean”)
public class SimpleBean {
. . .
}
<h:commandButton action="show" value="submit"/>
69
Java Server Faces 2.0
Much more ...
• Runs on Servlet 2.5+
• Conditional navigation
• Project Stages
• Development, UnitTest, SystemTest, Production
• Custom Scopes for Managed Beans
• Bookmarkable URLs
• h:link, h:button
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/page2.xhtml</to-view-id>
<!-- Only accept if the following condition
is true -->
<if>#{foo.someCondition}</if>
</navigation-case>
<h:link outcome="viewEntry" value="Link">
<f:param name="entry" value="#{aBean.entry}"/>
</h:link>
<a href="http://localhost:8080/myapp/viewEntry.xhtml?
entry=entry1">Link</a>
70
• Collection of basic types
@Entity
public class Person {
@Id protected String ssn;
protected String name;
protected Date birthDate;
. . .
@ElementCollection
@CollectionTable(name=”ALIAS”)
protected Set<String> nickNames;
}
Java Persistence API 2 (JSR 317)
Sophisticated mapping/modeling options
71
• Collection of embeddables
@Embeddable public class Address {
String street;
String city;
String state;
. . .
}
@Entity public class RichPerson extends Person {
. . .
@ElementCollection
protected Set<Address> vacationHomes;
. . .
}
Java Persistence API 2
Sophisticated mapping/modeling options
72
Java Persistence API 2
Sophisticated mapping/modeling options
• Multiple levels of embedding
@Embeddable public class ContactInfo {
@Embedded Address address;
. . .
}
@Entity public class Employee {
@Id int empId;
String name;
ContactInfo contactInfo;
. . .
}
73
Java Persistence API 2
Sophisticated mapping/modeling options
• Improved Map support
@Entity public class VideoStore {
@Id Integer storeId;
Address location;
. . .
@ElementCollection
Map<Movie, Integer> inventory;
}
@Entity public class Movie {
@Id String title;
@String director;
. . .
}
74
Java Persistence API 2
Metamodel
• Abstract “schema-level” model over managed
classes of a Persistence Context
• Entities, Mapped classes, Embeddables, ...
• Accessed dynamically
• EntityManager or EntityManagerFactory.getMetamodel()
• And/or statically materialized as metamodel
classes
• Use annotation processor with javac
75
import javax.persistence.metamodel.*;
@StaticMetamodel(Customer.class)
public class Customer_ {
public static SingularAttribute<Customer, Integer> custId;
public static SingularAttribute<Customer, String> name;
public static SingularAttribute<Customer, Address> address;
public static SingularAttribute<Customer, SalesRep> rep;
public static SetAttribute<Customer, Order> orders;
}
Java Persistence API 2
Metamodel Example
@Entity
public class Customer {
@Id Integer custId;
String name;
...
Address address;
@ManyToOne SalesRep rep;
@OneToMany Set<Order> orders;
}
76
Java Persistence API 2
Type-safe Criteria API
EntityManager em = emf.createEntityManager();
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery criteria = builder.createQuery(Manufacturer.class);
Root root = criteria.from(Manufacturer.class); // FROM clause
criteria.select(root); // SELECT clause
Predicate condition = builder.like(root.get(Manufacturer_.name),
"%" + name + "%");
criteria.where(condition); // WHERE clause
TypedQuery query = em.createQuery(criteria); // FIRE query
List manufacturers = query.getResultList();
77
Java Persistence API 2
Caching
• 1st-level Cache by PersistenceContext
• Only one object instance for any database row
• 2nd-level by “shared-cache-mode”
• ALL, NONE
• UNSPECIFIED – Provider specific defaults
• ENABE_SELECTIVE - Only entities with Cacheable(true)
• DISABLE_SELECTIVE - All but with Cacheable(false)
• Optional feature for PersistenceProvider
• Properties for find, refresh, setProperty
• CacheRetrieveMode – USE, BYPASS
78
Code is king!
79
Java Persistence API 2
Much more ...
• New locking modes
• PESSIMISTIC_READ – grab shared lock
• PESSIMISTIC_WRITE – grab exclusive lock
• PESSIMISTIC_FORCE_INCREMENT – update version
• em.find(<entity>.class, id,
LockModeType.XXX)
• em.lock(<entity>, LockModeType.XXX)
• Standard configuration options
• javax.persistence.jdbc.[driver | url | user | password]
80
Bean Validation (JSR 303)
• Tier-independent mechanism to define
constraints for data validation
• Represented by annotations
• javax.validation.* package
• Integrated with JSF and JPA
• JSF: f:validateRequired, f:validateRegexp
• JPA: pre-persist, pre-update, and pre-remove
• @NotNull(message=”...”), @Max, @Min,
@Size
• Fully Extensible
• @Email String recipient;
81
Bean Validation
Integration with JPA
• Managed classes may be configured
• Entities, Mapped superclasses, Embeddable classes
• Applied during pre-persist, pre-update, pre-
remove lifecycle events
• How to enable ?
• “validation-mode” in persistence.xml
• “javax.persistence.validation.mode” key in
Persistence.createEntityManagerFactory
• Specific set of classes can be targeted
• javax.persistence.validation.group.pre-[persist|update|
remove]
82
Bean Validation
Integration with JSF
• Individual validators not required
• Integration with EL
• f:validateBean, f:validateRequired
<h:form>
<f:validateBean>
<h:inputText value=”#{model.property}” />
<h:selectOneRadio value=”#{model.radioProperty}” > …
</h:selectOneRadio>
<!-- other input components here -->
</f:validateBean>
</h:form>
83
Bean Validation
Programmatic Validation
@Named(value=”shopping”)
public class ShoppingService {
@CreditCard
String card;
. . .
}
<h:inputText value="#{shopping.card}"/>
84
JAX-RS 1.1
• Java API for building RESTful Web Services
• POJO based
• Annotation-driven
• Server-side API
• HTTP-centric
85
JAX-RS 1.1
Code Sample - Simple
public class HelloWorldResource {
public String sayHello() {
return "Hello World";
}
public String morning() {
return “Good Morning!”;
}
}
@Path("helloworld")
@Context UriInfo ui;
@GET
@Produces("text/plain")
@GET
@Path("morning")
86
Code is king!
87
JAX-RS 1.1
Code Sample – Specifying Output MIME type
@Path("/helloworld")
@Produces("text/plain")
public class HelloWorldResource {
@GET
public String doGetAsPlainText() {
. . .
}
@GET
@Produces("text/html")
public String doGetAsHtml() {
. . .
}
}
@GET
@Produces({
"application/xml",
"application/json"})
public String doGetAsXmlOrJson() {
. . .
}
88
JAX-RS 1.1
Code Sample – Specifying Input MIME type
@POST
@Consumes("text/plain")
public String saveMessage() {
. . .
}
89
JAX-RS 1.1
Code Sample
import javax.inject.Inject;
import javax.enterprise.context.RequestScoped;
@RequestScoped
public class ActorResource {
@Inject DatbaseBean db;
public Actor getActor(int id) {
return db.findActorById(id);
}
}
90
JAX-RS 1.1
Code Sample
import javax.inject.Inject;
import javax.enterprise.context.RequestScoped;
@RequestScoped
public class ActorResource {
@Inject DatbaseBean db;
public Actor getActor( int id) {
return db.findActorById(id);
}
}
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.PathParam;
@Path("/actor/{id}")
@GET
@Produces("application/json")
@PathParam("id")
http://blogs.sun.com/arungupta/entry/totd_124_using_cdi_jpa
91
JAX-RS 1.1
More Code Samples
• Processing POSTed HTML Form
@POST
@Consumes("application/x-www-form-urlencoded")
public void post(@FormParam("name") String name) {
// Store the message
}
• Sub-Resources
@Singleton
@Path("/printers")
public class PrintersResource {
@GET @Path("/list")
@Produces({"application/json", "application/xml"})
public WebResourceList getListOfPrinters() { ... }
@GET @Path("/ids/{printerid}")
@Produces({"application/json", "application/xml"})
public Printer getPrinter(@PathParam("printerid") String printerId) { ... }
92
JAX-RS 1.1
Integration with Java EE 6 – Servlets 3.0
• No or Portable “web.xml”
<web-app>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.foo.MyApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
</web-app>
public class MyApplication
extends
javax.ws.rs.core.Application {
}
@ApplicationPath(“resources”)
93
JAX-RS 1.1
Jersey Client-side API
• Consume HTTP-based RESTful Services
• Easy-to-use
• Better than HttpURLConnection!
• Reuses JAX-RS API
• Resources and URI are first-class citizens
• Not part of JAX-RS yet
• com.sun.jersey.api.client
94
JAX-RS 1.1
Jersey Client API – Code Sample
Client client = Client.create();
WebResource resource = client.resource(“...”);
//curl http://example.com/base
String s = resource.get(String.class);
//curl -HAccept:text/plain http://example.com/base
String s = resource.
accept(“text/plain”).
get(String.class);
http://blogs.sun.com/enterprisetechtips/entry/consuming_restful_web_services_with
95
JAX-RS 1.1
Jersey Client API – NetBeans Code Generation
96
Code is king!
97
JAX-RS 1.1
WADL Representation of Resources
• Machine processable description of
HTTP-based Applications
• Generated OOTB for the application
<application xmlns="http://research.sun.com/wadl/2006/10">
<doc xmlns:jersey="http://jersey.dev.java.net/"
jersey:generatedBy="Jersey: 1.1.4.1 11/24/2009 01:37 AM"/>
<resources base="http://localhost:8080/HelloWADL/resources/">
<resource path="generic">
<method id="getText" name="GET">
<response>
<representation mediaType="text/plain"/>
</response>
</method>
<method id="putText" name="PUT">
<request>
<representation mediaType="text/plain"/>
</request>
</method>
</resource>
</resources>
</application>
98
JAX-RS 1.1
Much more ...
• Jersey is the Reference Implementation,
included in GlassFish
• RESTEasy, Restlet, CXF, Wink
• Hypermedia support (only in Jersey)
• Integration with Spring, Guice, Atom, …
• WADL representation
• Complete, Per resource
• Jersey 1.2 modules are OSGi compliant
99
IDE Support for Java EE 6
100
Books on Java EE
101
What is GlassFish ?
• A community
• Users, Partners, Testers, Developers, ...
• Started in 2005 on java.net
• Application Server
• Open Source (CDDL & GPL v2)
• Java EE Reference Implementation
GlassFish Distributions
Distribution License Features
GlassFish Open Source
Edition 3.0.1
CDDL &
GPLv2
• Java EE 6 Compatibility
• No Clustering
• Clustering planned in 3.1
• mod_jk for load balancing
GlassFish Open Source
Edition 2.1.1
CDDL &
GPLv2
• Java EE 5 Compatibility
• In memory replication
• mod_loadbalancer
Oracle GlassFish Server
3.0.1
Commercial • GlassFish Open Source Edition 3.0.1
• Oracle GlassFish Server Control
• Clustering planned in 3.1
Oracle GlassFish Server
2.1.1
Commercial • GlassFish Open Source Edition 2.1.1
• Enterprise Manager
• HADB
Clustering
Coming
Soon!
103
GlassFish 3
• Modular
• Maven 2 – Build & Module description
• Felix – OSGi runtime (216 bundles)
• Allow any type of Container to be plugged
• Start Container and Services on demand
• Embeddable: runs in-VM
• Extensible
• Rails, Grails, Django, ...
• Administration, Monitoring, Logging, Deployment, ...
104
GlassFish 3 & OSGi
• No OSGi APIs are used in GlassFish
• HK2 provides abstraction layer
• All GlassFish modules are OSGi bundles
• Felix is default, also runs on Knopflerfish & Equinox
• Can run in an existing shell
• 200+ modules in v3
http://blogs.sun.com/arungupta/entry/totd_103_glassfish_v3_with
105
106
Light Weight & On-demand Monitoring
• Event-driven light-weight and non-intrusive
monitoring
• Modules provide domain specific probes
(monitoring events)
• EJB, Web, Connector, JPA, Jersey, Orb, Ruby
• End-to-end monitoring on Solaris using
DTrace
• 3rd
party scripting clients
• JavaScript to begin with
107
REST Interface
• REST interface to management and
monitoring data
• Configuration data, commands invocation,
(start/stop instance, deploy, undeploy, ...), CRUD
resources (JMS, JDBC, ...)
•localhost:4848/management/domain
•localhost:4848/monitoring/domain
• GET, POST, DELETE methods
• XML, JSON, HTML reps
108
Boost your productivity
Retain session across deployment
asadmin redeploy –properties keepSessions=true helloworld.war
109
Boost your productivity
Deploy-on-Save
110
GlassFish Roadmap Detail
©2010 Oracle Corporation
111
GlassFish 3.1 = 3.0 + 2.1.1
• Main Features
• Clustering and Centralized Administration
• High Availability
• Other ...
• Application Versioning
• Application-scoped Resources
• SSH-based remote management and monitoring
• Embedded (extensive)
• Admin Console based on RESTful API
http://wikis.sun.com/display/glassfish/GlassFishv3.1
112
References
• glassfish.org
• blogs.sun.com/theaquarium
• oracle.com/goto/glassfish
• glassfish.org/roadmap
• youtube.com/user/GlassFishVideos
• Follow @glassfish
<Insert Picture Here>
Deep Dive Hands-on in Java EE 6
Arun Gupta, Java EE & GlassFish Guy
blogs.sun.com/arungupta, @arungupta

Weitere ähnliche Inhalte

Was ist angesagt?

Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Arun Gupta
 
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 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureJava EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureArun Gupta
 
OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6glassfish
 
GIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationGIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationArun Gupta
 
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...IndicThreads
 
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010Jagadish Prasath
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Arun Gupta
 
Java EE 6 & GlassFish 3
Java EE 6 & GlassFish 3Java EE 6 & GlassFish 3
Java EE 6 & GlassFish 3Arun Gupta
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0Arun Gupta
 
Java EE 6 Component Model Explained
Java EE 6 Component Model Explained Java EE 6 Component Model Explained
Java EE 6 Component Model Explained Shreedhar Ganapathy
 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudArun Gupta
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Arun Gupta
 
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
 
GlassFish & Java EE Business Update @ CEJUG
GlassFish & Java EE Business Update @ CEJUGGlassFish & Java EE Business Update @ CEJUG
GlassFish & Java EE Business Update @ CEJUGArun Gupta
 
Sun Java EE 6 Overview
Sun Java EE 6 OverviewSun Java EE 6 Overview
Sun Java EE 6 Overviewsbobde
 
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
 
The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011Arun Gupta
 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Arun Gupta
 

Was ist angesagt? (20)

Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
 
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 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureJava EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for future
 
OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6OTN Developer Days - Java EE 6
OTN Developer Days - Java EE 6
 
GIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE ApplicationGIDS 2012: PaaSing a Java EE Application
GIDS 2012: PaaSing a Java EE Application
 
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
 
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
 
Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010Powering the Next Generation Services with Java Platform - Spark IT 2010
Powering the Next Generation Services with Java Platform - Spark IT 2010
 
Java EE 6 & GlassFish 3
Java EE 6 & GlassFish 3Java EE 6 & GlassFish 3
Java EE 6 & GlassFish 3
 
GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0GIDS 2012: Java Message Service 2.0
GIDS 2012: Java Message Service 2.0
 
Java EE 6 Component Model Explained
Java EE 6 Component Model Explained Java EE 6 Component Model Explained
Java EE 6 Component Model Explained
 
Running your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the CloudRunning your Java EE 6 applications in the Cloud
Running your Java EE 6 applications in the Cloud
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
 
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
 
GlassFish & Java EE Business Update @ CEJUG
GlassFish & Java EE Business Update @ CEJUGGlassFish & Java EE Business Update @ CEJUG
GlassFish & Java EE Business Update @ CEJUG
 
Sun Java EE 6 Overview
Sun Java EE 6 OverviewSun Java EE 6 Overview
Sun Java EE 6 Overview
 
Glass Fishv3 March2010
Glass Fishv3 March2010Glass Fishv3 March2010
Glass Fishv3 March2010
 
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
 
The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011The State of Java under Oracle at JCertif 2011
The State of Java under Oracle at JCertif 2011
 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
 

Ähnlich wie Java EE 6 Deep Dive Hands-on

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 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
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Arun Gupta
 
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Arun Gupta
 
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 IndiaJava EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 IndiaArun Gupta
 
JavaEE 6 and GlassFish v3 at SFJUG
JavaEE 6 and GlassFish v3 at SFJUGJavaEE 6 and GlassFish v3 at SFJUG
JavaEE 6 and GlassFish v3 at SFJUGMarakana Inc.
 
Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Agora Group
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Kile Niklawski
 
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
 
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010Arun Gupta
 
Java EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureJava EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureIndicThreads
 
Understanding the nuts & bolts of Java EE 6
Understanding the nuts & bolts of Java EE 6Understanding the nuts & bolts of Java EE 6
Understanding the nuts & bolts of Java EE 6Arun Gupta
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
 
Java EE 6 & GlassFish v3: Paving path for the future
Java EE 6 & GlassFish v3: Paving path for the futureJava EE 6 & GlassFish v3: Paving path for the future
Java EE 6 & GlassFish v3: Paving path for the futureArun 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
 
JavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth SlidesJavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth SlidesEdward Burns
 
Java ee 8 + security overview
Java ee 8 + security overviewJava ee 8 + security overview
Java ee 8 + security overviewRudy De Busscher
 
Java EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConJava EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConLudovic Champenois
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalacheCodecamp Romania
 

Ähnlich wie Java EE 6 Deep Dive Hands-on (20)

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 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
 
Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6Boston 2011 OTN Developer Days - Java EE 6
Boston 2011 OTN Developer Days - Java EE 6
 
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
 
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 IndiaJava EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
 
JavaEE 6 and GlassFish v3 at SFJUG
JavaEE 6 and GlassFish v3 at SFJUGJavaEE 6 and GlassFish v3 at SFJUG
JavaEE 6 and GlassFish v3 at SFJUG
 
Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011Andrei Niculae - JavaEE6 - 24mai2011
Andrei Niculae - JavaEE6 - 24mai2011
 
Java EE8 - by Kito Mann
Java EE8 - by Kito Mann Java EE8 - by Kito Mann
Java EE8 - by Kito Mann
 
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
 
Java E
Java EJava E
Java E
 
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
 
Java EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The FutureJava EE 6 : Paving The Path For The Future
Java EE 6 : Paving The Path For The Future
 
Understanding the nuts & bolts of Java EE 6
Understanding the nuts & bolts of Java EE 6Understanding the nuts & bolts of Java EE 6
Understanding the nuts & bolts of Java EE 6
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Java EE 6 & GlassFish v3: Paving path for the future
Java EE 6 & GlassFish v3: Paving path for the futureJava EE 6 & GlassFish v3: Paving path for the future
Java EE 6 & GlassFish v3: Paving path for the future
 
Java EE 8: On the Horizon
Java EE 8:  On the HorizonJava EE 8:  On the Horizon
Java EE 8: On the Horizon
 
JavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth SlidesJavaOne 2014 Java EE 8 Booth Slides
JavaOne 2014 Java EE 8 Booth Slides
 
Java ee 8 + security overview
Java ee 8 + security overviewJava ee 8 + security overview
Java ee 8 + security overview
 
Java EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseConJava EE 6, Eclipse @ EclipseCon
Java EE 6, Eclipse @ EclipseCon
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
 

Mehr von Arun Gupta

5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdfArun Gupta
 
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Arun Gupta
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesArun Gupta
 
Secure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerArun Gupta
 
Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Arun Gupta
 
Why Amazon Cares about Open Source
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open SourceArun Gupta
 
Machine learning using Kubernetes
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using KubernetesArun Gupta
 
Building Cloud Native Applications
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native ApplicationsArun Gupta
 
Chaos Engineering with Kubernetes
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with KubernetesArun Gupta
 
How to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMArun Gupta
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Arun Gupta
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteArun Gupta
 
Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Arun Gupta
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitArun Gupta
 
Top 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeTop 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeArun Gupta
 
Container Landscape in 2017
Container Landscape in 2017Container Landscape in 2017
Container Landscape in 2017Arun Gupta
 
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftJava EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftArun Gupta
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersArun Gupta
 
Thanks Managers!
Thanks Managers!Thanks Managers!
Thanks Managers!Arun Gupta
 
Migrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersMigrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersArun Gupta
 

Mehr von Arun Gupta (20)

5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf5 Skills To Force Multiply Technical Talents.pdf
5 Skills To Force Multiply Technical Talents.pdf
 
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubernetes - AI Conclave 2019
 
Machine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and KubernetesMachine Learning using Kubeflow and Kubernetes
Machine Learning using Kubeflow and Kubernetes
 
Secure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using FirecrackerSecure and Fast microVM for Serverless Computing using Firecracker
Secure and Fast microVM for Serverless Computing using Firecracker
 
Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019Building Java in the Open - j.Day at OSCON 2019
Building Java in the Open - j.Day at OSCON 2019
 
Why Amazon Cares about Open Source
Why Amazon Cares about Open SourceWhy Amazon Cares about Open Source
Why Amazon Cares about Open Source
 
Machine learning using Kubernetes
Machine learning using KubernetesMachine learning using Kubernetes
Machine learning using Kubernetes
 
Building Cloud Native Applications
Building Cloud Native ApplicationsBuilding Cloud Native Applications
Building Cloud Native Applications
 
Chaos Engineering with Kubernetes
Chaos Engineering with KubernetesChaos Engineering with Kubernetes
Chaos Engineering with Kubernetes
 
How to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAMHow to be a mentor to bring more girls to STEAM
How to be a mentor to bring more girls to STEAM
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
 
The Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 KeynoteThe Serverless Tidal Wave - SwampUP 2018 Keynote
The Serverless Tidal Wave - SwampUP 2018 Keynote
 
Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018Introduction to Amazon EKS - KubeCon 2018
Introduction to Amazon EKS - KubeCon 2018
 
Mastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv SummitMastering Kubernetes on AWS - Tel Aviv Summit
Mastering Kubernetes on AWS - Tel Aviv Summit
 
Top 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's LandscapeTop 10 Technology Trends Changing Developer's Landscape
Top 10 Technology Trends Changing Developer's Landscape
 
Container Landscape in 2017
Container Landscape in 2017Container Landscape in 2017
Container Landscape in 2017
 
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShiftJava EE and NoSQL using JBoss EAP 7 and OpenShift
Java EE and NoSQL using JBoss EAP 7 and OpenShift
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developers
 
Thanks Managers!
Thanks Managers!Thanks Managers!
Thanks Managers!
 
Migrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to ContainersMigrate your traditional VM-based Clusters to Containers
Migrate your traditional VM-based Clusters to Containers
 

Kürzlich hochgeladen

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
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
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
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
 
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
 
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
 

Kürzlich hochgeladen (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
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
 
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
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
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
 
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.
 
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
 

Java EE 6 Deep Dive Hands-on

  • 1. <Insert Picture Here> Deep Dive Hands-on in Java EE 6 Arun Gupta, Java EE & GlassFish Guy blogs.sun.com/arungupta, @arungupta
  • 2. 2 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.
  • 4. 4 Compatible Java EE 5 Impl http://java.sun.com/javaee/overview/compatibility-javaee5.jsp
  • 5. 5 Compatible Java EE 6 Impls Today: Announced:
  • 6. 6 Goals for the Java EE 6 Platform • Flexible & Light-weight • Web Profile 1.0 • Pruning: JAX-RPC, EJB 2.x Entity Beans, JAXR, JSR 88 • Extensible • Embrace Open Source Frameworks • Easier to use, develop on • Continue on path set by Java EE 5
  • 7. 7 Java EE 6 Web Profile 1.0 • Fully functional mid-sized profile • Actively discussed in the Java EE 6 Expert Group and outside it • Technologies • Servlets 3.0, JSP 2.2, EL 2.2, Debugging Support for Other Languages 1.0, JSTL 1.2, JSF 2.0, Common Annotations 1.1, EJB 3.1 Lite, JTA 1.1, JPA 2.0, Bean Validation 1.0, Managed Beans 1.0, Interceptors 1.1, Context & Dependency Injection 1.0, Dependency Injection for Java 1.0
  • 8. 8 Java EE 6 - Done • Specifications approved by the JCP • Reference Implementation is GlassFish v3 • TCK D ec 2009
  • 9. 9 Java EE 6 Specifications • The Platform • Java EE 6 Web Profile 1.0 • Managed Beans 1.0
  • 10. 10 Java EE 6 Specifications New • Contexts and Dependency Injection for Java EE (JSR 299) • Bean Validation 1.0 (JSR 303) • Java API for RESTful Web Services (JSR 311) • Dependency Injection for Java (JSR 330)
  • 11. 11 Java EE 6 Specifications Extreme Makeover • Java Server Faces 2.0 (JSR 314) • Java Servlets 3.0 (JSR 315) • Java Persistence 2.0 (JSR 317) • Enterprise Java Beans 3.1 & Interceptors 1.1 (JSR 318) • Java EE Connector Architecture 1.6 (JSR 322)
  • 12. 12 Java EE 6 Specifications Updates • Java API for XML-based Web Services 2.2 (JSR 224) • Java API for XML Binding 2.2 (JSR 222) • Web Services Metadata MR3 (JSR 181) • JSP 2.2/EL 2.2 (JSR 245) • Web Services for Java EE 1.3 (JSR 109) • Common Annotations 1.1 (JSR 250) • Java Authorization Contract for Containers 1.3 (JSR 115) • Java Authentication Service Provider Interface for Containers 1.0 (JSR 196)
  • 13. 13 Java EE 6 Specifications As is • JDBC 4.0 API • Java Naming and Directory Interface 1.2 • Java Message Service 1.1 • Java Transaction API 1.1 • Java Transaction Service 1.0 • JavaMail API Specification 1.4 • JavaBeans Activation Framework 1.1 • Java API for XML Processing 1.3 • Java API for XML-based RPC 1.1 • SOAP with Attachments API for Java 1.3 • Java API for XML Registries 1.0 • Java EE Management Specification 1.1 (JSR 77) • Java EE Deployment Specification 1.2 (JSR 88) • Java Management Extensions 1.2 • Java Authentication and Authorization Service 1.0 • Debugging Support for Other Languages (JSR 45) • Standard Tag Library for JSP 1.2 (JSR 52) • Streaming API for XML 1.0 (JSR 173)
  • 14. 14 Managed Beans 1.0 EJB CDI JPAJAX-WS JAX-RSJSF ... @Stateful @Stateless @Singleton @Named @Entity @Web Service @Path @Managed Bean ... EJB @javax.annotation.ManagedBean
  • 15. 15 Managed Beans 1.0 • POJO as managed component for the Java EE container • JavaBeans component model for Java EE • Simple and Universally useful • Advanced concepts in companion specs • Basic Services • Resource Injection, Lifecycle Callbacks, Interceptors • Available as • @Resource / @Inject • java:app/<module-name>/<bean-name> • java:module/<bean-name>
  • 17. 17 public class MyManagedBean { public void setupResources() { // setup your resources } public void cleanupResources() { // collect them back here } public String sayHello(String name) { return "Hello " + name; } } Managed Beans 1.0 - Sample @Resource MyManagedBean bean; @javax.annotation.ManagedBean @PostConstruct @PreDestroy @Inject MyManagedBean bean; http://blogs.sun.com/arungupta/entry/totd_129_managed_beans_1
  • 18. 18 Interceptors 1.1 • Interpose on invocations and lifecycle events on a target class • Defined • Using annotations or DD • Default Interceptors (only in DD) • Class & Method Interceptors • In the same transaction & security context • Cross-cutting concerns: logging, auditing, profiling
  • 20. 20 Interceptors 1.1 - Code @InterceptorBinding @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.TYPE}) public @interface MyInterceptorBinding { } @Interceptor @MyInterceptorBinding public class MyInterceptor { @AroundInvoke public Object intercept(InvocationContext context) { System.out.println(context.getMethod.getName()); System.out.println(context.getParameters()); Object result = context.proceed(); return result; } . . . }
  • 21. 21 Interceptors 1.1 – Sample Code @Interceptors(MyInterceptor.class) public class MyManagedBean { . . . } http://blogs.sun.com/arungupta/entry/totd_134_interceptors_1_1 @Inject MyManagedBean bean; public class MyManagedBean { @Interceptors(MyInterceptor.class) public String sayHello(String name) { . . . } } Single instance of Interceptor per target class instance
  • 22. 22 Interceptors 1.1 – Sample Code @Named @Interceptors(MyInterceptor.class) public class MyManagedBean { . . . @Interceptors(AnotherInterceptor.class) @ExcludeDefaultInterceptors @ExcludeClassInterceptors public void someMethod() { . . . } }
  • 23. 23 Servlets in Java EE 5 At least 2 files <!--Deployment descriptor web.xml --> <web-app> <servlet> <servlet-name>MyServlet </servlet-name> <servlet-class> com.sun.MyServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet </servlet-name> <url-pattern>/myApp/* </url-pattern> </servlet-mapping> ... </web-app> /* Code in Java Class */ package com.sun; public class MyServlet extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res) { ... } ... }
  • 24. 24 Servlets 3.0 (JSR 315) Annotations-based @WebServlet http://blogs.sun.com/arungupta/entry/totd_81_getting_started_with package com.sun; @WebServlet(name=”MyServlet”, urlPatterns={”/myApp/*”}) public class MyServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) { ... } <!--Deployment descriptor web.xml --> <web-app> <servlet> <servlet-name>MyServlet</servlet-name> <servlet-class> com.sun.MyServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>/myApp/*</url-pattern> </servlet-mapping> ... </web-app>
  • 26. 26 Servlets 3.0 Annotations-based @WebServlet @WebServlet(name="mytest", urlPatterns={"/myurl"}, initParams={ @InitParam(name="n1", value="v1"), @InitParam(name="n2", value="v2") } ) public class TestServlet extends javax.servlet.http.HttpServlet { .... }
  • 27. 27 Servlets 3.0 Annotations-based @WebListeners <listener> <listener-class> server.LoginServletListener </listener-class> </listener> package server; . . . @WebListener() public class LoginServletListener implements ServletContextListener {
  • 29. 29 Servlets 3.0 Asynchronous Servlets • Useful for Comet, long waits • Must declare @WebServlet(asyncSupported=true) AsyncContext context = request.startAsync(); context.addListener(new AsyncListener() { … }); context.dispatch(“/request.jsp”); //context.start(Runnable action); . . . context.complete(); http://blogs.sun.com/arungupta/entry/totd_139_asynchronous_request_processing
  • 30. 30 Servlets 3.0 Extensibility • Plugin libraries using web fragments • Modular web.xml • Bundled in framework JAR file in META-INF directory • Zero-configuration, drag-and-drop for web frameworks • Servlets, servlet filters, context listeners for a framework get discovered and registered by the container • Only JAR files in WEB-INF/lib are used
  • 32. 32 <web-fragment> <filter> <filter-name>LiftFilter</filter-name> <display-name>Lift Filter</display-name> <description>The Filter that intercepts lift calls</description> <filter-class>net.liftweb.http.LiftFilter</filter-class> </filter> <filter-mapping> <filter-name>LiftFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-fragment> http://blogs.sun.com/arungupta/entry/totd_101_applying_servlet_3 Servlets 3.0 Extensibility
  • 33. 33 Servlets 3.0 Extensibility - ServletContainerInitializer • Provided by the apps or container • Discovered using the service provider API • Expresses interest in classes via @HandlesTypes • Who uses it ? • Mojarra (JSF2) is bootstrapped into GlassFish • No “faces-config.xml” or “web.xml” • Jersey (JAX-RS) registers root Application • No (or portable) “web.xml”
  • 34. 34 Servlets 3.0 Dynamic Registration – Java Server Faces @SuppressWarnings({"UnusedDeclaration"}) @HandlesTypes({ ManagedBean.class, FacesComponent.class, FacesValidator.class, FacesConverter.class, FacesBehaviorRenderer.class, ResourceDependency.class, ResourceDependencies.class, ListenerFor.class, ListenersFor.class, UIComponent.class, Validator.class, Converter.class, Renderer.class }) public class FacesInitializer implements ServletContainerInitializer { // NOTE: Loggins should not be used with this class. private static final String FACES_SERVLET_CLASS = FacesServlet.class.getName();
  • 35. 35 Servlets 3.0 Dynamic Registration – Java Server Faces public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException { if (shouldCheckMappings(classes, servletContext)) { Map<String,? extends ServletRegistration> existing = servletContext.getServletRegistrations(); for (ServletRegistration registration : existing.values()) { if (FACES_SERVLET_CLASS.equals(registration.getClassName())) { // FacesServlet has already been defined, so we're // not going to add additional mappings; return; } } ServletRegistration reg = servletContext.addServlet("FacesServlet", "javax.faces.webapp.FacesServlet"); reg.addMapping("/faces/*", "*.jsf", "*.faces"); servletContext.setAttribute(RIConstants.FACES_INITIALIZER_MAPPINGS_ADDED, Boolean.TRUE);
  • 36. 36 Servlets 3.0 Resource Sharing • Static and JSP no longer confined to document root of the web application • May be placed in WEB-INF/lib/ [*.jar]/META-INF/resources • Resources in document root take precedence over those in bundled JAR myapp.war WEB-INF/lib/catalog.jar /META-INF/resources/catalog/books.html http://localhost:8080/myapp/catalog/books.html
  • 37. 37 Servlets 3.0 Much more ... • Programmatic authentication, login, logout > HttpServletRequest.authenticate > HttpServletRequest.login > HttpServletRequest.logout • File upload support • Servlet Security > @ServletSecurity • Default Error Page > Any HTTP status code > http://blogs.sun.com/arungupta/entry/ totd_136_default_error_page <error-page> <error-code>...</error-code> <exception-type>...</exception-type> <location>/404.html</location> </error-page>
  • 38. 38 EJB 3.1 (JSR 318) Package & Deploy in a WAR foo.ear foo_web.war WEB-INF/web.xml WEB-INF/classes com.sun.FooServlet com.sun.TickTock foo_ejb.jar com.sun.FooBean com.sun.FooHelper foo.war WEB-INF/classes com.sun.FooServlet com.sun.TickTock com.sun.FooBean com.sun.FooHelper web.xml ? Java EE 5 Java EE 6 http://blogs.sun.com/arungupta/entry/totd_95_ejb_3_1
  • 40. 40 EJB 3.1 @Stateless public class App { public String sayHello(String name) { return "Hello " + name; } }
  • 41. 41 EJB 3.1 • No interface view – one source file per bean • Only for Local and within WAR • Required for Remote • No location transparency • Component initialization in @PostConstruct • No assumptions on no-arg ctor
  • 42. 42 EJB 3.1 Portable Global JNDI Name Syntax • Portable • Global • Application/Module-scoped • Derived from metadata such as name, component name etc.
  • 43. 43 EJB 3.1 Portable Global JNDI Name Syntax java:global[/<app-name>]/<module-name>/<bean-name> [!<fully-qualified-interface-name>] Only within EAR Base name of EAR (or application.xml) Base name of ejb-jar/WAR (or ejb-jar.xml/web.xml) Unqualified name of the bean class Annotation/name attribute Or ejb-jar.xml • Until now, only java:comp • Local & Remote business • No-interface • Also in java:app, java:module
  • 44. 44 public void testEJB() throws NamingException { EJBContainer ejbC = EJBContainer.createEJBContainer(); Context ctx = ejbC.getContext(); App app = (App) ctx.lookup("java:global/classes/App"); assertNotNull(app); String NAME = "Duke"; String greeting = app.sayHello(NAME); assertNotNull(greeting); assertTrue(greeting.equals("Hello " + NAME)); ejbC.close(); } EJB 3.1 Embeddable API – Deploy the Bean http://blogs.sun.com/arungupta/entry/totd_128_ejbcontainer_createejbcontainer_embedded
  • 46. 46 EJB 3.1 Singleton Beans • One instance per app/VM, not pooled • Useful for caching state • CMT/BMT • Access to container services for injection, resource manager, timers, startup/shutdown callbacks, etc. • Enable eager initialization using @Startup • Always supports concurrent access • Define initialization ordering using @Depends @Singleton public class MyEJB { . . . }
  • 47. 47 EJB 3.1 Asynchronous Session Beans • Control returns to the client before the container dispatches invocation to a bean instance • @Asynchronous – method or class • Return type – void or Future<V> • Transaction context does not propagate • REQUIRED → REQUIRED_NEW • Security principal propagates
  • 48. 48 EJB 3.1 Asynchronous Session Beans – Code Sample @Stateless @Asynchronous public class SimpleAsyncEJB { public Future<Integer> addNumbers(int n1, int n2) { Integer result; result = n1 + n2; try { // simulate JPA queries + reading file system Thread.currentThread().sleep(2000); } catch (InterruptedException ex) { ex.printStackTrace(); } return new AsyncResult(result); } } http://blogs.sun.com/arungupta/entry/totd_137_asynchronous_ejb_a
  • 49. 49 EJB 3.1 Timers • Automatically created EJB Timers • Calendar-based Timers – cron like semantics • Every 14th minute within the hour, for the hours 1 and 2 am (minute=”*/14”, hour=”1,2”) • Every 10 seconds starting at 30 (second=”30/10”) • Every 5 minutes of every hour (minute=”*/5”, hour=”*”) • 2pm on Last Thur of Nov of every year (hour=”14”, dayOfMonth=”Last Thu”, month=”Nov”) • Every Mon & Wed midnight @Schedule(dayOfWeek=”Mon,Wed”)
  • 51. 51 EJB 3.1 Timers • Single persistent timer across JVMs • Automatically created EJB Timers • @Schedule(hour=”15”,dayOfWeek=”Fri”) • Can be chained • @Schedules({ @Schedule(hour=”6”,dayOfWeek=”Tue,Thu,Fri-Sun”), @Schedule(hour=”12”,dayOfWeek=”Mon,Wed”) }) • May be associated with a TimeZone • Non-persistent timer, e.g. Cache • @Schedule(..., persistent=false)
  • 52. 52 EJB 3.1 EJB 3.1 Lite A proper subset of the full EJB 3.1 API that includes a small, powerful selection of EJB features suitable for writing portable transactional business logic . . . suitable for inclusion in a wider range of Java products, many of which have much smaller installation and runtime footprints than a typical full Java EE implementation
  • 53. 53 EJB 3.1 EJB 3.1 Lite – Feature Comparison
  • 54. 54 Contexts & Dependency Injection - CDI (JSR 299) • Type-safe Dependency Injection • No String-based identifiers • Selected at development/deployment time • Strong typing, Loose coupling • Context & Scope management - extensible • Works with Java EE modular and component architecture • Integration with Unified Expression Language (UEL)
  • 55. 55 CDI Injection Points • Field, Method, Constructor • 0 or more qualifiers • Type @Inject @LoggedIn User user Request Injection What ? (Type) Which one ? (Qualifier) @Inject @LoggedIn User user
  • 56. 56 CDI – Sample Client Code Field and Method Injection public class CheckoutHandler { @Inject @LoggedIn User user; @Inject PaymentProcessor processor; @Inject void setShoppingCart(@Default Cart cart) { … } }
  • 57. 57 CDI – Sample Client Code Constructor Injection public class CheckoutHandler { @Inject CheckoutHandler(@LoggedIn User user, PaymentProcessor processor, @Default Cart cart) { ... } } • Only one constructor can have @Inject
  • 58. 58 CDI - Sample Client Code Multiple Qualifiers and Qualifiers with Arguments public class CheckoutHandler { @Inject CheckoutHandler(@LoggedIn User user, @Reliable @PayBy(CREDIT_CARD) PaymentProcessor processor, @Default Cart cart) { ... } }
  • 59. 59 CDI - Scopes • Beans can be declared in a scope • Everywhere: @ApplicationScoped, @RequestScoped • Web app: @SessionScoped • JSF app: @ConversationScoped • Transient and long-running • Pseudo-scope (default): @Dependent • Custom scopes via @Scope • CDI runtime makes sure the right bean is created at the right time • Client do NOT have to be scope-aware
  • 60. 60 CDI - Named Beans Built-in support for the Unified EL • Beans give themselves a name with @Named(“cart”) • Then refer to it from a JSF or JSP page using the EL: <h:commandButton value=”Checkout” action=“#{cart.checkout}”/>
  • 61. 61 CDI - Events Even more decoupling • Annotation-based event model • A bean observes an event void onLogin(@Observes LoginEvent event){…} • Another bean fires an event @Inject @Any Event<PrintEvent> myEvent; void doPrint() { . . . myEvent.fire(new PrintEvent()); } • Events can have qualifiers too
  • 62. 62 CDI Much more ... • Producer methods and fields • Bridging Java EE resources • Alternatives • Interceptors • Decorators • Stereotypes • . . .
  • 63. 63 Java Server Faces 2.0 (JSR 314) • Facelets as “templating language” for the page • Custom components much easier to develop <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Enter Name &amp; Password</title> </h:head> <h:body> <h1>Enter Name &amp; Password</h1> <h:form> <h:panelGrid columns="2"> <h:outputText value="Name:"/> <h:inputText value="#{simplebean.name}" title="name" id="name" required="true"/> <h:outputText value="Password:"/> <h:inputText value="#{simplebean.password}" title="password" id="password" required="true"/> </h:panelGrid> <h:commandButton action="show" value="submit"/> </h:form> </h:body> </html>
  • 65. 65 JSF 2 Composite Components
  • 66. 66 JSF 2 Composite Components <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:ez="http://java.sun.com/jsf/composite/ezcomp"> <h:head> <title>Enter Name &amp; Password</title> </h:head> <h:body> <h1>Enter Name &amp; Password</h1> <h:form> <ez:username-password/> <h:commandButton action="show" value="submit"/> </h:form> </h:body> </html> http://blogs.sun.com/arungupta/entry/totd_135_jsf2_custom_components . . . WEB-INF index.xhtml resources/ ezcomp/ username-password.xhtml
  • 67. 67 Java Server Faces 2.0 Integrated Ajax Support • f:ajax <h:commandButton actionListener="#{sakilabean.findActors}" value="submit"> <f:ajax execute="length" render="actorTable totalActors"/> </h:commandButton> http://blogs.sun.com/arungupta/entry/totd_123_f_ajax_bean
  • 68. 68 Java Server Faces 2.0 • “faces-config.xml” optional in common cases • <managed-bean> → @ManagedBean or @Named • Validator, Renderer, Listener, ... • Default navigation rules – match a view on the disk @Named(“simplebean”) public class SimpleBean { . . . } <h:commandButton action="show" value="submit"/>
  • 69. 69 Java Server Faces 2.0 Much more ... • Runs on Servlet 2.5+ • Conditional navigation • Project Stages • Development, UnitTest, SystemTest, Production • Custom Scopes for Managed Beans • Bookmarkable URLs • h:link, h:button <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/page2.xhtml</to-view-id> <!-- Only accept if the following condition is true --> <if>#{foo.someCondition}</if> </navigation-case> <h:link outcome="viewEntry" value="Link"> <f:param name="entry" value="#{aBean.entry}"/> </h:link> <a href="http://localhost:8080/myapp/viewEntry.xhtml? entry=entry1">Link</a>
  • 70. 70 • Collection of basic types @Entity public class Person { @Id protected String ssn; protected String name; protected Date birthDate; . . . @ElementCollection @CollectionTable(name=”ALIAS”) protected Set<String> nickNames; } Java Persistence API 2 (JSR 317) Sophisticated mapping/modeling options
  • 71. 71 • Collection of embeddables @Embeddable public class Address { String street; String city; String state; . . . } @Entity public class RichPerson extends Person { . . . @ElementCollection protected Set<Address> vacationHomes; . . . } Java Persistence API 2 Sophisticated mapping/modeling options
  • 72. 72 Java Persistence API 2 Sophisticated mapping/modeling options • Multiple levels of embedding @Embeddable public class ContactInfo { @Embedded Address address; . . . } @Entity public class Employee { @Id int empId; String name; ContactInfo contactInfo; . . . }
  • 73. 73 Java Persistence API 2 Sophisticated mapping/modeling options • Improved Map support @Entity public class VideoStore { @Id Integer storeId; Address location; . . . @ElementCollection Map<Movie, Integer> inventory; } @Entity public class Movie { @Id String title; @String director; . . . }
  • 74. 74 Java Persistence API 2 Metamodel • Abstract “schema-level” model over managed classes of a Persistence Context • Entities, Mapped classes, Embeddables, ... • Accessed dynamically • EntityManager or EntityManagerFactory.getMetamodel() • And/or statically materialized as metamodel classes • Use annotation processor with javac
  • 75. 75 import javax.persistence.metamodel.*; @StaticMetamodel(Customer.class) public class Customer_ { public static SingularAttribute<Customer, Integer> custId; public static SingularAttribute<Customer, String> name; public static SingularAttribute<Customer, Address> address; public static SingularAttribute<Customer, SalesRep> rep; public static SetAttribute<Customer, Order> orders; } Java Persistence API 2 Metamodel Example @Entity public class Customer { @Id Integer custId; String name; ... Address address; @ManyToOne SalesRep rep; @OneToMany Set<Order> orders; }
  • 76. 76 Java Persistence API 2 Type-safe Criteria API EntityManager em = emf.createEntityManager(); CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery criteria = builder.createQuery(Manufacturer.class); Root root = criteria.from(Manufacturer.class); // FROM clause criteria.select(root); // SELECT clause Predicate condition = builder.like(root.get(Manufacturer_.name), "%" + name + "%"); criteria.where(condition); // WHERE clause TypedQuery query = em.createQuery(criteria); // FIRE query List manufacturers = query.getResultList();
  • 77. 77 Java Persistence API 2 Caching • 1st-level Cache by PersistenceContext • Only one object instance for any database row • 2nd-level by “shared-cache-mode” • ALL, NONE • UNSPECIFIED – Provider specific defaults • ENABE_SELECTIVE - Only entities with Cacheable(true) • DISABLE_SELECTIVE - All but with Cacheable(false) • Optional feature for PersistenceProvider • Properties for find, refresh, setProperty • CacheRetrieveMode – USE, BYPASS
  • 79. 79 Java Persistence API 2 Much more ... • New locking modes • PESSIMISTIC_READ – grab shared lock • PESSIMISTIC_WRITE – grab exclusive lock • PESSIMISTIC_FORCE_INCREMENT – update version • em.find(<entity>.class, id, LockModeType.XXX) • em.lock(<entity>, LockModeType.XXX) • Standard configuration options • javax.persistence.jdbc.[driver | url | user | password]
  • 80. 80 Bean Validation (JSR 303) • Tier-independent mechanism to define constraints for data validation • Represented by annotations • javax.validation.* package • Integrated with JSF and JPA • JSF: f:validateRequired, f:validateRegexp • JPA: pre-persist, pre-update, and pre-remove • @NotNull(message=”...”), @Max, @Min, @Size • Fully Extensible • @Email String recipient;
  • 81. 81 Bean Validation Integration with JPA • Managed classes may be configured • Entities, Mapped superclasses, Embeddable classes • Applied during pre-persist, pre-update, pre- remove lifecycle events • How to enable ? • “validation-mode” in persistence.xml • “javax.persistence.validation.mode” key in Persistence.createEntityManagerFactory • Specific set of classes can be targeted • javax.persistence.validation.group.pre-[persist|update| remove]
  • 82. 82 Bean Validation Integration with JSF • Individual validators not required • Integration with EL • f:validateBean, f:validateRequired <h:form> <f:validateBean> <h:inputText value=”#{model.property}” /> <h:selectOneRadio value=”#{model.radioProperty}” > … </h:selectOneRadio> <!-- other input components here --> </f:validateBean> </h:form>
  • 83. 83 Bean Validation Programmatic Validation @Named(value=”shopping”) public class ShoppingService { @CreditCard String card; . . . } <h:inputText value="#{shopping.card}"/>
  • 84. 84 JAX-RS 1.1 • Java API for building RESTful Web Services • POJO based • Annotation-driven • Server-side API • HTTP-centric
  • 85. 85 JAX-RS 1.1 Code Sample - Simple public class HelloWorldResource { public String sayHello() { return "Hello World"; } public String morning() { return “Good Morning!”; } } @Path("helloworld") @Context UriInfo ui; @GET @Produces("text/plain") @GET @Path("morning")
  • 87. 87 JAX-RS 1.1 Code Sample – Specifying Output MIME type @Path("/helloworld") @Produces("text/plain") public class HelloWorldResource { @GET public String doGetAsPlainText() { . . . } @GET @Produces("text/html") public String doGetAsHtml() { . . . } } @GET @Produces({ "application/xml", "application/json"}) public String doGetAsXmlOrJson() { . . . }
  • 88. 88 JAX-RS 1.1 Code Sample – Specifying Input MIME type @POST @Consumes("text/plain") public String saveMessage() { . . . }
  • 89. 89 JAX-RS 1.1 Code Sample import javax.inject.Inject; import javax.enterprise.context.RequestScoped; @RequestScoped public class ActorResource { @Inject DatbaseBean db; public Actor getActor(int id) { return db.findActorById(id); } }
  • 90. 90 JAX-RS 1.1 Code Sample import javax.inject.Inject; import javax.enterprise.context.RequestScoped; @RequestScoped public class ActorResource { @Inject DatbaseBean db; public Actor getActor( int id) { return db.findActorById(id); } } import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.PathParam; @Path("/actor/{id}") @GET @Produces("application/json") @PathParam("id") http://blogs.sun.com/arungupta/entry/totd_124_using_cdi_jpa
  • 91. 91 JAX-RS 1.1 More Code Samples • Processing POSTed HTML Form @POST @Consumes("application/x-www-form-urlencoded") public void post(@FormParam("name") String name) { // Store the message } • Sub-Resources @Singleton @Path("/printers") public class PrintersResource { @GET @Path("/list") @Produces({"application/json", "application/xml"}) public WebResourceList getListOfPrinters() { ... } @GET @Path("/ids/{printerid}") @Produces({"application/json", "application/xml"}) public Printer getPrinter(@PathParam("printerid") String printerId) { ... }
  • 92. 92 JAX-RS 1.1 Integration with Java EE 6 – Servlets 3.0 • No or Portable “web.xml” <web-app> <servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer </servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>com.foo.MyApplication</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>Jersey Web Application</servlet-name> <url-pattern>/resources/*</url-pattern> </servlet-mapping> </web-app> public class MyApplication extends javax.ws.rs.core.Application { } @ApplicationPath(“resources”)
  • 93. 93 JAX-RS 1.1 Jersey Client-side API • Consume HTTP-based RESTful Services • Easy-to-use • Better than HttpURLConnection! • Reuses JAX-RS API • Resources and URI are first-class citizens • Not part of JAX-RS yet • com.sun.jersey.api.client
  • 94. 94 JAX-RS 1.1 Jersey Client API – Code Sample Client client = Client.create(); WebResource resource = client.resource(“...”); //curl http://example.com/base String s = resource.get(String.class); //curl -HAccept:text/plain http://example.com/base String s = resource. accept(“text/plain”). get(String.class); http://blogs.sun.com/enterprisetechtips/entry/consuming_restful_web_services_with
  • 95. 95 JAX-RS 1.1 Jersey Client API – NetBeans Code Generation
  • 97. 97 JAX-RS 1.1 WADL Representation of Resources • Machine processable description of HTTP-based Applications • Generated OOTB for the application <application xmlns="http://research.sun.com/wadl/2006/10"> <doc xmlns:jersey="http://jersey.dev.java.net/" jersey:generatedBy="Jersey: 1.1.4.1 11/24/2009 01:37 AM"/> <resources base="http://localhost:8080/HelloWADL/resources/"> <resource path="generic"> <method id="getText" name="GET"> <response> <representation mediaType="text/plain"/> </response> </method> <method id="putText" name="PUT"> <request> <representation mediaType="text/plain"/> </request> </method> </resource> </resources> </application>
  • 98. 98 JAX-RS 1.1 Much more ... • Jersey is the Reference Implementation, included in GlassFish • RESTEasy, Restlet, CXF, Wink • Hypermedia support (only in Jersey) • Integration with Spring, Guice, Atom, … • WADL representation • Complete, Per resource • Jersey 1.2 modules are OSGi compliant
  • 99. 99 IDE Support for Java EE 6
  • 101. 101 What is GlassFish ? • A community • Users, Partners, Testers, Developers, ... • Started in 2005 on java.net • Application Server • Open Source (CDDL & GPL v2) • Java EE Reference Implementation
  • 102. GlassFish Distributions Distribution License Features GlassFish Open Source Edition 3.0.1 CDDL & GPLv2 • Java EE 6 Compatibility • No Clustering • Clustering planned in 3.1 • mod_jk for load balancing GlassFish Open Source Edition 2.1.1 CDDL & GPLv2 • Java EE 5 Compatibility • In memory replication • mod_loadbalancer Oracle GlassFish Server 3.0.1 Commercial • GlassFish Open Source Edition 3.0.1 • Oracle GlassFish Server Control • Clustering planned in 3.1 Oracle GlassFish Server 2.1.1 Commercial • GlassFish Open Source Edition 2.1.1 • Enterprise Manager • HADB Clustering Coming Soon!
  • 103. 103 GlassFish 3 • Modular • Maven 2 – Build & Module description • Felix – OSGi runtime (216 bundles) • Allow any type of Container to be plugged • Start Container and Services on demand • Embeddable: runs in-VM • Extensible • Rails, Grails, Django, ... • Administration, Monitoring, Logging, Deployment, ...
  • 104. 104 GlassFish 3 & OSGi • No OSGi APIs are used in GlassFish • HK2 provides abstraction layer • All GlassFish modules are OSGi bundles • Felix is default, also runs on Knopflerfish & Equinox • Can run in an existing shell • 200+ modules in v3 http://blogs.sun.com/arungupta/entry/totd_103_glassfish_v3_with
  • 105. 105
  • 106. 106 Light Weight & On-demand Monitoring • Event-driven light-weight and non-intrusive monitoring • Modules provide domain specific probes (monitoring events) • EJB, Web, Connector, JPA, Jersey, Orb, Ruby • End-to-end monitoring on Solaris using DTrace • 3rd party scripting clients • JavaScript to begin with
  • 107. 107 REST Interface • REST interface to management and monitoring data • Configuration data, commands invocation, (start/stop instance, deploy, undeploy, ...), CRUD resources (JMS, JDBC, ...) •localhost:4848/management/domain •localhost:4848/monitoring/domain • GET, POST, DELETE methods • XML, JSON, HTML reps
  • 108. 108 Boost your productivity Retain session across deployment asadmin redeploy –properties keepSessions=true helloworld.war
  • 110. 110 GlassFish Roadmap Detail ©2010 Oracle Corporation
  • 111. 111 GlassFish 3.1 = 3.0 + 2.1.1 • Main Features • Clustering and Centralized Administration • High Availability • Other ... • Application Versioning • Application-scoped Resources • SSH-based remote management and monitoring • Embedded (extensive) • Admin Console based on RESTful API http://wikis.sun.com/display/glassfish/GlassFishv3.1
  • 112. 112 References • glassfish.org • blogs.sun.com/theaquarium • oracle.com/goto/glassfish • glassfish.org/roadmap • youtube.com/user/GlassFishVideos • Follow @glassfish
  • 113. <Insert Picture Here> Deep Dive Hands-on in Java EE 6 Arun Gupta, Java EE & GlassFish Guy blogs.sun.com/arungupta, @arungupta