SlideShare a Scribd company logo
JBoss Application Server Overview
                                                                                                                                   Community Project




                                                                JBoss Application Server* is the world's lead-
                                                                ing Open Source Java EE application server for
                                                                developing and deploying enterprise applica-
                                                                tions. The latest in this line, JBoss AS 7 (Java EE
                                                                Web Profile certified), provides the same devel-
                                                                oper friendly environment as previous versions
        JBoss Application Server 7                              while offering revolutionary new management
                                                                capabilities, and much more.
Blazing fast startup (~3seconds)
Services are started concurrently to eliminate unnecessary waits and leverage multi-core processors, while non-critical
services remain passivated until rst use. JBoss AS 7 o ers a 10-fold reduction in startup time over previous versions.

Lightweight
An aggressive approach to memory management and metadata indexing keeps the footprint exceptionally small,
enabling it to run with stock JVM settings and on small devices. Pro les can be used to tune the capabilities of
the server.

Modular core
JBoss Modules o ers true application isolation, hiding server implementation classes and only loads the classes your
application needs. Class loading is concurrent for extreme performance. OSGi support is available the moment you
install the application server.

Hot, incremental deployment
Quick turnaround during development as a result of fast, concurrent deployment and the ability to edit static resources
without redeployment in a exible deployment structure.

Elegant administration
Consistent and powerful management is available, ranging from a polished, user-friendly web console to Java and
HTTP APIs to a command line tool to direct XML edits. Con guration data is centralized and user-focused.

Domain (multi-server) management
One controller can rule them all or you can simply start a standalone server. Port o sets can be changed with a single
switch. Rolling deployments are available

First class components
JBoss AS builds on many best of breed standalone OSS projects: Hibernate, JBoss Transactions, In nispan, Iron
Jacamar, RESTEasy, Weld, HornetQ, JGroups, JBoss Logging, Mojarra, Apache CXF, and more.

Java EE 6 programming model
Java EE 6 o ers a modern, loosely coupled programming model, founded on CDI, a speci cation driven by JBoss.
With Java EE 6 you can focus on implementing your business logic, and allow the platform to take care of the rest.

Testable by design
Arquillian o ers absolute delity for testing: the ability to test your application inside the actual environment. Just like
CDI, Arquillian takes care of all the boilerplate in the background, removing clutter from your tests.


            Scan this and find out
            more about the JBoss Application Server project.
            http://www.jboss.org/jbossas

                                                                          * JBoss Application Server is in the upstream for JBoss Enterprise Application Platform.
brought to you by...

#150
   Get More Refcardz! Visit refcardz.com



                                           CONTENTS INCLUDE:
                                           n	


                                           n	 	


                                           n	
                                                About the Platform
                                                Common Annotations For Java
                                                Java Platform, Enterprise Edition
                                                                                                       Java Enterprise Edition 6
                                                Java Servelet 3.0
                                                                                                                                                          The Most Elegant Enterprise Java Yet
                                           n	


                                           n	
                                                JavaServer Faces 2.0
                                           n	
                                                Enterprise JavaBeans 3.1                                                                                                        By Andrew Lee Rubinger

                                                                                                                                         Reference
                                                    ABOUT THE PLATFORM                                                                   The full JavaDoc for the Java EE 6 API is located at:
                                                                                                                                         http://download.oracle.com/javaee/6/api/
                                           Enterprise software development is inherently complex, and multi-user
                                           systems open the door to concerns such as transactional integrity, security,                      COMMON ANNOTATIONS FOR THE JAVA PLATFORM
                                           persistence integration, and interaction between components. Very simply
                                           put, the mission of the Java Enterprise Edition is to enable an out-of-the-box
                                           set of configurable services that allows the programmer to write less and focus               JSR-250
                                           on delivering clean business logic.
                                                                                                                                         he common annotations for Java EE are a shared package used throughout
                                           To this end, Java EE 6 is an aggregate of many interoperable technologies
                                                                                                                                         the platform specifications that generally focus on shared services like
                                           designed to deliver a unified experience. Application Servers that are
                                                                                                                                         lifecycle, injection, and security.
                                           certified to the standards defined by the Java Community Process are
                                           intended to service applications written to the specifications within the
                                           platform.
                                                                                                                                          Class Name             Description
                                           For the sake of brevity, this reference card will focus on the key APIs of Java EE             Generated              Marks generated code
                                           6 that are most relevant to modern development.
                                                                                                                                          ManagedBean            Defines a class as a Java EE 6 Managed Bean


                                                    JAVA PLATFORM, ENTERPRISE EDITION 6 (JAVA EE 6)                                       PostConstruct          Lifecycle callback after an instance has been created but
                                                                                                                                                                 before it is put into service
                                                                                                                                          PreDestroy             Lifecycle callback before an instance is to be removed from
                                           JSR-316                                                                                                               service

                                           This umbrella specification ties together the various subsystems that comprise                 Resource               Defines an injection point, marks that this is to be provided by
                                           the platform and provides additional integration support.                                                             the container

                                           Profiles                                                                                       Resources              Allows for injection of N resources

                                           New to Java EE 6 is the notion of the “Web Profile”, a subset of the full
                                           specification that is targeted to cater to more specialized and minimal web-                   DeclareRoles           Class-level target defining valid security roles
                                           based application requirements. It is guaranteed to support the platform
                                           common annotations for injection and lifecycle (JSR-250), JNDI Naming                          DenyAll                Marks that no roles are allowed to access this method
                                           standards, and the Java Transaction API. Additionally, the Web Profile
                                           focuses on Servlet and closely related technologies such as persistence, view                  PermitAll              Marks that all roles are allowed to access this method (or all
                                           presentation (JavaServer Faces and JavaServer Pages), and the business logic                                          methods if applied to a class)
                                           elements of EJB Lite.
                                                                                                                                          RolesAllowed           Specifies list of roles permitted to access this method (or all
                                           Code Example                                                                                                          methods if applied to a class)


                                           The simple class below is all it takes in Java EE 6 to define a POJO-based
                                           managed component capable of lifecycle callbacks, interceptors, and
                                           resource injection.

                                                /**
Java Enterprise Edition 6




                                                 * Interceptor logging that an invocation has been received
                                                 */
                                                public class LoggingInterceptor {

                                                    @AroundInvoke
                                                    public Object intercept(InvocationContext context) throws Exception {
                                                        System.out.println(“Been intercepted: “ + context);
                                                        return context.proceed();
                                                    }
                                                }

                                                /**
                                                 * Defines a simple managed bean able to receive an injection
                                                 */
                                                @ManagedBean
                                                @Interceptors({LoggingInterceptor.class}) // Invocations will be
                                                   // intercepted
                                                public class ComponentResourceInjection {

                                                    @Resource
                                                    private UserTransaction userTransaction;

                                                    // ... business methods will be intercepted
                                                    // by LoggingInterceptor




                                                                                                                       DZone, Inc.   |   www.dzone.com
2                                                                      Java Enterprise Edition 6




 RunAs                     Defines the identity context when run in the container                     RolesAllowed                  Specifies list of roles permitted to access this method (or all
                                                                                                                                    methods if applied to a class)


                                                                                                      RunAs                         Defines the identity context when run in the container
     JAVA SERVLET 3.0

                                                                                                          JAVA API FOR RESTFUL WEB SERVICES (JAX-RS)
JSR-315

Servlet technology models the request/response programming model and                                 JSR-311
is commonly used to extend HTTP servers to tie into server-side business
logic. In Servlet 3.0, the specification has been expanded to include                                New to Java EE, the JAX-RS specification allows for standard development
support for annotations, asynchronous processing, pluggability, and                                  adhering to the Representational State Transfer (REST) paradigm. These
general ease-of-configuration.                                                                       applications are packaged as a Servlet inside a web application archive.

Code Example
                                                                                                      /**
Because Servlet 3.0 includes annotations to define servlets, the descriptor                            * JAXB Model of a Name
                                                                                                       */
web.xml is no longer required in most of the common cases; below is an                                @XmlRootElement
example of all that’s needed to create a simple servlet.                                              public class Name {

 /**                                                                                                         private String name;
  * Simple Servlet which welcomes the user by name specified
  * by the request parameter “name”.                                                                         public Name(String name) {
  */                                                                                                             this.name = name;
 @WebServlet(urlPatterns =                                                                                   }
 {“/welcome”}) // Will service requests to the path “/welcome”                                               public Name() {}
 public class WelcomeServlet extends HttpServlet
 {                                                                                                           public String getName() {return this.name;}
    /**
     * Inject a reference to an EJB                                                                          public void setName(String name) {
     */                                                                                                          this.name = name;
    @EJB                                                                                                     }
    private WelcomeBean bean;                                                                         }

    /**                                                                                               /**
     * Service HTTP GET Requests                                                                       * Services requests for the path “/name”
     */                                                                                                * returning the JAXB-formed Name XML
    @Override                                                                                          */
    protected void doGet(final HttpServletRequest request, final HttpServletResponse                  @Path(“/name”)
 response) throws ServletException,                                                                   @Produces({“application/xml”})
           IOException                                                                                public class NamedResource extends javax.ws.rs.core.Application {
    {                                                                                                     @GET
       // Get the name from the request                                                                   public Name get(@QueryParam(“name”) String name) {
       final String name = request.getParameter(“name”);                                                      return new Name(name);
                                                                                                          }
       // Precondition checks                                                                         }
       if (name == null)
       {
          response.sendError(HttpServletResponse.SC_BAD_REQUEST, “Request                            ...and HTTP GET requests to “{baseUrl}/myapp/name?name=andrew” will
 parameter ”name” is required”);                                                                   return the XML form for the Name.
       }

         // Set content type                                                                         Public API Annotation Selection from javax.ws.rs:
         response.setContentType(“text/plain”);

         // Get the welcome message
                                                                                                      Class Name                    Description
         final String welcomeMessage = bean.welcome(name);
                                                                                                      Consumes                      Defines the media types that may be accepted
         // Write out
         response.getWriter().write(welcomeMessage);
     }                                                                                                CookieParam                   Injects the value of an HTTP cookie to a method param
                                                                                                                                    or bean/class field
 }


                                                                                                      DefaultValue                  Defines default values for cookies and other parameters
Public API from javax.servlet.annotation:
 Class Name                Description                                                                DELETE                        Flags that a method is to service HTTP DELETE requests

 HttpConstraint            Defines security constraints for all HTTP-servicing meth-
                           ods in a secured servlet                                                   Encoded                       Disables automatic decoding of parameter values

 HttpMethodCon-            Defines security constraints for an HTTP-servicing
                                                                                                      FormParam                     Injects the value of a form parameter to a resource method
 straint                   method in a servlet                                                                                      parameter

 MultipartConfig           Indicates the servlet is to service requests for multipart/                GET                           Flags that a method is to service HTTP GET requests
                           form-data MIME type
                                                                                                      HEAD                          Flags that a method is to service HTTP HEAD requests
 ServletSecurity           Secures a servlet class for HTTP-servicing methods


 WebFilter                 Defines a class as a servlet filter                                        HeaderParam                   Injects the value of a header parameter

                                                                                                      HttpMethod                    Draws an association between an HTTP method with an an-
 WebInitParam              Specificies an initialization parameter on a servlet or filter                                           notation

 WebListener               Defines a class as a web listener                                          MatrixParam                   Injects the value of a URI matrix parameter


 WebServlet                Defines a class as a servlet                                               Path                          Designates the URI path that a resource class or resource
                                                                                                                                    method will serve

 PermitAll                 Marks that all roles are allowed to access this method (or all             PathParam                     Injects the value of a URI path parameter
                           method if applied to a class)




                                                                                   DZone, Inc.   |   www.dzone.com
