Skip to main content

EJB 3.1 to release on third quarter of 2009

Posted by felipegaucho on June 2, 2009 at 1:19 PM PDT

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) { ... }

      No transaction propagation from caller to callee.

    5. 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.

Comments

How will it play with WebBeans?