Live from JavaOne: JCA Spec Enhancements

Live from the JavaOne conference, I’m currently attending a session on JCA specification 1.6 enhancements. According to the specification team, the goal of the new version of the spec is to simplify writing resource adapters (RAs) for those who have not written them in the past or may be new to the specification. In this article, I highlight some of the important new features.

1. New Annotation: @Connector
An alternative for creating XML information, this can now be done simply in the annotation.

2. New Annotation: @ConfigProperty
Complicated in previous versions, the new 1.6 spec will allow for automatic discovery of config properties to ease development of connectors.

3. New Annotation: @Activation
They’ve replaced activation interface required with simple annotation property as follows:

@Activation()
public class MyActivationSpec {
   // Use of bean validation annotations to express validation requirements
   @Size(min=5,max=5)
   private int length;
    // other methods...
}

Generic Work Context
They updated the concept of work context to accomplish tasks. A resource adapter submits a job request to the work manager, which then creates a work plan to complete the request, such as setting the proper transaction request. Backwards compatible with existing JCA 1.5 connector work solution.

More Information
This article is briefer than previous ones, in part because the slides were fast and flowing during the talk. Hopefully, I’ll update the information when the official slides are published.

Live from JaveOne: JDBC Spec Enhancements

Live from the JavaOne conference again, this time attending a session about enhancements to the JDBC specification 4.1. Four members of the JDBC specification team have presented a number of useful enhancements due in the upcoming version of JDBC. Some of these features may not make it into 4.1, but will be in future versions of JDBC down the road.

1. Named Prepared Statements
As many of you may already know, Prepared Statements support parameters referenced by numeric index such as ps.setString(1,”val1″) where “1” corresponds to the 1st index of “?” in the SQL string. Perhaps rightfully so, a lot of new developers to JDBC often complain that JDBC should support named parameters as well as numeric indexes. Well those developers are in luck, future versions of JDBC may support syntax such as the following:

NamedPStatement nsmt = con.createNPStatement("SELECT f1, f2, f3 FROM foo 
     WHERE f1 = :f1 AND f2 < :f2");
nstmt.setParameter("f1","val1");
nstmt.setParameter("f2","val2");
ResultSet rs = nstmt.executeQuery();

A quick screenshot of the slide covering this information:

2. Chaining Commands
Using the previous example, the team intends to support chaining commands such that setParameter() returns a reference to the object allowing single-lined commands such as the following.

ResultSet rs = nstmt.setParameter("f1","val1").setParameter("f2","val2").executeQuery()

3. Changing schemas on the fly
For databases that support the notion of database schemas, you will be able to change your current schema dynamically after the connection is established, using the following command:

Connection connection = ...
connection.setSchema("mySchema")

For those databases that do not support such commands, this would likely be a no-op.

4. Timezone support
Better support for time zones are due in distant future versions after Java 1.7 adds a lot of new features related to them.

More information from their slide:

Live from JavaOne: EJB 3.1 New Features

I’m blogging live from the floor of the Sun JavaOne Conference in San Francisco today, currently attending a session about the new features of EJB 3.1. This article highlights some of the much-needed features added to the EJB 3.1 specification.

1. EJB Singletons (finally!)
The EJB 3.1 specification will support shared session bean instances without using a Java static object. Singleton session beans are added with the @Singleton annotation and are created per application, per JVM. The new features of a singleton object require a number of concurrency enhancements, referred to as bean-managed concurrency and container managed concurrency, which essentially supports read/write locks for the singleton object, helping to ensure proper access from multiple concurrent clients.

2. Dynamic/Portable JNDI names
When EJB modules are deployed, JNDI names are auto-created for each bean as follows:

  • Global: java:global/[<app-name>]/<module-name>/<ejb-name>
  • Same App: java:app/[<module-name>]/<ejb-name>
  • Module: java:module/<ejb-name>

3. EJB Timers
Added cron-like support for EJB timers. Seems identical to Java Quartz, but I’d have to see the lower level details to see if they are related. Timers can be created via annotations or explicitly in Java code and seem to have a much larger expressive language for creating schedules.

4. EJB Lite
Subset of the EJB implementation allowing vendors to create and support EJB environments with a much smaller overhead. Not sure how helpful this will be in practice since most vendors are currently used to creating full EJB implementations and creating a new, smaller subset will require some amount of non-trivial work.

5. Asynchronous Session Bean Invocations
Add asynchronous support for remote/local enterprise bean. “Fire and forget” with results available from Java concurrent Future API. Example:

@Stateless
public class HelloBean {
...
@Asynchronous public Future<int> getHelloValue() {...}
}

More to come
There were other things discussed in EJB 3.1 specification such as interface-less local beans, testing EJBs, startup/shutdown callbacks, and JAX-RS integration, but I’ve covered the ones I find most exciting. Overall, the Singleton aspect has to be one of the most needed features of EJB. More to come from the JavaOne conference this week!