3                                                                   Java Enterprise Edition 6




 POST                       Flags that a method is to service HTTP POST requests                   javax.enterprise.inject.Model                          Built-in stereotype for beans
                                                                                                                                                          defining the model layer of an MVC
                                                                                                                                                          webapp (ie. JSF)
 Produces                   Signals the media type(s) to be served by this resource
                                                                                                   javax.enterprise.inject.New                            Built-in qualifier type
 PUT                        Flags that a method is to service HTTP PUT requests
                                                                                                   javax.enterprise.inject.Produces                       Identifies a Producer method or field
 QueryParam                 Injects the value of a query parameter
                                                                                                   javax.enterprise.inject.Specializes                    Indicates that a bean specializes
                                                                                                                                                          another bean

                                                                                                   javax.enterprise.inject.Stereotype                     Specifies that an annotation is a
      CONTEXTS AND DEPENDENCY INJECTION FOR JAVA                                                                                                          stereotype

                                                                                                   javax.enterprise.inject.Typed                          Restricts the types of a bean

JSR-299
                                                                                                  Relevent Public Annotation API from JSR-330,
The Java Contexts and Dependency Injection (CDI) specification                                    Dependency Injection for Java in package javax.inject:
introduces a standard set of application component management services
                                                                                                   Class Name          Description
to the Java EE platform. CDI manages the lifecycle and interactions
of stateful components bound to well defined contexts. CDI provides                                Inject              Identifies injectable constructors, methods, and fields
typesafe dependency injection between components. CDI also provides
                                                                                                   Named               String-based qualifier
interceptors and decorators to extend the behavior of components,
an event model for loosely coupled components and an SPI allowing
portable extensions to integrate cleanly with the Java EE environment.                             Qualifier           Identifies qualifier annotations
Additionally, CDI provides for easy integration with view layers such as                           Scope               Identifies scope annotations
JavaServer Faces 2.0 (JSR-314).

                                                                                                   Singleton           Identifies a type that the injector only instantiates once
Code Example
                                                                                                  For a deeper dive into CDI, check out DZone’s CDI Refcard: http://
Below is a simple example of a CDI Bean that is placed in scope alongside                         refcardz.dzone.com/refcardz/contexts-and-depencency
the HTTP session, given a String-based name binding (such that it may be
used in JSF view components, for example) and injects the FacesContext
such that it may be used in business methods.                                                          BEAN VALIDATION 1.0


 @SessionScoped // Bind to the web session                                                        JSR-303
 @Named // To be used in view components by name
 public class GreeterBean implements Serializable {
                                                                                                  New to Java EE 6, the Bean Validation Specification provides for unified
     @Inject // Used to integrate w/ JSF
     private FacesContext context;
                                                                                                  declaration of validation constraints upon bean data. It may be used to
                                                                                                  maintain the integrity of an object at all levels of an application: from user
     public GreeterBean() {}
                                                                                                  form input in the presentation tier all the way to the persistence layer.
     // ... business methods

 }                                                                                                Code Example

                                                                                                  Here is an example of how to apply Bean Validation constraints in a
 Class Name                                           Description                                 declarative fashion to ensure the integrity of a User object.

 javax.decorator.Decorator                            Declares the class as a Decorator            public class User {
                                                                                                       @NotNull
                                                                                                       @Size(min=1, max=15)
 javax.decorator.Delegate                             Specifies the injection point of a               private String firstname;
                                                      Decorator
                                                                                                       @NotNull
                                                                                                       @Size(min=1, max=30)
                                                                                                       private String lastname;
 javax.enterprise.context.ApplicationScoped           Specifies the bean has applica-
                                                      tion scope                                       @Pattern(regexp=”b[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}b”)
                                                                                                       public String email;

                                                                                                   }
 javax.enterprise.context.ConversationScoped          Specifies the bean has conversation
                                                      scope

                                                                                                  Public Annotation API for javax.validation
 javax.enterprise.context.Dependent                   Specifies the bean belongs to
                                                      dependent pseudo-scope                       Class Name                  Description
                                                                                                   Constraint                  Link between a constraint annotation and its constraint
 javax.enterprise.context.NormalScope                 Specifies the bean is normally-                                          validation implementations
                                                      scoped
                                                                                                   GroupSequence               Defines a group sequence
 javax.enterprise.context.RequestScoped               Specifies the bean is request-scoped

 javax.enterprise.context.SessionScoped               Specifies the bean is session-scoped         OverridesAttribute          Mark an attribute as overriding the attribute of a com-
 javax.enterprise.event.Observes                      Identifies an event parameter of an                                      posing constraint
                                                      observer method
                                                                                                   OverridesAttribute.List     Defines several @OverridesAttribute annotations on the same
 javax.enterprise.inject.Alternative                  Specifies that the bean is an                                            element
                                                      Alternative
                                                                                                   ReportAsSingleViola-        A constraint annotation hosting this annotation will return the
                                                                                                   tion                        composed annotation error report if any of the composing
 javax.enterprise.inject.Any                          Built-in qualifier type
                                                                                                                               annotations fail.
 javax.enterprise.inject.Default                      Default qualifier type                       Valid                       Mark an association as cascaded

 javax.enterprise.inject.Disposes                     Identifies the disposed parameter of
                                                      a disposer method




                                                                                DZone, Inc.   |   www.dzone.com
4                                                            Java Enterprise Edition 6




                                                                                           ManagedProperty           Injection point for fields in ManagedBean classes
     JAVASERVER FACES 2.0

                                                                                           NoneScoped                Denotes a ManagedBean is to be in the “none” scope
JSR-314                                                                                    ReferencedBean            Denotes the class as a referenced bean

JavaServer Faces is a user interface (UI) framework for the development                    RequestScoped             Denotes a ManagedBean is to be in request scope
of Java web applications. Its primary function is to provide a component-
                                                                                           SessionScoped             Denotes a ManagedBean is to be in session scope
based toolset for easily displaying dynamic data to the user. It also
integrates a rich set of tools to help manage state and promote code                       ViewScoped                Denotes a ManagedBean is to be in view scope
reuse.
                                                                                          Public API from javax.faces.application:
Additionally, JSF is an extensible specification that encourages the
authoring of custom user views. It’s designed with tooling in mind such                    Class Name                Description
that integrated development environments (IDEs) can intelligently assist
                                                                                           Application               Singleton scoped per web application to provide
with design.
                                                                                                                     configuration for things like validators, components
                                                                                                                     and converters
Code Example
                                                                                           ApplicationFactory        Creates (if required) and returns Application instances
Here we’ll show a simple example of a JSF managed bean whose state is
scope to the HTTP request, and is registered to a bean name that may be                    ApplicationWrapper        Application type which may be used by developers to
accessed by the view layer.                                                                                          add to an existing ResourceHandler
                                                                                           ConfigurableNavigation-   Extends NavidationHandler to provide runtime inspection
                                                                                           Handler                   of the NavigationCase which defines the rule base for
 /**                                                                                                                 navigation
  * This class defines a bean to live bound to the HTTP
  * request scope, and may be accessed by the view layer                                   FacesMessage              A single validation message
  * under the name “hitchhikersGuide”.
  */                                                                                       NavigationCase            A single navigation case in the navigation rule base
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
 import javax.faces.application.ProjectStage;
                                                                                           NavigationHandler         Handles navigation from a given action and outcome
 import javax.faces.bean.ManagedBean;
 import javax.faces.bean.ManagedProperty;                                                  Resource                  Models a client resource request

 @RequestScoped                                                                            ResourceHandler           API by which UIComponent and Renderer instances can
 @ManagedBean(name = “hitchhikersGuide”)                                                                             reference Resource instances
 public class HitchhikersGuide {
     private String ultimateAnswer;
                                                                                           ResourceWrapper           Simple base implementation of Resource to be extended
     @ManagedProperty(value = “#{facesContext.application.projectStage}”)                                            by developers looking to add custom behaviors
     private ProjectStage journeyStage;
                                                                                           StateManager              Coordinates the process of saving and restoring the view
     public String getUltimateAnswer() {                                                                             between client requests
         return ultimateAnswer;
     }                                                                                     StateManagerWrapper       Base implementation of a StateManager which may be
                                                                                                                     subclasses by developers looking to add custom behaviors
     public void setUltimateAnswer(String ultimateAnswer) {
         this.ultimateAnswer = ultimateAnswer;                                             ViewHandler               Pluggable point for the render response and restore view
     }                                                                                                               phases of the request lifecycle.
     public ProjectStage getJourneyStage() {
                                                                                           ViewHandlerWrapper        Base implementation of a ViewHandler which may be sub-
         return journeyStage;
     }                                                                                                               classes by developers looking to add custom behaviors.

     public void setJourneyStage(ProjectStage journeyStage) {
         this.journeyStage = journeyStage;
     }
                                                                                              ENTERPRISE JAVABEANS 3.1
     @PostConstruct
     public void findUltimateAnswerToUltimateQuestion() {
         ultimateAnswer = “42”;

 }
     }                                                                                    JSR-318
 index.xhtml View:                                                                        Enterprise JavaBeans provide a component model to encapsulate
 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”                           business logic. As such, they provide a few bean types:
    “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
 <html xmlns=”http://www.w3.org/1999/xhtml”                                                 •	 Session Beans
    xmlns:h=”http://java.sun.com/jsf/html”
    xmlns:f=”http://java.sun.com/jsf/core”>
    <head>
                                                                                            •	 Stateless
       <title>Sample JSF Page</title>
    </head>                                                                                 •	 No conversational state between requests
    <body>
    <f:view>
       <h2><h:outputText value=”Test Managed Bean Annotations”/></h2>                       •	 Stateful
       <p><h:outputText value=”hitchhikersGuide.ultimateAnswer =
 #{hitchhikersGuide.ultimateAnswer}”/></p>
       <h2><h:outputText value=”Test Project Stage”/></h2>
                                                                                            •	 Same bean instance used to service each client/session
       <p><h:outputText value=”project stage = #{hitchhikersGuide.
 journeyStage}”/></p>                                                                       •	 Singleton
    </f:view>
    </body>
 </html>                                                                                    •	 One shared bean instance for all users
                                                                                            •	 Message-Driven
Public API from javax.faces.bean:
                                                                                            •	 Event Listener
 Class Name                 Description
                                                                                            •	 JCA endpoint
 ApplicationScoped          Denotes a ManagedBean is to be in application
                            scope                                                           •	 Asynchronous
 CustomScoped               Denotes a ManagedBean is to be in a custom-de-
                                                                                            •	 Entity
                            fined scope of the specified value
 ManagedBean                Defines a class as a ManagedBean type                           •	 Integration point w/ Java Persistence



                                                                        DZone, Inc.   |   www.dzone.com
5                                                                   Java Enterprise Edition 6




Code Example                                                                                    TransactionManage-           Configures transactional management for a Session or
                                                                                                ment                         Message-Driven Bean (container or bean provided)
