dev@glassfish.java.net

CCC Request: end support for lookup name "UserTransaction"

From: Cheng Fang <cheng.fang_at_oracle.com>
Date: Tue, 07 Sep 2010 23:10:56 -0400

  I'd like to explore the possibility of ending the support for
GlassFish-specific lookup name "UserTransaction" in 3.1. The usage of
this lookup name: initialContext.lookup("UserTransaction");

This lookup name might have been documented in previous versions.
However, it does not appear in either v2.1 GlassFish dev guide, or admin
guide. It's currently documented in both guides to use @Resource
injection or the portable lookup name "java:comp/UserTransaction". So
chances are this name is already defunct.

The direct reason for this request is issue 13108 (Cycle in our
component chain involving GlassFishNamingManager and
TransactionNamingProxy) [1]. One part of the circular dependency is
TransactionNamingProxy injecting GlassFishNamingManager, just to publish
UserTransaction by the name "UserTransaction". [2]

We can resolve this circular dependency by removing this injection and
naming publishing. It seems to be the fix with lowest risk.

After some discussion with Marian and Mahesh, another potential fix for
13108 is to lazily initialize InitialContext in
GlassFishNamingManagerImpl. InitialContext field is used extensively in
GlassFishNamingManagerImpl, in many frequent code paths like lookup,
bind, rebind, publish, etc. So this approach will add some
concurrency-related cost (e.g., volatile field, synchronized block). [3]

So IMO, skipping publishing "UserTransaction" seems to be a better fit.
Users can still use either @Resource injection (for Java EE 5 or newer),
or lookup "java:comp/UserTransaction" (for all versions of Java EE).

Any concerns / comments?

- cheng

[1]
https://glassfish.dev.java.net/issues/show_bug.cgi?id=13108
[2]
https://svn.dev.java.net/svn/glassfish-svn/trunk/v3/transaction/jta/src/main/java/com/sun/enterprise/transaction/TransactionNamingProxy.java
[3]
https://svn.dev.java.net/svn/glassfish-svn/trunk/v3/common/glassfish-naming/src/main/java/com/sun/enterprise/naming/impl/GlassfishNamingManagerImpl.java