EJB 3.1 Proposed Final Draft Now Available

I'm pleased to announce that the EJB 3.1 Proposed Final Draft is now available. We're well on our way towards finalizing what I'm sure will be a vastly improved version of Enterprise JavaBeans. The spec includes many clarifications to the requirements from the previous drafts, as well as some small feature improvements. Here are a few of the notable changes :

Improved portable Local Session Bean lookups

The EJB 3.1 Public Draft introduced portable global JNDI names for session beans. While the global syntax works great for Remote lookups, it is not ideal for dynamic lookups of Local session beans. We've gotten a lot of feedback that it's too cumbersome to have to declare an ejb-local-ref or @EJB annotation just to retrieve a session bean defined within the same module.

The problem with the portable global JNDI name syntax is that it requires knowing the module name and potentially the application name in order to make the lookup. To minimize these dependencies, we're adding JNDI syntaxes based on two new portable naming scopes called java:module and java:app.

java:module lookups are scoped to the module in which the lookup occurs. They allow session beans to be retrieved based only on the ejb-name.

java:app lookups are scoped to the application in which the lookup occurs. They allow session beans to be retrieved based only on the module name and the ejb-name.

For example, given the following Stateless session bean :

   1:  @Stateless 
   2:  public class HelloBean {
   3:     public String hello() { return "hello, world\\n"; }
   4:  }

Any code running within the same module as HelloBean can portably retrieve its reference as follows :

   1:  InitialContext ic = new InitialContext();
   2:  HelloBean hb = (HelloBean) ic.lookup("java:module/HelloBean");

Likewise, if HelloBean is packaged in hello.jar, any code running in a module within the same .ear can portably retrieve its reference using the string "java:app/hello/HelloBean".

See Section 4.4 for more details.

Timezone support for calendar-based timers

One of the limitations of calendar-based timers as defined in the Public Draft is that their schedules can only be specified relative to the time zone in which the application is deployed. That means if you want a calendar-based timeout to occur at a specific time in a given time zone, there's no easy way to do it.

The Proposed Final Draft addresses this by allowing an optional time zone ID to be associated with a calendar-based timer. In that case, all timeouts occur relative to the specified time zone. Time zones are supported no matter how the calendar-based timer is defined : programmatically, via annotation, or in ejb-jar.xml.

For example, the following code defines an automatic calendar-based timeout that occurs at 10 a.m. U.S. Eastern Time every day, independent of where the application itself is running :

   1:  @Schedule(hour="10", timezone="America/New_York")
   2:  public void timeout() { ... } 

See Section 18.2 for more details.

Spec-defined stateful session bean timeouts

Developers are always asking why there isn't a spec-defined way to specify the stateful session bean timeout value. Stateful session beans have always had the notion of a timeout, yet it has been left to the vendors to define the configuration for this value. The Proposed Final Draft defines a portable way to specify it.

   1:  @Stateful
   2:  @StatefulTimeout(value=10, unit=TimeUnit.MINUTES)
   3:  public class CartBean { ... }

@StatefulTimeout specifies the amount of time a stateful session bean can be idle (not receive any client invocations) before being eligible for removal by the container. The time unit is optional and defaults to MINUTES. Like all of our annotations, the stateful timeout metadata can also be specified in ejb-jar.xml.

See Section 4.3.12 for more details.


Please check out the spec and leave feedback here or at jsr-318-comments@jcp.org. Note that given where we are in the process the top priority is fixing spec bugs and problems with the APIs. Of course, we're always interested in hearing feature requests for future EJB versions :-)

Comments:

hg in --quiet --template '{files}\\n' | sort | uniq

Or is that getting you the same list?

-kto
http://www.muzikler.org/sitemap.php
http://www.muzikler.org/sitemap2.php

Posted by oyun on January 16, 2010 at 10:00 AM EST #

StatefulTimeout specifies the amount of time a stateful session bean can be idle (not receive any client invocations) before being eligible for removal by the container. The time unit is optional and defaults to MINUTES. Like all of our annotations, the stateful timeout metadata can also be specified in ejb-jar.xml.

Posted by tütünex on February 11, 2011 at 07:35 PM EST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Ken Saks is the Spec Lead for Enterprise JavaBeans (EJB) 3.1 and a Senior Staff Engineer in the Java Platform, Enterprise Edition team at SUN.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today