It’s simple to define an EJB capable of greeting a user.


 /**
  * Stateless Session EJB                                                                            JAVA PERSISTENCE 2.0
  */
 @Stateless // Defines a Stateless Session Bean
 @LocalBean // No-interface view
 public class GreeterBean {
     @Override                                                                                 JSR-317
     public String greet(String name) {
         return “Hi, “ + name + “!”;
     }                                                                                         Most enterprise applications will need to deal with persistent data,
 }                                                                                             and interaction with relational databases can be a tedious and difficult
                                                                                               endeavor. The Java Persistence specification aims to provide an object
                                                                                               view of backend storage in a transactionally aware manner. By dealing
Other components, such as Servlets, may now inject a proxy to the above                        with POJOs, JPA enables developers to perform database operations
EJB:                                                                                           without the need for manually tuning SQL.

@EJB private GreeterBean greeterEjb;
                                                                                               Code Example
Public API Annotation Selection from javax.ejb:                                                A JPA entity is simply a POJO with some annotations to provide additional
 Class Name               Description                                                          mapping metadata. For instance:

 AccessTimeout            Designates the amount of time a concurrent method                      @Entity
                          should block before timing out                                         public class SimpleEmployee {
                                                                                                    @Id @Auto
 ActivationConfig-        Used to configure Message-Driven Beans                                    private Long id;
                                                                                                    private String name;
 Property
                                                                                                     public   Long getId(){ return id; }
 AfterBegin               Defines a Tx callback method for the “after begin”                         public   void setId(final Long id) { this.id = id; }
                                                                                                     public   String getName() { return name; }
                          event                                                                      public   void setName(final String name) { this.name = name; }
                                                                                                 }
 AfterCompletion          Defines a Tx callback method for the “after completion” event


 ApplicationException     Defines a user exception which should not be wrapped                 Now a managed component such as an EJB or CDI bean can interact with
                                                                                               the database through our entity by associating it with an EntityManager.
 Asynchronous             Defines methods to be executed asynchronously.
                                                                                                 @PersistenceContext
                                                                                                 private EntityManager em;
 BeforeCompletion         Defines a Tx callback method for the “before completion”
                          event                                                                  public void createUser(){
                                                                                                   final SimpleEmployee andrew = new SimpleEmployee();
 ConcurrencyManage-       Configures the concurrency management mode for a single-                 andrew.setId(100L);
 ment                     ton session bean                                                         andrew.setName(“Andrew Lee Rubinger”);
                                                                                                   em.persist(andrew); // Store in the DB
 DependsOn                Designates initialization order for Singleton Session Beans              // Now any state changes done to this managed object will be
                                                                                                   // reflected in the database when the Tx completes
                                                                                                 }
 EJB                      Defines an injection point and dependency upon an EJB
                          component

 EJBs                     Plural injection point and dependency for EJB components, to
                          be applied at the class-level                                        Public API Annotation Selection from javax.persistence:
 Local                    Defines a local business interface view                               Class Name               Description
 LocalBean                Defines a no-interface view                                           Basic                    Describes mapping for a database column

 Lock                     Defines a concurrency lock for Singleton Session Beans using
                          container-managed concurrency
                                                                                                Column                   Specifies column mapping for a persistent property

 MessageDriven            Defines a Message-Driven Bean
                                                                                                DiscriminatorCol-        Notes the discriminator column used for SINGLE_TABLE
 PostActivate             Defines an event callback after a Stateful Session Bean has           umn                      and JOINED inheritance strategies
                          been activated

 PrePassivate             Defines an event callback before a Stateful Session Bean is to        DiscriminatorValue       Specifies the value of the discriminator column for entities of this
                          be passivated                                                                                  type

 Remote                   Defines a remote business interface view                              ElementCollection        Defines a collection of instances

 Remove                   Defines a business method that should trigger the removal of
                          a Stateful Session Bean instance (i.e., destroy the session)          Embeddable               Defines a class whose instances are stored as part of the owning
                                                                                                                         entity
 Schedule                 Defines a new timer to be created with a specified schedule

 Schedules                Plural of Schedule                                                    Embedded                 Specifies a persistent property whose value is an instance of an
                                                                                                                         embeddable class
 Singleton                Defines a Singleton Session Bean

 Startup                  Denotes that a Singleton Session Bean should eagerly load             EmbeddedId               Denotes composite primary key of an embeddable class

 Stateful                 Defines a Stateful Session Bean
                                                                                                Entity                   Defines a POJO as a persistent entity
 StatefulTimeout          Defines the amount of idle time before a Stateful Session is
                          eligible for removal                                                  EntityListeners          Specifies callback listeners

 Stateless                Defines a Stateless Session Bean
                                                                                                Enumerated               Specifies that a persistent property should be persisted as an
 Timeout                  Defines a timer expiration method                                                              enumeration

 TransactionAttribute     Configures the transactional context under which business
                          methods should execute


                                                                             DZone, Inc.   |   www.dzone.com
6                                                            Java Enterprise Edition 6




                                                                                                                                                                                   GeneratedValue                                                                                                                                  Specifies generation strategies for primary keys                                                                                    PostLoad          Define an event callback method

                                                                                                                                                                                                                                                                                                                                                                                                                                                                       PostPersist       Define an event callback method
                                                                                                                                                                                   Id                                                                                                                                              Denotes a primary key field
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       PostRemove        Define an event callback method
                                                                                                                                                                                   IdClass                                                                                                                                         Denotes a composite primary key class
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       PostUpdate        Define an event callback method
                                                                                                                                                                                   Inheritance                                                                                                                                     Denotes the inheritance strategy for this given entity
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       PrePersist        Define an event callback method
                                                                                                                                                                                   JoinColumn                                                                                                                                      Specifies a column for joining an entity association or element
                                                                                                                                                                                                                                                                                                                                   collection.                                                                                                                         PreRemove         Define an event callback method
                                                                                                                                                                                   JoinColumns                                                                                                                                     Plural of JoinColumn                                                                                                                                  Define an event callback method
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       PreUpdate
                                                                                                                                                                                   JoinTable                                                                                                                                       Maps associations                                                                                                                                     Specifies the primary table for this entity
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Table
                                                                                                                                                                                   Lob                                                                                                                                             Denotes a binary large object persistent property                                                                                                     Denotes persistence of Date and Calendar field types
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Temporal
                                                                                                                                                                                   ManyToMany                                                                                                                                      Defines an N:N relationship                                                                                                                           Denotes that a property is not persistent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Transient
                                                                                                                                                                                   ManyToOne                                                                                                                                       Defines an N:1 relationship                                                                                                                           Specifies the persistent property used as the optimistic lock
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Version
                                                                                                                                                                                   NamedQuery                                                                                                                                      Defines a static query in JPAQL

                                                                                                                                                                                   OneToMany                                                                                                                                       Defines a 1:N relationship

                                                                                                                                                                                   OneToOne                                                                                                                                        Defines a 1:1 relationship

                                                                                                                                                                                   OrderBy                                                                                                                                         Specifies ordering of elements when a Collection is retrieved

                                                                                                                                                                                   PersistenceContext                                                                                                                              Used for injecting EntityManager instances

                                                                                                                                                                                   PersistenceUnit                                                                                                                                 Used for injecting EntityManagerFactory instances




                                                                                                                                        ABOUT THE AUTHOR                                                                                                                                                                                                                                                                                                               RECOMMENDED BOOK

                                                                                                                                                                                                                                                                             Andrew Lee Rubinger                                                                                                                                                                                            Learn how to code, package, deploy, and test
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            functional Enterprise JavaBeans with the latest
                                                                                                                                                                                                                                                                             Open Source Software Engineer and Author                                                                                                                                                                       edition of bestselling guide. Written by the
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            developers of the JBoss EJB 3.1 implementation,
                                                                                                                                                                                      Advocate for and speaker on testable enterprise Java                                                                                                                                                                                                                                                  this book brings you up to speed on each of the
                                                                                                                                                                                      development, author of “Enterprise JavaBeans 3.1”                                                                                                                                                                                                                                                     component types and container services in this
                                                                                                                                                                                      from O’Reilly Media. Member of the JBoss Application                                                                                                                                                                                                                                                  technology, while the workbook in the second
                                                                                                                                                                                      Server development team and technical lead of the                                                                                                                                                                                                                                                     section provides several hands-on examples for
                                                                                                                                                                         ShrinkWrap project. Proudly employed by JBoss / Red Hat.                                                                                                                                                                                                                                                           putting the concepts into practice. Enterprise
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            JavaBeans 3.1 is the most complete reference
                                                                                                                                                                                                                                                                                                                                                                                                                                                                       you’ll find on this specification.




                                                                                                                                       #82

                                                                                                                                                                                                                                                                                                                                                                                            Browse our collection of over 100 Free Cheat Sheets
                                                                                                                                           Get More Refcardz! Visit refcardz.com




                                                                                                                                                                                      CONTENTS INCLUDE:
                                                                                                                                                                                      ■


                                                                                                                                                                                      ■
                                                                                                                                                                                          About Cloud Computing
                                                                                                                                                                                          Usage Scenarios                                                                              Getting Started with

                                                                                                                                                                                                           Aldon                                               Cloud 4Computing
                                                                                                                                                                                      ■
                                                                                                                                                                                          Underlying Concepts
                                                                                                                                                                                          Cost
                                                                                                                                                                                                   by...                                                            #6
                                                                                                                                                                                      ■




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Upcoming Refcardz
                                                                                                                                                                                                                                                 ®
                                                                                                                                                                                          t to you
                                                                                                                                                                                       Data Tier Technologies
                                                                                                                                                                                      ■



                                                                                                                                                                                   brough                                            Comply.
                                                                                                                                                                                       Platform Management and more...     borate.
                                                                                                                                                                                      ■



                                                                                                                                                                                                            Chan
                                                                                                                                                                                                                  ge. Colla                                                                                                                       By Daniel Rubio


                                                                                                               on:
                                                                                                                                                                                                                                                                                               dz. com




                                                                                                          grati s
                                                                                                                                                                                                                                                                         also minimizes the need to make design changes to support
                                                                                                                                                                                                                                                                                               CON
                                                                                                                                                                                              ABOUT CLOUD COMPUTING                                                      one time events.           TEN TS
                                                                                                                                                                                                                                                                                                           INC



                                                                                                    s Inte -Patternvall
                                                                                                                                                                                                                                                                                                                             ■
                                                                                                                                                                                                                                                                                                                                 HTML                 LUD E:
                                                                                                                                                                                                                                                                                                                                        Basics
                                                                                                                                                                                                                                                                                         HTML
                                                                                                                                                                                                                                                                                             ref car




                                                                                                                                                                                                                                                                                                                         ■

                                                                                                                                                                                                                                                                         Automated growth & scalable technologies



                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Java EE 6
                                                                                                                                                                                          Web applications have always been deployed on servers



                                                                                             nuou d Anti Paul M. Du
                                                                                                                                                                                                                                                                                              vs XHT
                                                                                                                                                                                                                                                                                                    ation
                                                                                                                                                                                                                                                                                                                     ■
                                                                                                                                                                                                                                                                                                                         Valid                   ML
                                                                                                                                                                                          connected to what is now deemed the ‘cloud’.                                   Having the capability to support one time events, cloud
                                                                                                                                                                                                                                                                                              Useful




                                                                                        ContiPatterns an
                                                                                                                                                                                                                                                                                                                 ■


                                                                                                                                                                                                                                                                         computing platforms also facilitate the gradual growth curves
                                                                                                                                                                                                                                                                                                     Open
                                                                                                                                                                                                                                                                                             Page         Source
                                                                                                                                                                                                                                                                                                             ■
                                                                                                                                                                                                                                                                                       Vis it




                                                                                                                                                                                          However, the demands and technology used on such servers                                                 Stru
                                                                                                                                                                                                                                                                         faced by web applications. cture         Tools




                                                                                                                                                                                                                                                                                                                                                                                     Core
                                   E:                                                                      By                                                                             has changed substantially in recent years, especially with
                                                                                                                                                                                                                                                                                             Key         ■

                                                                                                                                                                                                                                                                                                                                 Structur       Elem
                                                                                                                                                                                                                                                                                                                                            al Elem ents
                         INC LUD gration                                                                                                                                                  the entrance of service providers like Amazon, Google and                                                             ents and
                                                                                                                                                                                                                                                                         Large scale growth scenarios involving specialized equipment
                   NTS
                                                                                                                                                                                                                                                                                    rdz !




                             ous Inte Change



                                                                                                                                                                                                                                                                                                                                                                                          HTML
           CO NTE                                                                                                                                                                                                                        es                                                                               more...




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      MySQL 5.5
                    Continu at Every                                                                                                                                                      Microsoft.                              e chang                                (e.g. load balancers and clusters) are all but abstracted away by
            About                      ns                                                                                                                                                                                            to isolat
                                                                                                                                                                                                                                                                         relying on a cloud computing platform’s technology.
                    Software i-patter
            ■
                                                                                                                                                                            n                                 space
                                                                                                                                                                                                                                                                                       fca




                                                                                                                                                                                                    e Work
             Build
                                                                                                                                                                    riptio
                        and Ant                                                                                                              These companies have Privat deployed webmanage
                                                                                                                                                              Desc                         a
                                                                                                                                                                                   are in long trol repos
                                                                                                                                                                                                                         itory
                                                                                                                                                                                                                                         applications                                                                        HTM
                                                                                                                                                                                                                                                                                                                                     L BAS
                ■


              Patterns Control                                                                                                                                        lop softw                     n-con                           to
                                                                                                                                                                                                                          ing and                                                                                    ICS
                                                                                                                                                                                                                                                                                 re Re




                    ■
                                                                                                                                             that adapt and scale to large user bases, making them
                                                                                                                                                               Deve
                                                                                                                                                                                  les to
                                                                                                                                                                                          a versio                                                                       In addition, several cloud computing platforms support data
                                ment                                                                                                                                                                         ize merg
                                                                                                                                rn
               Version                  e...                                                                              Patte                                           it all fi                to minim
                                                                                                                                                                                    many aspects related tomultiple computing.
                                                                                                                                                                                                                                                                                             HTM
