Felipe Gaúcho works as senior software engineer at Netcetera AG in Switzerland. He is a well known Brazilian JUG leader and open-source evangelist. Felipe works with Java since its early versions and has plans to keep that Java tradition as it is. When he is not coding, he prefers to listen reggae and travel around with his lovely wife Alena and his son Rodrigo. Felipe is a DZone MVB and is not an employee of DZone and has posted 29 posts at DZone. View Full User Profile

EJB 3.1 to Release on Third Quarter of 2009

06.03.2009
| 3988 views |
  • submit to reddit

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
Published at DZone with permission of Felipe Gaúcho, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Wang Dongnian replied on Fri, 2009/06/05 - 7:50am

That is really exciting new features in EJB3.1. We can develop and deploy application more easily and efficitive.

lucas hal replied on Tue, 2009/06/09 - 1:23pm

My name is lucas, I have started my edveture with bookmakers 2 years ago.Since this time I have won around 100 000 usd. Would You like do same?? Think about Sports betting and change Your life. Nice post Regards

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.