dev@glassfish.java.net

Re: CCC Request: end support for lookup name "UserTransaction"

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Mon, 13 Sep 2010 14:19:21 -0700

Jerome,

To avoid synchronization calls on all lookups, GlassfishNamingManager creates a
new InitialContext in its constructor. This triggers loading of all
NamingObjectsProvider(s) by SerialInitContextFactory.

One of the TransactionNamingProxy impls is TransactionNamingProxy which in its
postConstruct publishes UTx by the name "UserTransaction" (because there is no
"java:" prefix, this is the only way to make it available in the current impl)
using GlassfishNamingManager, which is still being constructed.

 From my experience with hk2 use, moving 'new IC()' to
GlassfishNamingManager.postConstruct won't solve the problem.

Best,
-marina

Jerome Dochez wrote:
> We talked about this at CCC today and we were not particularly in favor of getting rid of a feature just because it solves a coding issue.
>
> Can you elaborate the cyclic dependency you are having that cannot be resolved ?
>
> jerome
>
> On Sep 7, 2010, at 8:10 PM, Cheng Fang wrote:
>
>
>>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
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>