r




                      Manage s and mor                                                                                           e Work knowledgeable in a mainline                                                                  s cloud                             tier technologies that L and the precedent set by Relational
                                                                                                                                                                                                                                                                                                     exceed
                        ■                                                                                                                 space                  Comm
ref ca




                Build                                                                                                      Privat                                        lop on                                        that utilize                                                          HTML          XHT
                            tice                                                                                                                                                                                                                                                                     is used ML are the
                                                                                                                                                                                                                                                                         Database Systems (RDBMS): Map Reduce, web service APIs,
                            ■

                       Prac                                                                                                                                       Deve code lines                         a system
                 Build                                                                                                            sitory                                                                                                       of work                                      prog
                                                                                                                                                                                                                                                                                                   support as the grap foundation                                                                                                    By An
                                                                                                                                                                                                                                                                         Ge t Mo




                                                                                                                            Repo                                   active                    are within
                                                                                                                                             This Refcard will introduce to you to clouddcomputing, with an                             units
                                                                                   RATION                                                                                                                                                                                etc. Some platforms rams writ large scale RDBMS deployments.




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      HTML 5 Canvas
                                ■
                                                                                                                                                                                                                                                                                                                                                                                      The src
                                                                                                                                                                                                                                                                                                                                                                                                                                          dy Ha
                                                                                                                                                                                      softw                                   riente
                                                                                                                  e                 ine                                     loping                                                                                                         and Java                            hical           of all
                                                                       INTEG                                                                                                                                                                                                                                 ten                                                                               attribute
                                                                                                                                                                                                                      task-o
                                                                                                         softwar                             emphasis oncodelines providers, so by Commit better understand
                                                                                                                              Mainl                                  Deve
                                                                                                                                                                        these                         chang Level can
                                                                                                                                                                                                              es you
                                                                                                                                                                                                                                                                                                       also recein JavaScri user interfac web develop                                and the                                                   rris
  Vis it




                                                               OUS                                ding                                                                                      e code                                                                                        as the                                                                                                         desc
                                                                                                                                           w ww.dzone.com




                                                                                                                                                                                                                                                                                                                   ive data pt. Server-s                                            the ima alt attribute ribes whe
                                                                                                                                                                                                          Task
                                                      NTINU                             s of buil      control                               what it is a cloud computingaplatform can offer your web
                                                                                                                                      line Policy                              nize sourc es as                                                        ut                                          output                                           e in clien         ment.
                                               T CO                           proces ’s version
                                                                                                                                Code
                                                                                                                                             applications. and subm
                                                                                                                                                                       Orga           it chang               e name                     sourc
                                                                                                                                                                                                                                               e witho                                   likew
                                                                                                                                                                                                                                                                              CLOUD COMPUTING PLATFORMS AND ide languag t-side
                                                                                                                                                                                                                                                                                                ise         mechan             from                                                          ge is           describe re the ima
                                      ABOU                           is the          ject                                                              it                                       with uniqu                   are from
                                                                                                                                                                                                                                                                                         was onc use HTML              ism. The web pag                                            Nested
                                                                                                                                                                                                                                                                                                                                                                                                   unavaila            s alte          ge file
    rd z!




                                                                (CI)          a pro                                                      evel Comm                                 the build                         softw                                                                                                                                     es like                                      ble.              rnate
                                                       gration
                                                                                                                                                                                                             build                                         um
                                                                                                                                                                                                                                                                              UNDERLYING CONCEPTS                 and XHT          emergin es and use                                                                                          can be
                                                                     ed to                                      blem              Task-L                                  Label
                                                                                                                                                                                              activit
                                                                                                                                                                                                      ies to
                                                                                                                                                                                                                                        the bare
                                                                                                                                                                                                                                                    minim                                          e
                                                                                                                                                                                                                                                                                        standard a very loos                                 g Ajax
                                                                                                                                                                                                                                                                                                                                                                       PHP
                                                                                                                                                                                                                                                                                                                                                                                  Tags        tags                                   text that           found,
                                             ous Inte      committ                                   to a pro                                         USAGE SCENARIOS                ate all
                                                                                                                                                                            Autom configurat
                                                                                                                                                                                                     ion                        cies to                  t
                                                                                                                                                                                                                                                                                                   ization,        ely-defi
                                                                                                                                                                                                                                                                                                                              ML as
                                                                                                                                                                                                                                                                                                                                      thei            tech
                                                                                                                                                                                                                                                                                                                                                               HTML                     can                                                     is disp
                                    Continu ry change                                                                                                                                                                                                                                                                                                                            cannot be (and freq
                                                                                                                                                                                                                         nden                      ymen                                                                                                                                                                                                 layed
                                                                                               tion                                                                                                                                                                                                                          ned lang r visual eng nologies
         Re fca




                                                                                                             ive                           Build                                     al                          depe                       deplo      t                               need
                                                                                      , a solu , ineffect                           Label                                    manu                        d tool                                                                                             but as                                                                                                                                            if




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Android
                                          eve                                                                         )                                                                           stalle                       the same          nmen                                         for                                                                                         overlap          uen
                                    with                                      s (i.e.       (i.e.               blem                         ated
                                                                                                                                                     Build
                                                                                                                                                                                      ce pre-in                        t, use target enviro                              Amazon EC2: ther stanstandard software and uage with
                                                                                                                                                                                                                                                                                       whe Industry dard              it has
                                                                                                                                                                                                                                                                                                                              become virtualization HTM
                                                                                                                                                                                                                                                                                                                                                          ine.                  b></               , so <a>< tly are) nest
                                                                   pattern                            lar pro
                                                                                                                                                                                                               ymen
                                                                                    tterns                                                                                                                                                                                                                   s has                                                                    a> is
                                              ory.                                                                                    Autom                                    Redu                  d deploEAR) in each
                                     reposit                ed via                            particu tions that e                                                                        Pay only what you consume                                                                   the curr you cho platform isome bec heavily based on very little L                                    fine.             b></            ed insid
                                                                         anti-pa                                                                                                                                                                                         Amazon’s cloud computing ose                                    more
                                                                                                                                                               cies                          tagge          or
                                                       lain                                                                                               nden                        each          WAR                                                    t                                                                                    imp                                                               a></
                                               be exp              and               x” the are solu                                                                             For
                                                                                                                                                                                         ge (e.g.
                                                                                                                                             Web application deployment untillibrari yearsenvironmen similar
                                                                                                                                               al Depe                                                                      es                                                                 ent stan         to writ          mor
                                                                                                                                                                                                                                                                         industry standard software and virtualization technology. ortant, the
                                                                                                                                                                                                                                                                                                                                                                                                                       b> is           e
                                                                                                                                                                                                                                                                                                                                                                                                                             not lega each othe
                                                             text)           to “fi           ns             to pro
                                                                                                                    duc                 Minim                                     packa                     nden a few target ago was
                                                                                                                                                                                                                  t
                                                                                                                                                                                                                                                                                     that will           dards           e HTM e apparen
           Mo re




                                      CI can ticular con             used                                                                                                                        all depe                                                                                                                                                                          HTM                                                                r. Tags
                                                                                   i-patter they tend es, but can                                                                                                                                                                                                                                                                                                                      l, but
                                                                                                                                                        rity                                                                     all
                                                                                                                                                                                                                                                                                                                                   L or XHT       t. Reg
                                          a par             etimes        s. Ant             ,                                           Binar most phone services: plans with alloted resources, with an
                                                                                                                                             toInteg
                                                                                                                                               y                                   Centr
                                                                                                                                                                                          alize                 late fi
                                                                                                                                                                                                                        le that
                                                                                                                                                                                                                                                         ts                         and XHT simplify all         will help
                                                                                                                                                                                                                                                                                                                                             ML, und ardless
                                                                                                                                                                                                                                                                                                                                                                                          L VS
                                                                                                                                                                                                                                                                                                                                                                                                 XHTM                                         <a><
                                                                                                           ctic                                                                                          temp                                                                                                                 you prov                                                                                                               b></
                                                   hes som       proces in the end bad pra                          enting                                                                                                                                                                                   you
                                       in                                                                                                                                  nt                                                                     nmen
                                                                                                                                                                  geme                      e a single based on
                                                                                                                                             incurred cost whether such resources were consumedto thenot.                                t enviro            or                                ML physical r othe
                                                                                                                                                                                                                                                                         Virtualization allows aare actu piece of hardware idebe
                                                                                                                                                                                                                                                                                   much                                                  to             erstand of           HTML                        L
                                                                                                                                                         cy Mana
                                        approac ed with the cial, but,                                    implem                                                                                                               nt targe
                                                                                                                                                                                                                                                                                                             ally simp r web cod
                                                                                                                                                                                     Creat
                                                                                           rily                                                   nden                                        rties are                                                 es                                of the                                             a solid             ing                 has
                                                                                                                                                                                                                into differe
                                                                                necessa pared to
                                                                                                                                                                                                                                                 chang
                                                               efi                                                                          Depe                                       prope                                               itting                         utilized by multiple operating systems. This allows resources
                                                                                                                                                                                                                                                                                                   function                            ing.            foundati             job adm been arou
                                         associat to be ben
                                                                                                                                                               er
                                                                                                                                                                                                                                                                                                             ality has ler than they Fortuna
                    Ge t




                                                                                                                                                                                                    te builds                                                                     commo
                                                                     are not                                                                        late Verifi                                                                  e comm                                                                                                                           on
                                                                                      n  com                                                                                                 remo
                                                                                                                                             Cloud computing asRun known etoday has changed this. etc.
                                                                                                                                                                                         it’s                           befor                                                                                                                                                         irably,         nd for
                                                              They         lts whe
                                                                                                                                            Temp                                                                Build                                    ually,          (e.g. bandwidth,n elem CPU) to be mov
                                                                                                                                                                                                                                                                                             memory,                      allocated exclusively to      tely               expecte            that job       som
                                          appear effects.                                                                                    The various resources consumed by webperiodically, rm a
                                                                                                                                                                                                       Privat                                     contin
                                                                                                                                                                                                                                     applications (e.g.nt team                    Every                ent instances. ed to CSS
                                                                                                                                                                                                                                                                                                                                          used
                                                                                                                                                                                                                                                                                                                                                 to be, HTML                         d. Earl            has exp e time. Whi
                                                                 ed resu                                                    tion                                                         Perfo                                                               opme                       pag
                                                                                                                                                                                                                                                                         individual operating system s                                                    because         Brow
                                                                                                                                                                                                                                                                                                                                                                                ser man y HTML
                                           adverse unintend                                                        Integra
                                                                                                                                                       d Builds                                  sitory
                                                                                                                                             bandwidth, memory, CPU) areIntegration on from CI server basis
                                                                                                                                                                                                                           Build                    to devel                     common e (HTML                                            .                                                                    anded           le it
                                                                                                                                                                                                                                                                                                                                                                                                                         far mor has done
                                                                                                                                               Stage                                      Repo
                                                    e                                                         ous                                                                                            tallied               a per-unit                                                            or XHT                                                           web dev         ufac         had very
                                            produc                                                 Continu Refcard
                                                                                                                                                        e Build                                    rm an                                                                        extensio .) All are                                                                                 elopers turers add
                                                                                                                                                                                                                                                                e.com




                                                                                                                                                                                                                                                                                                                  ML shar                                                                                        limit            e than          its
                                                     tern.
                                                                                                                                                                                                                             ack
                                                                                            term                                             (starting from zero) by Perfomajor cloud computing platforms.
                                                                                                                                                Privat
                                                                                                                                                                                            all                     feedb                                           on
                                                                                                                                                                                                                                                                                          n. HTM essentia
                                                                                                                                                                                                                                                                         As a user of Amazon’s EC2 cloud computing platform, you are
                                                                                                                                                                                                                                                                                                                             es cert                                     result                            ed man ed layout               anybody
                                                                                                         e, this
                                                                                                                                                                                                             ated
                                             the pat
                                                                                                                                                                                                                                        occur                                                                                                                                                 came
                                                                  gration                                               as                                                                                                                                    based                                                                                                             is
                                                                                   of the         ” cycl         such                                            Build                       Send
                                                                                                                                                                                                     autom                    as they                 builds                   proc
                                                                                                                                                                                                                                                                         assigned essor             L files       lly plai
                                                                                                                                                                                                                                                                                    an operating system in the same wayain on all hosting
                                                                                                                                                                                                                                                                                                                                      as elements                       The late a lack of stan up with clev y competi
                                                                                                                                                                                                                                                                                                                                                                                                                                   supp
                                                        ous Inte tional use and test concepts
                                                                                                                                                                                                                       soon                                                                                                n text                                                                                                        ort.
                                                                                                                                                          ration                                               ors as                        ion with                                                      should
                                                                                                                                                   Integ                                                                              entat
                                                                                                                                                                                                                                                                                                                                                      in                          st web           dar            er wor        ng stan
                                              Continu conven                “build include                                                                                                                           oper
                                                                                                                                                                                                                             docum                                                                                    not be
                                                                                                                                                                                                                                                                                                                                cr                                                         standar                        kar            dar
                                               While
                                                      the        s to the of CI to
                                                                    efer                                                                                                                         Gene
                                                                                                                                                                                                        rate devel
                                                                              ion
                                                                                                                                            Cloud Computing




                                                                      the not
                                                                 s on
                                                     expand



                                                                                                                                                                                                                                                                                                                                                                                                                                                                   DZone, Inc.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   140 Preston Executive Dr.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Suite 100
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Cary, NC 27513
                                                                                               DZone communities deliver over 6 million pages each month to                                                                                                                                                                                                                                                                                                        888.678.0399
                                                                                               more than 3.3 million software developers, architects and decision                                                                                                                                                                                                                                                                                                  919.678.0300
                                                                                               makers. DZone offers something for everyone, including news,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Refcardz Feedback Welcome
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  $7.95




                                                                                               tutorials, cheat sheets, blogs, feature articles, source code and more.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   refcardz@dzone.com
                                                                                               “DZone is a developer’s dream,” says PC Magazine.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Sponsorship Opportunities
                                                                                               Copyright © 2011 DZone, Inc. All rights reserved. No part of this publication may be reproduced, stored in a
                                                                                               retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise,                                                                                                                                                                                                                                                       sales@dzone.com                                                                  Version 1.0
                                                                                               without prior written permission of the publisher.

