Menu

#1 Handling of References broken?

open
None
5
2002-06-12
2002-06-12
No

1. I tried to incorporate the tyrex JNDI Provider into my Client
Container
and found some bug(s) in the MemoryContext regarding
ReferenceHandling.
I'm using my own ThreadLocalContextFactory and my own
(read/write)
JavaContext and javaURLContextFactory ..

RefAddr refAddr = new StringRefAddr("nns", "ENC");
Reference envRef = new Reference("javax.naming.Context",
refAddr,
ThreadLocalContextFactory.class.getName(),
null);
Context context = (Context)new InitialContext().lookup("java:");
context.bind("comp", envRef);

Thus "java:comp" is a dynamic reference to a thread local context.

The following code is working:

Context subcontext = (Context)context.lookup("comp");
subcontext.bind("test", "value");

is working. However, the following results in a
NotContextException: "comp
is not a subcontext":

context.bind("comp/test", "value");

.. well, he's right, but it's a Reference to a subcontext!!

The problem is, that References are only followed during lookups. If
bind/rebind/list/.. are called with a name that traverses a Reference,
the
reference is not followed.

The attached patch fixes this (at least for me). But I'm not sure, if it
fixes all places, where references have to be followed. Also LinkRefs
are
not handled.

2. another suggestion (also part of the patch): Please make the
constructor:

MemoryContext( MemoryBinding bindings, Hashtable env )

public or at least protected to make the MemoryContext more
accessible and
useful for different applications.

3. Please separate the JNDI provider from the rest of the tyrex jar.
The
class dependencies "leak":

javaURLContextFactory depends on JavaContext
JavaContext depends on EnvContext
EnvContext depends on tyrex.tm.impl.ThreadContext
ThreadContext depends on tyrex.tm.RuntimeContext
RuntimeContext depends on everything else

This means, that the java url context factory can only be used in
conjunction with the whole tyrex functionality.

A possible solution would be to use a provider mechanism: a
configurable
ObjectFactory implementation, that populates the EnvContext.

Discussion

  • Holger Engels

    Holger Engels - 2002-06-12

    patch for MemoryContext

     
  • Riad Mohammed

    Riad Mohammed - 2002-06-12
    • assigned_to: nobody --> tyrex
     
  • Riad Mohammed

    Riad Mohammed - 2002-06-12

    Logged In: YES
    user_id=551721

    Thanks for the patch. I'll add support for LinkRefs as well. It'll be in
    the next point release. I'm waiting for the old CVS to be imported
    before I can work on it.

     
  • alan johnson

    alan johnson - 2004-05-24

    Logged In: YES
    user_id=943591

    this seems to be a remedy

     

Log in to post a comment.