Over a million developers have joined DZone.
Silver Partner

EJB 3.1 to Release on Third Quarter of 2009

· Java Zone

After the impressive General Session, I attended a session about EJB 3.1 - proposed to release on the third quarter of this year. There are tons of blogs with complete overview of the new EJB, but here are the fresh highlights from the session:

  1. Optional local interface business interface

  2. Packaging

    • We don't need to create EAR every time anymore
    • EJB 3.1 can be deployed directly inside the WAR file

    • ejb-jar.xml is optional

    • All resources are shared in the WAR file

  3. EJB 3.1 Lite API

    • Web profile (injection like Spring does)
    • No portability issue, works in Tomcat and Java EE containers, for example.

    • only available for local EJBs (no MDB, ws-endpoints, etc). Supposed to be a simplified and lightweight model.

  4. Portable Global JNDI names

    • The lookup mechanism will look for the local and remote interface (remember, the local is optional)
    • Improve the portability of remote Java Clients.

  5. Portable Naming Syntax: every session bean gets the following entries:

    • The lookup mechanism will look for the local and remote interface (remember, the local is optional)

    • Globally unique name:

    • Unique name within the same application.

    • Unique name within defining module.

  6. Testing EJBs

    • Embedded Container can be used in test classes:

      EJBContainer container = EJBContainer.createEJBContainer();
      container.getContext().lookup("java:global:/module/BankBean");

       

       

  7. Embeddable API

    • The code running in the Client side will have the same component behaviour /life cycle of the code running on the server side.

  8. New features

    1. Singletons - designed for efficient concurrent access.

      • Single Thread (default)

        @Singleton
        @Lock(READ)
        public class SharedBean {
        ...
        @Lock(READ)
        @AccessTimeout(value=1, ...)
        public void timeoutMethod(...) {
        }

        @Lock(WRITE)
        public void update(...) {
        }
        }

         

      • Container Managed Concurrency (method-level locking)
      • Bean Managed Concurrency (all concurrent invocations have access to bean instance). The developer is responsible to care about concurrency in this mode.
    2. Startup / Shutdown callbacks.

      • Startup: @Startup + @PostConstruct

      • Shutdown: @PreDestroy.

    3. Calendar-based timers: timeouts, automatic timer creation, non.persistent timers. A cron-like semantics with improved syntax. Automatic timer creation can be specified via annotations or deployment descriptor (ejb-jar.xml).

    4. @Asynchronous session bean invocations. Fire and Forget or async results via Future<V>. It is not available for MDB (for obvious reasons). Best ever delivers, better than JMS for EJB calls (persitent delivery guarantee not included in the spec).

      @Asynchronous
      public Future compute(Task t) { ... }

       

    5.  No transaction propagation from caller to callee.

    6. JAX-RS integration (RESTful). Instead of using Jersey or other technology to expose a RESTful web-service, we can just expose the bean on the HTTP interface. That's really cool and IMO it will save a lot of boiler plate code.

From http://weblogs.java.net/blog/felipegaucho
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}