More Related Content

What's hot (18)

PPT
JBoss presentation 2003 11 for matrix
runsignup
 
PDF
JavaEE 6 and GlassFish v3 at SFJUG
Marakana Inc.
 
PDF
Java EE 6 and GlassFish v3: Paving the path for future
Arun Gupta
 
PDF
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
Arun Gupta
 
PDF
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Anton Arhipov
 
PPTX
Windows Server 2012 Active Directory Domain and Trust (Forest Trust)
Serhad MAKBULOĞLU, MBA
 
PDF
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta
 
PDF
Sun Java EE 6 Overview
sbobde
 
PPT
it's learning MLG integration
jab
 
PDF
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Arun Gupta
 
PDF
Java EE 6 Component Model Explained
Shreedhar Ganapathy
 
PDF
Flex For Java Architects Ledroff Breizh Jug V Blog Cc
François Le Droff
 
PDF
Workload Groups overview updates
COMMON Europe
 
PDF
Sail Fin Webinar Overview
Eduardo Pelegri-Llopart
 
PDF
Eclipse Development Tools | JBuilder from Embarcadero Technologies
Michael Findling
 
PDF
Java one brazil_keynote_dochez
Jerome Dochez
 
PDF
Whats new in was liberty security and cloud readiness
sflynn073
 
PPTX
LUGOD Raspberry Pi Hacking
Stephen Chin
 
JBoss presentation 2003 11 for matrix
runsignup
 
JavaEE 6 and GlassFish v3 at SFJUG
Marakana Inc.
 
Java EE 6 and GlassFish v3: Paving the path for future
Arun Gupta
 
Java EE 6 Hands-on Workshop at Dallas Tech Fest 2010
Arun Gupta
 
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Anton Arhipov
 
Windows Server 2012 Active Directory Domain and Trust (Forest Trust)
Serhad MAKBULOĞLU, MBA
 
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta
 
Sun Java EE 6 Overview
sbobde
 
it's learning MLG integration
jab
 
Java EE 6 & GlassFish v3: Paving the path for the future - Spark IT 2010
Arun Gupta
 
Java EE 6 Component Model Explained
Shreedhar Ganapathy
 
Flex For Java Architects Ledroff Breizh Jug V Blog Cc
François Le Droff
 
Workload Groups overview updates
COMMON Europe
 
Sail Fin Webinar Overview
Eduardo Pelegri-Llopart
 
Eclipse Development Tools | JBuilder from Embarcadero Technologies
Michael Findling
 
Java one brazil_keynote_dochez
Jerome Dochez
 
Whats new in was liberty security and cloud readiness
sflynn073
 
LUGOD Raspberry Pi Hacking
Stephen Chin
 

Viewers also liked (6)

PDF
Mongo db实战
Roger Xia
 
PDF
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
Roger Xia
 
PDF
Consistency-New-Generation-Databases
Roger Xia
 
PPT
Ajax Lucence
Roger Xia
 
PDF
构建高效能的Web网站 精选版-by-infoq
Roger Xia
 
PPTX
机器学习推动金融数据智能
Roger Xia
 
Mongo db实战
Roger Xia
 
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
Roger Xia
 
Consistency-New-Generation-Databases
Roger Xia
 
Ajax Lucence
Roger Xia
 
构建高效能的Web网站 精选版-by-infoq
Roger Xia
 
机器学习推动金融数据智能
Roger Xia
 
Ad

Similar to JavaEE6 (20)

PDF
Whats Cool in Java E 6
Arun Gupta
 
PDF
Java EE 6 & GlassFish 3
Arun Gupta
 
PDF
JUG Darmstadt - Java EE 7 - Auf in die Wolken!
Markus Eisele
 
PDF
Enterprise java unit-1_chapter-1
sandeep54552
 
PDF
Understanding the nuts & bolts of Java EE 6
Arun Gupta
 
PDF
Java E
Arun Gupta
 
DOCX
Jboss
Sridhar Rapala
 
PDF
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Arun Gupta
 
PDF
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
Arun Gupta
 
PDF
Developer Productivity with Forge, Java EE 6 and Arquillian
Ray Ploski
 
PPT
Introduction to java_ee
Yogesh Bindwal
 
PDF
Summer training java
Arshit Rai
 
PPT
Ejb (1)
Salman Virani
 
PDF
Java EE 7 - Into the Cloud
Markus Eisele
 
PDF
New Features of Java7 SE
dogangoko
 
PDF
Andrei Niculae - JavaEE6 - 24mai2011
Agora Group
 
PPT
JBoss Analyst tour Sept 2003
runsignup
 
PDF
Jfokus 2012 : The Java EE 7 Platform: Developing for the Cloud
Arun Gupta
 
PDF
Java EE / GlassFish Strategy & Roadmap @ JavaOne 2011
Arun Gupta
 
PDF
Java EE Technical Keynote - JavaOne India 2011
Arun Gupta
 
Whats Cool in Java E 6
Arun Gupta
 
Java EE 6 & GlassFish 3
Arun Gupta
 
JUG Darmstadt - Java EE 7 - Auf in die Wolken!
Markus Eisele
 
Enterprise java unit-1_chapter-1
sandeep54552
 
Understanding the nuts & bolts of Java EE 6
Arun Gupta
 
Java E
Arun Gupta
 
Java EE 6 & GlassFish v3: Paving the path for the future - Tech Days 2010 India
Arun Gupta
 
TDC 2011: The Java EE 7 Platform: Developing for the Cloud
Arun Gupta
 
Developer Productivity with Forge, Java EE 6 and Arquillian
Ray Ploski
 
Introduction to java_ee
Yogesh Bindwal
 
Summer training java
Arshit Rai
 
Ejb (1)
Salman Virani
 
Java EE 7 - Into the Cloud
Markus Eisele
 
New Features of Java7 SE
dogangoko
 
Andrei Niculae - JavaEE6 - 24mai2011
Agora Group
 
JBoss Analyst tour Sept 2003
runsignup
 
Jfokus 2012 : The Java EE 7 Platform: Developing for the Cloud
Arun Gupta
 
Java EE / GlassFish Strategy & Roadmap @ JavaOne 2011
Arun Gupta
 
Java EE Technical Keynote - JavaOne India 2011
Arun Gupta
 
Ad

More from Roger Xia (20)

PPTX
Code reviews
Roger Xia
 
PPTX
Python introduction
Roger Xia
 
PPT
Learning notes ruby
Roger Xia
 
PDF
Converged open platform for enterprise
Roger Xia
 
PPTX
Code reviews
Roger Xia
 
PDF
E commerce search strategies
Roger Xia
 
PDF
Saml
Roger Xia
 
PDF
Indefero source code_managment
Roger Xia
 
PDF
Web Services Atomic Transactio
Roger Xia
 
DOCX
Web service through cxf
Roger Xia
 
PDF
Spring one2gx2010 spring-nonrelational_data
Roger Xia
 
PDF
Java explore
Roger Xia
 
PDF
Ca siteminder
Roger Xia
 
PDF
Fixing twitter
Roger Xia
 
DOCX
Eclipse plug in mylyn & tasktop
Roger Xia
 
DOCX
新浪微博架构猜想
Roger Xia
 
PDF
Jenkins
Roger Xia
 
DOCX
MDD and modeling tools research
Roger Xia
 
PDF
Secure Multi Tenancy In the Cloud
Roger Xia
 
PPT
Java programing considering performance
Roger Xia
 
Code reviews
Roger Xia
 
Python introduction
Roger Xia
 
Learning notes ruby
Roger Xia
 
Converged open platform for enterprise
Roger Xia
 
Code reviews
Roger Xia
 
E commerce search strategies
Roger Xia
 
Saml
Roger Xia
 
Indefero source code_managment
Roger Xia
 
Web Services Atomic Transactio
Roger Xia
 
Web service through cxf
Roger Xia
 
Spring one2gx2010 spring-nonrelational_data
Roger Xia
 
Java explore
Roger Xia
 
Ca siteminder
Roger Xia
 
Fixing twitter
Roger Xia
 
Eclipse plug in mylyn & tasktop
Roger Xia
 
新浪微博架构猜想
Roger Xia
 
Jenkins
Roger Xia
 
MDD and modeling tools research
Roger Xia
 
Secure Multi Tenancy In the Cloud
Roger Xia
 
Java programing considering performance
Roger Xia
 

Recently uploaded (20)

PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 

JavaEE6

  • 1. JBoss Application Server Overview Community Project JBoss Application Server* is the world's lead- ing Open Source Java EE application server for developing and deploying enterprise applica- tions. The latest in this line, JBoss AS 7 (Java EE Web Profile certified), provides the same devel- oper friendly environment as previous versions JBoss Application Server 7 while offering revolutionary new management capabilities, and much more. Blazing fast startup (~3seconds) Services are started concurrently to eliminate unnecessary waits and leverage multi-core processors, while non-critical services remain passivated until rst use. JBoss AS 7 o ers a 10-fold reduction in startup time over previous versions. Lightweight An aggressive approach to memory management and metadata indexing keeps the footprint exceptionally small, enabling it to run with stock JVM settings and on small devices. Pro les can be used to tune the capabilities of the server. Modular core JBoss Modules o ers true application isolation, hiding server implementation classes and only loads the classes your application needs. Class loading is concurrent for extreme performance. OSGi support is available the moment you install the application server. Hot, incremental deployment Quick turnaround during development as a result of fast, concurrent deployment and the ability to edit static resources without redeployment in a exible deployment structure. Elegant administration Consistent and powerful management is available, ranging from a polished, user-friendly web console to Java and HTTP APIs to a command line tool to direct XML edits. Con guration data is centralized and user-focused. Domain (multi-server) management One controller can rule them all or you can simply start a standalone server. Port o sets can be changed with a single switch. Rolling deployments are available First class components JBoss AS builds on many best of breed standalone OSS projects: Hibernate, JBoss Transactions, In nispan, Iron Jacamar, RESTEasy, Weld, HornetQ, JGroups, JBoss Logging, Mojarra, Apache CXF, and more. Java EE 6 programming model Java EE 6 o ers a modern, loosely coupled programming model, founded on CDI, a speci cation driven by JBoss. With Java EE 6 you can focus on implementing your business logic, and allow the platform to take care of the rest. Testable by design Arquillian o ers absolute delity for testing: the ability to test your application inside the actual environment. Just like CDI, Arquillian takes care of all the boilerplate in the background, removing clutter from your tests. Scan this and find out more about the JBoss Application Server project. http://www.jboss.org/jbossas * JBoss Application Server is in the upstream for JBoss Enterprise Application Platform.
  • 2. brought to you by... #150 Get More Refcardz! Visit refcardz.com CONTENTS INCLUDE: n n n About the Platform Common Annotations For Java Java Platform, Enterprise Edition Java Enterprise Edition 6 Java Servelet 3.0 The Most Elegant Enterprise Java Yet n n JavaServer Faces 2.0 n Enterprise JavaBeans 3.1 By Andrew Lee Rubinger Reference ABOUT THE PLATFORM The full JavaDoc for the Java EE 6 API is located at: http://download.oracle.com/javaee/6/api/ Enterprise software development is inherently complex, and multi-user systems open the door to concerns such as transactional integrity, security, COMMON ANNOTATIONS FOR THE JAVA PLATFORM persistence integration, and interaction between components. Very simply put, the mission of the Java Enterprise Edition is to enable an out-of-the-box set of configurable services that allows the programmer to write less and focus JSR-250 on delivering clean business logic. he common annotations for Java EE are a shared package used throughout To this end, Java EE 6 is an aggregate of many interoperable technologies the platform specifications that generally focus on shared services like designed to deliver a unified experience. Application Servers that are lifecycle, injection, and security. certified to the standards defined by the Java Community Process are intended to service applications written to the specifications within the platform. Class Name Description For the sake of brevity, this reference card will focus on the key APIs of Java EE Generated Marks generated code 6 that are most relevant to modern development. ManagedBean Defines a class as a Java EE 6 Managed Bean JAVA PLATFORM, ENTERPRISE EDITION 6 (JAVA EE 6) PostConstruct Lifecycle callback after an instance has been created but before it is put into service PreDestroy Lifecycle callback before an instance is to be removed from JSR-316 service This umbrella specification ties together the various subsystems that comprise Resource Defines an injection point, marks that this is to be provided by the platform and provides additional integration support. the container Profiles Resources Allows for injection of N resources New to Java EE 6 is the notion of the “Web Profile”, a subset of the full specification that is targeted to cater to more specialized and minimal web- DeclareRoles Class-level target defining valid security roles based application requirements. It is guaranteed to support the platform common annotations for injection and lifecycle (JSR-250), JNDI Naming DenyAll Marks that no roles are allowed to access this method standards, and the Java Transaction API. Additionally, the Web Profile focuses on Servlet and closely related technologies such as persistence, view PermitAll Marks that all roles are allowed to access this method (or all presentation (JavaServer Faces and JavaServer Pages), and the business logic methods if applied to a class) elements of EJB Lite. RolesAllowed Specifies list of roles permitted to access this method (or all Code Example methods if applied to a class) The simple class below is all it takes in Java EE 6 to define a POJO-based managed component capable of lifecycle callbacks, interceptors, and resource injection. /** Java Enterprise Edition 6 * Interceptor logging that an invocation has been received */ public class LoggingInterceptor { @AroundInvoke public Object intercept(InvocationContext context) throws Exception { System.out.println(“Been intercepted: “ + context); return context.proceed(); } } /** * Defines a simple managed bean able to receive an injection */ @ManagedBean @Interceptors({LoggingInterceptor.class}) // Invocations will be // intercepted public class ComponentResourceInjection { @Resource private UserTransaction userTransaction; // ... business methods will be intercepted // by LoggingInterceptor DZone, Inc. | www.dzone.com
  • 3. 2 Java Enterprise Edition 6 RunAs Defines the identity context when run in the container RolesAllowed Specifies list of roles permitted to access this method (or all methods if applied to a class) RunAs Defines the identity context when run in the container JAVA SERVLET 3.0 JAVA API FOR RESTFUL WEB SERVICES (JAX-RS) JSR-315 Servlet technology models the request/response programming model and JSR-311 is commonly used to extend HTTP servers to tie into server-side business logic. In Servlet 3.0, the specification has been expanded to include New to Java EE, the JAX-RS specification allows for standard development support for annotations, asynchronous processing, pluggability, and adhering to the Representational State Transfer (REST) paradigm. These general ease-of-configuration. applications are packaged as a Servlet inside a web application archive. Code Example /** Because Servlet 3.0 includes annotations to define servlets, the descriptor * JAXB Model of a Name */ web.xml is no longer required in most of the common cases; below is an @XmlRootElement example of all that’s needed to create a simple servlet. public class Name { /** private String name; * Simple Servlet which welcomes the user by name specified * by the request parameter “name”. public Name(String name) { */ this.name = name; @WebServlet(urlPatterns = } {“/welcome”}) // Will service requests to the path “/welcome” public Name() {} public class WelcomeServlet extends HttpServlet { public String getName() {return this.name;} /** * Inject a reference to an EJB public void setName(String name) { */ this.name = name; @EJB } private WelcomeBean bean; } /** /** * Service HTTP GET Requests * Services requests for the path “/name” */ * returning the JAXB-formed Name XML @Override */ protected void doGet(final HttpServletRequest request, final HttpServletResponse @Path(“/name”) response) throws ServletException, @Produces({“application/xml”}) IOException public class NamedResource extends javax.ws.rs.core.Application { { @GET // Get the name from the request public Name get(@QueryParam(“name”) String name) { final String name = request.getParameter(“name”); return new Name(name); } // Precondition checks } if (name == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, “Request ...and HTTP GET requests to “{baseUrl}/myapp/name?name=andrew” will parameter ”name” is required”); return the XML form for the Name. } // Set content type Public API Annotation Selection from javax.ws.rs: response.setContentType(“text/plain”); // Get the welcome message Class Name Description final String welcomeMessage = bean.welcome(name); Consumes Defines the media types that may be accepted // Write out response.getWriter().write(welcomeMessage); } CookieParam Injects the value of an HTTP cookie to a method param or bean/class field } DefaultValue Defines default values for cookies and other parameters Public API from javax.servlet.annotation: Class Name Description DELETE Flags that a method is to service HTTP DELETE requests HttpConstraint Defines security constraints for all HTTP-servicing meth- ods in a secured servlet Encoded Disables automatic decoding of parameter values HttpMethodCon- Defines security constraints for an HTTP-servicing FormParam Injects the value of a form parameter to a resource method straint method in a servlet parameter MultipartConfig Indicates the servlet is to service requests for multipart/ GET Flags that a method is to service HTTP GET requests form-data MIME type HEAD Flags that a method is to service HTTP HEAD requests ServletSecurity Secures a servlet class for HTTP-servicing methods WebFilter Defines a class as a servlet filter HeaderParam Injects the value of a header parameter HttpMethod Draws an association between an HTTP method with an an- WebInitParam Specificies an initialization parameter on a servlet or filter notation WebListener Defines a class as a web listener MatrixParam Injects the value of a URI matrix parameter WebServlet Defines a class as a servlet Path Designates the URI path that a resource class or resource method will serve PermitAll Marks that all roles are allowed to access this method (or all PathParam Injects the value of a URI path parameter method if applied to a class) DZone, Inc. | www.dzone.com
  • 4. 3 Java Enterprise Edition 6 POST Flags that a method is to service HTTP POST requests javax.enterprise.inject.Model Built-in stereotype for beans defining the model layer of an MVC webapp (ie. JSF) Produces Signals the media type(s) to be served by this resource javax.enterprise.inject.New Built-in qualifier type PUT Flags that a method is to service HTTP PUT requests javax.enterprise.inject.Produces Identifies a Producer method or field QueryParam Injects the value of a query parameter javax.enterprise.inject.Specializes Indicates that a bean specializes another bean javax.enterprise.inject.Stereotype Specifies that an annotation is a CONTEXTS AND DEPENDENCY INJECTION FOR JAVA stereotype javax.enterprise.inject.Typed Restricts the types of a bean JSR-299 Relevent Public Annotation API from JSR-330, The Java Contexts and Dependency Injection (CDI) specification Dependency Injection for Java in package javax.inject: introduces a standard set of application component management services Class Name Description to the Java EE platform. CDI manages the lifecycle and interactions of stateful components bound to well defined contexts. CDI provides Inject Identifies injectable constructors, methods, and fields typesafe dependency injection between components. CDI also provides Named String-based qualifier interceptors and decorators to extend the behavior of components, an event model for loosely coupled components and an SPI allowing portable extensions to integrate cleanly with the Java EE environment. Qualifier Identifies qualifier annotations Additionally, CDI provides for easy integration with view layers such as Scope Identifies scope annotations JavaServer Faces 2.0 (JSR-314). Singleton Identifies a type that the injector only instantiates once Code Example For a deeper dive into CDI, check out DZone’s CDI Refcard: http:// Below is a simple example of a CDI Bean that is placed in scope alongside refcardz.dzone.com/refcardz/contexts-and-depencency the HTTP session, given a String-based name binding (such that it may be used in JSF view components, for example) and injects the FacesContext such that it may be used in business methods. BEAN VALIDATION 1.0 @SessionScoped // Bind to the web session JSR-303 @Named // To be used in view components by name public class GreeterBean implements Serializable { New to Java EE 6, the Bean Validation Specification provides for unified @Inject // Used to integrate w/ JSF private FacesContext context; declaration of validation constraints upon bean data. It may be used to maintain the integrity of an object at all levels of an application: from user public GreeterBean() {} form input in the presentation tier all the way to the persistence layer. // ... business methods } Code Example Here is an example of how to apply Bean Validation constraints in a Class Name Description declarative fashion to ensure the integrity of a User object. javax.decorator.Decorator Declares the class as a Decorator public class User { @NotNull @Size(min=1, max=15) javax.decorator.Delegate Specifies the injection point of a private String firstname; Decorator @NotNull @Size(min=1, max=30) private String lastname; javax.enterprise.context.ApplicationScoped Specifies the bean has applica- tion scope @Pattern(regexp=”b[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}b”) public String email; } javax.enterprise.context.ConversationScoped Specifies the bean has conversation scope Public Annotation API for javax.validation javax.enterprise.context.Dependent Specifies the bean belongs to dependent pseudo-scope Class Name Description Constraint Link between a constraint annotation and its constraint javax.enterprise.context.NormalScope Specifies the bean is normally- validation implementations scoped GroupSequence Defines a group sequence javax.enterprise.context.RequestScoped Specifies the bean is request-scoped javax.enterprise.context.SessionScoped Specifies the bean is session-scoped OverridesAttribute Mark an attribute as overriding the attribute of a com- javax.enterprise.event.Observes Identifies an event parameter of an posing constraint observer method OverridesAttribute.List Defines several @OverridesAttribute annotations on the same javax.enterprise.inject.Alternative Specifies that the bean is an element Alternative ReportAsSingleViola- A constraint annotation hosting this annotation will return the tion composed annotation error report if any of the composing javax.enterprise.inject.Any Built-in qualifier type annotations fail. javax.enterprise.inject.Default Default qualifier type Valid Mark an association as cascaded javax.enterprise.inject.Disposes Identifies the disposed parameter of a disposer method DZone, Inc. | www.dzone.com
  • 5. 4 Java Enterprise Edition 6 ManagedProperty Injection point for fields in ManagedBean classes JAVASERVER FACES 2.0 NoneScoped Denotes a ManagedBean is to be in the “none” scope JSR-314 ReferencedBean Denotes the class as a referenced bean JavaServer Faces is a user interface (UI) framework for the development RequestScoped Denotes a ManagedBean is to be in request scope of Java web applications. Its primary function is to provide a component- SessionScoped Denotes a ManagedBean is to be in session scope based toolset for easily displaying dynamic data to the user. It also integrates a rich set of tools to help manage state and promote code ViewScoped Denotes a ManagedBean is to be in view scope reuse. Public API from javax.faces.application: Additionally, JSF is an extensible specification that encourages the authoring of custom user views. It’s designed with tooling in mind such Class Name Description that integrated development environments (IDEs) can intelligently assist Application Singleton scoped per web application to provide with design. configuration for things like validators, components and converters Code Example ApplicationFactory Creates (if required) and returns Application instances Here we’ll show a simple example of a JSF managed bean whose state is scope to the HTTP request, and is registered to a bean name that may be ApplicationWrapper Application type which may be used by developers to accessed by the view layer. add to an existing ResourceHandler ConfigurableNavigation- Extends NavidationHandler to provide runtime inspection Handler of the NavigationCase which defines the rule base for /** navigation * This class defines a bean to live bound to the HTTP * request scope, and may be accessed by the view layer FacesMessage A single validation message * under the name “hitchhikersGuide”. */ NavigationCase A single navigation case in the navigation rule base import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.faces.application.ProjectStage; NavigationHandler Handles navigation from a given action and outcome import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; Resource Models a client resource request @RequestScoped ResourceHandler API by which UIComponent and Renderer instances can @ManagedBean(name = “hitchhikersGuide”) reference Resource instances public class HitchhikersGuide { private String ultimateAnswer; ResourceWrapper Simple base implementation of Resource to be extended @ManagedProperty(value = “#{facesContext.application.projectStage}”) by developers looking to add custom behaviors private ProjectStage journeyStage; StateManager Coordinates the process of saving and restoring the view public String getUltimateAnswer() { between client requests return ultimateAnswer; } StateManagerWrapper Base implementation of a StateManager which may be subclasses by developers looking to add custom behaviors public void setUltimateAnswer(String ultimateAnswer) { this.ultimateAnswer = ultimateAnswer; ViewHandler Pluggable point for the render response and restore view } phases of the request lifecycle. public ProjectStage getJourneyStage() { ViewHandlerWrapper Base implementation of a ViewHandler which may be sub- return journeyStage; } classes by developers looking to add custom behaviors. public void setJourneyStage(ProjectStage journeyStage) { this.journeyStage = journeyStage; } ENTERPRISE JAVABEANS 3.1 @PostConstruct public void findUltimateAnswerToUltimateQuestion() { ultimateAnswer = “42”; } } JSR-318 index.xhtml View: Enterprise JavaBeans provide a component model to encapsulate <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” business logic. As such, they provide a few bean types: “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml” • Session Beans xmlns:h=”http://java.sun.com/jsf/html” xmlns:f=”http://java.sun.com/jsf/core”> <head> • Stateless <title>Sample JSF Page</title> </head> • No conversational state between requests <body> <f:view> <h2><h:outputText value=”Test Managed Bean Annotations”/></h2> • Stateful <p><h:outputText value=”hitchhikersGuide.ultimateAnswer = #{hitchhikersGuide.ultimateAnswer}”/></p> <h2><h:outputText value=”Test Project Stage”/></h2> • Same bean instance used to service each client/session <p><h:outputText value=”project stage = #{hitchhikersGuide. journeyStage}”/></p> • Singleton </f:view> </body> </html> • One shared bean instance for all users • Message-Driven Public API from javax.faces.bean: • Event Listener Class Name Description • JCA endpoint ApplicationScoped Denotes a ManagedBean is to be in application scope • Asynchronous CustomScoped Denotes a ManagedBean is to be in a custom-de- • Entity fined scope of the specified value ManagedBean Defines a class as a ManagedBean type • Integration point w/ Java Persistence DZone, Inc. | www.dzone.com
  • 6. 5 Java Enterprise Edition 6 Code Example TransactionManage- Configures transactional management for a Session or ment Message-Driven Bean (container or bean provided) It’s simple to define an EJB capable of greeting a user. /** * Stateless Session EJB JAVA PERSISTENCE 2.0 */ @Stateless // Defines a Stateless Session Bean @LocalBean // No-interface view public class GreeterBean { @Override JSR-317 public String greet(String name) { return “Hi, “ + name + “!”; } Most enterprise applications will need to deal with persistent data, } and interaction with relational databases can be a tedious and difficult endeavor. The Java Persistence specification aims to provide an object view of backend storage in a transactionally aware manner. By dealing Other components, such as Servlets, may now inject a proxy to the above with POJOs, JPA enables developers to perform database operations EJB: without the need for manually tuning SQL. @EJB private GreeterBean greeterEjb; Code Example Public API Annotation Selection from javax.ejb: A JPA entity is simply a POJO with some annotations to provide additional Class Name Description mapping metadata. For instance: AccessTimeout Designates the amount of time a concurrent method @Entity should block before timing out public class SimpleEmployee { @Id @Auto ActivationConfig- Used to configure Message-Driven Beans private Long id; private String name; Property public Long getId(){ return id; } AfterBegin Defines a Tx callback method for the “after begin” public void setId(final Long id) { this.id = id; } public String getName() { return name; } event public void setName(final String name) { this.name = name; } } AfterCompletion Defines a Tx callback method for the “after completion” event ApplicationException Defines a user exception which should not be wrapped Now a managed component such as an EJB or CDI bean can interact with the database through our entity by associating it with an EntityManager. Asynchronous Defines methods to be executed asynchronously. @PersistenceContext private EntityManager em; BeforeCompletion Defines a Tx callback method for the “before completion” event public void createUser(){ final SimpleEmployee andrew = new SimpleEmployee(); ConcurrencyManage- Configures the concurrency management mode for a single- andrew.setId(100L); ment ton session bean andrew.setName(“Andrew Lee Rubinger”); em.persist(andrew); // Store in the DB DependsOn Designates initialization order for Singleton Session Beans // Now any state changes done to this managed object will be // reflected in the database when the Tx completes } EJB Defines an injection point and dependency upon an EJB component EJBs Plural injection point and dependency for EJB components, to be applied at the class-level Public API Annotation Selection from javax.persistence: Local Defines a local business interface view Class Name Description LocalBean Defines a no-interface view Basic Describes mapping for a database column Lock Defines a concurrency lock for Singleton Session Beans using container-managed concurrency Column Specifies column mapping for a persistent property MessageDriven Defines a Message-Driven Bean DiscriminatorCol- Notes the discriminator column used for SINGLE_TABLE PostActivate Defines an event callback after a Stateful Session Bean has umn and JOINED inheritance strategies been activated PrePassivate Defines an event callback before a Stateful Session Bean is to DiscriminatorValue Specifies the value of the discriminator column for entities of this be passivated type Remote Defines a remote business interface view ElementCollection Defines a collection of instances Remove Defines a business method that should trigger the removal of a Stateful Session Bean instance (i.e., destroy the session) Embeddable Defines a class whose instances are stored as part of the owning entity Schedule Defines a new timer to be created with a specified schedule Schedules Plural of Schedule Embedded Specifies a persistent property whose value is an instance of an embeddable class Singleton Defines a Singleton Session Bean Startup Denotes that a Singleton Session Bean should eagerly load EmbeddedId Denotes composite primary key of an embeddable class Stateful Defines a Stateful Session Bean Entity Defines a POJO as a persistent entity StatefulTimeout Defines the amount of idle time before a Stateful Session is eligible for removal EntityListeners Specifies callback listeners Stateless Defines a Stateless Session Bean Enumerated Specifies that a persistent property should be persisted as an Timeout Defines a timer expiration method enumeration TransactionAttribute Configures the transactional context under which business methods should execute DZone, Inc. | www.dzone.com
  • 7. 6 Java Enterprise Edition 6 GeneratedValue Specifies generation strategies for primary keys PostLoad Define an event callback method PostPersist Define an event callback method Id Denotes a primary key field PostRemove Define an event callback method IdClass Denotes a composite primary key class PostUpdate Define an event callback method Inheritance Denotes the inheritance strategy for this given entity PrePersist Define an event callback method JoinColumn Specifies a column for joining an entity association or element collection. PreRemove Define an event callback method JoinColumns Plural of JoinColumn Define an event callback method PreUpdate JoinTable Maps associations Specifies the primary table for this entity Table Lob Denotes a binary large object persistent property Denotes persistence of Date and Calendar field types Temporal ManyToMany Defines an N:N relationship Denotes that a property is not persistent Transient ManyToOne Defines an N:1 relationship Specifies the persistent property used as the optimistic lock Version NamedQuery Defines a static query in JPAQL OneToMany Defines a 1:N relationship OneToOne Defines a 1:1 relationship OrderBy Specifies ordering of elements when a Collection is retrieved PersistenceContext Used for injecting EntityManager instances PersistenceUnit Used for injecting EntityManagerFactory instances ABOUT THE AUTHOR RECOMMENDED BOOK Andrew Lee Rubinger Learn how to code, package, deploy, and test functional Enterprise JavaBeans with the latest Open Source Software Engineer and Author edition of bestselling guide. Written by the developers of the JBoss EJB 3.1 implementation, Advocate for and speaker on testable enterprise Java this book brings you up to speed on each of the development, author of “Enterprise JavaBeans 3.1” component types and container services in this from O’Reilly Media. Member of the JBoss Application technology, while the workbook in the second Server development team and technical lead of the section provides several hands-on examples for ShrinkWrap project. Proudly employed by JBoss / Red Hat. putting the concepts into practice. Enterprise JavaBeans 3.1 is the most complete reference you’ll find on this specification. #82 Browse our collection of over 100 Free Cheat Sheets Get More Refcardz! Visit refcardz.com CONTENTS INCLUDE: ■ ■ About Cloud Computing Usage Scenarios Getting Started with Aldon Cloud 4Computing ■ Underlying Concepts Cost by... #6 ■ Upcoming Refcardz ® t to you Data Tier Technologies ■ brough Comply. Platform Management and more... borate. ■ Chan ge. Colla By Daniel Rubio on: dz. com grati s also minimizes the need to make design changes to support CON ABOUT CLOUD COMPUTING one time events. TEN TS INC s Inte -Patternvall ■ HTML LUD E: Basics HTML ref car ■ Automated growth & scalable technologies Java EE 6 Web applications have always been deployed on servers nuou d Anti Paul M. Du vs XHT ation ■ Valid ML connected to what is now deemed the ‘cloud’. Having the capability to support one time events, cloud Useful ContiPatterns an ■ computing platforms also facilitate the gradual growth curves Open Page Source ■ Vis it However, the demands and technology used on such servers Stru faced by web applications. cture Tools Core E: By has changed substantially in recent years, especially with Key ■ Structur Elem al Elem ents INC LUD gration the entrance of service providers like Amazon, Google and ents and Large scale growth scenarios involving specialized equipment NTS rdz ! ous Inte Change HTML CO NTE es more... MySQL 5.5 Continu at Every Microsoft. e chang (e.g. load balancers and clusters) are all but abstracted away by About ns to isolat relying on a cloud computing platform’s technology. Software i-patter ■ n space fca e Work Build riptio and Ant These companies have Privat deployed webmanage Desc a are in long trol repos itory applications HTM L BAS ■ Patterns Control lop softw n-con to ing and ICS re Re ■ that adapt and scale to large user bases, making them Deve les to a versio In addition, several cloud computing platforms support data ment ize merg rn Version e... Patte it all fi to minim many aspects related tomultiple computing. HTM r Manage s and mor e Work knowledgeable in a mainline s cloud tier technologies that L and the precedent set by Relational exceed ■ space Comm ref ca Build Privat lop on that utilize HTML XHT tice is used ML are the Database Systems (RDBMS): Map Reduce, web service APIs, ■ Prac Deve code lines a system Build sitory of work prog support as the grap foundation By An Ge t Mo Repo active are within This Refcard will introduce to you to clouddcomputing, with an units RATION etc. Some platforms rams writ large scale RDBMS deployments. HTML 5 Canvas ■ The src dy Ha softw riente e ine loping and Java hical of all INTEG ten attribute task-o softwar emphasis oncodelines providers, so by Commit better understand Mainl Deve these chang Level can es you also recein JavaScri user interfac web develop and the rris Vis it OUS ding e code as the desc w ww.dzone.com ive data pt. Server-s the ima alt attribute ribes whe Task NTINU s of buil control what it is a cloud computingaplatform can offer your web line Policy nize sourc es as ut output e in clien ment. T CO proces ’s version Code applications. and subm Orga it chang e name sourc e witho likew CLOUD COMPUTING PLATFORMS AND ide languag t-side ise mechan from ge is describe re the ima ABOU is the ject it with uniqu are from was onc use HTML ism. The web pag Nested unavaila s alte ge file rd z! (CI) a pro evel Comm the build softw es like ble. rnate gration build um UNDERLYING CONCEPTS and XHT emergin es and use can be ed to blem Task-L Label activit ies to the bare minim e standard a very loos g Ajax PHP Tags tags text that found, ous Inte committ to a pro USAGE SCENARIOS ate all Autom configurat ion cies to t ization, ely-defi ML as thei tech HTML can is disp Continu ry change cannot be (and freq nden ymen layed tion ned lang r visual eng nologies Re fca ive Build al depe deplo t need , a solu , ineffect Label manu d tool but as if Android eve ) stalle the same nmen for overlap uen with s (i.e. (i.e. blem ated Build ce pre-in t, use target enviro Amazon EC2: ther stanstandard software and uage with whe Industry dard it has become virtualization HTM ine. b></ , so <a>< tly are) nest pattern lar pro ymen tterns s has a> is ory. Autom Redu d deploEAR) in each reposit ed via particu tions that e Pay only what you consume the curr you cho platform isome bec heavily based on very little L fine. b></ ed insid anti-pa Amazon’s cloud computing ose more cies tagge or lain nden each WAR t imp a></ be exp and x” the are solu For ge (e.g. Web application deployment untillibrari yearsenvironmen similar al Depe es ent stan to writ mor industry standard software and virtualization technology. ortant, the b> is e not lega each othe text) to “fi ns to pro duc Minim packa nden a few target ago was t that will dards e HTM e apparen Mo re CI can ticular con used all depe HTM r. Tags i-patter they tend es, but can l, but rity all L or XHT t. Reg a par etimes s. Ant , Binar most phone services: plans with alloted resources, with an toInteg y Centr alize late fi le that ts and XHT simplify all will help ML, und ardless L VS XHTM <a>< ctic temp you prov b></ hes som proces in the end bad pra enting you in nt nmen geme e a single based on incurred cost whether such resources were consumedto thenot. t enviro or ML physical r othe Virtualization allows aare actu piece of hardware idebe much to erstand of HTML L cy Mana approac ed with the cial, but, implem nt targe ally simp r web cod Creat rily nden rties are es of the a solid ing has into differe necessa pared to chang efi Depe prope itting utilized by multiple operating systems. This allows resources function ing. foundati job adm been arou associat to be ben er ality has ler than they Fortuna Ge t te builds commo are not late Verifi e comm on n com remo Cloud computing asRun known etoday has changed this. etc. it’s befor irably, nd for They lts whe Temp Build ually, (e.g. bandwidth,n elem CPU) to be mov memory, allocated exclusively to tely expecte that job som appear effects. The various resources consumed by webperiodically, rm a Privat contin applications (e.g.nt team Every ent instances. ed to CSS used to be, HTML d. Earl has exp e time. Whi ed resu tion Perfo opme pag individual operating system s because Brow ser man y HTML adverse unintend Integra d Builds sitory bandwidth, memory, CPU) areIntegration on from CI server basis Build to devel common e (HTML . anded le it far mor has done Stage Repo e ous tallied a per-unit or XHT web dev ufac had very produc Continu Refcard e Build rm an extensio .) All are elopers turers add e.com ML shar limit e than its tern. ack term (starting from zero) by Perfomajor cloud computing platforms. Privat all feedb on n. HTM essentia As a user of Amazon’s EC2 cloud computing platform, you are es cert result ed man ed layout anybody e, this ated the pat occur came gration as based is of the ” cycl such Build Send autom as they builds proc assigned essor L files lly plai an operating system in the same wayain on all hosting as elements The late a lack of stan up with clev y competi supp ous Inte tional use and test concepts soon n text ort. ration ors as ion with should Integ entat in st web dar er wor ng stan Continu conven “build include oper docum not be cr standar kar dar While the s to the of CI to efer Gene rate devel ion Cloud Computing the not s on expand DZone, Inc. 140 Preston Executive Dr. Suite 100 Cary, NC 27513 DZone communities deliver over 6 million pages each month to 888.678.0399 more than 3.3 million software developers, architects and decision 919.678.0300 makers. DZone offers something for everyone, including news, Refcardz Feedback Welcome $7.95 tutorials, cheat sheets, blogs, feature articles, source code and more. [email protected] “DZone is a developer’s dream,” says PC Magazine. Sponsorship Opportunities Copyright © 2011 DZone, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, [email protected] Version 1.0 without prior written permission of the publisher.