geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/naming/java ReadOnlyContext.java
Date Tue, 09 Dec 2003 18:40:53 GMT
On Mon, Dec 08, 2003 at 09:43:39PM -0800, David Jencks wrote:
> I'm sorry, I don't understand all about jndi.
> 
> Could you give an example of what this is for, and how it differs from  
> binding into the read only context refs whose targets are in say the  
> jmx context?

The ReadOnlyContext is used by the OpenEJB nova containers, so there is no jmx anything going
on.  The situation is that I need to add another Context implementation, one built by OpenEJB,
into the ReadOnlyContext of an EJBContainer.

Doing this by instantiating the ReadOnlyContext with a Map, where one of the values is the
non-ReadOnlyContext context object.  Lookups to the respective name need to be delegated to
that context object.

> Does this have the effect of making the ReadOnlyContext mutable, in  
> that you can look up whatever happens to be currently bound in the  
> subcontext?

It could if the Context added allowed bind operations, but in this case it doesn't.  The neat
thing is that the "outside" context is only checked if the lookup failed against the ReadOnlyContext,
so everything in the ReadOnlyContext essentially trumps the outside context.  This is useful
for the UserTransaction object.

-David Blevins

> 
> Thanks
> david jencks
> 
> On Monday, December 8, 2003, at 09:03 PM, dblevins@apache.org wrote:
> 
> >dblevins    2003/12/08 21:03:49
> >
> >  Modified:    modules/core/src/java/org/apache/geronimo/naming/java
> >                        ReadOnlyContext.java
> >  Log:
> >  Added support to do lookups from other Context implementations.  In  
> >other words,
> >  sub-contexts under the context which aren't ReadOnlyContext  
> >implementations.
> >
> >  Revision  Changes    Path
> >  1.7       +23 -3      
> >incubator-geronimo/modules/core/src/java/org/apache/geronimo/naming/ 
> >java/ReadOnlyContext.java
> >
> >  Index: ReadOnlyContext.java
> >  ===================================================================
> >  RCS file:  
> >/home/cvs/incubator-geronimo/modules/core/src/java/org/apache/ 
> >geronimo/naming/java/ReadOnlyContext.java,v
> >  retrieving revision 1.6
> >  retrieving revision 1.7
> >  diff -u -r1.6 -r1.7
> >  --- ReadOnlyContext.java	16 Nov 2003 05:24:38 -0000	1.6
> >  +++ ReadOnlyContext.java	9 Dec 2003 05:03:49 -0000	1.7
> >  @@ -87,7 +87,7 @@
> >    * resolution phase performed by the JVM takes considerably longer,  
> >so for
> >    * optimum performance lookups should be coded like:</p>
> >    * <code>
> >  - *   Context componentContext = new  
> >InitialContext().lookup("java:comp");
> >  + *   Context componentContext = (Context)new  
> >InitialContext().lookup("java:comp");
> >    *   String envEntry = (String)  
> >componentContext.lookup("env/myEntry");
> >    *   String envEntry2 = (String)  
> >componentContext.lookup("env/myEntry2");
> >    * </code>
> >  @@ -122,7 +122,11 @@
> >       }
> >
> >       ReadOnlyContext(Hashtable env) {
> >  +        if (env == null) {
> >  +            this.env = new Hashtable();
> >  +        } else {
> >           this.env = new Hashtable(env);
> >  +        }
> >           this.bindings = Collections.EMPTY_MAP;
> >           this.treeBindings = Collections.EMPTY_MAP;
> >       }
> >  @@ -159,8 +163,24 @@
> >                       throw new NamingException("scheme " + scheme +  
> >" not recognized");
> >                   }
> >                   return ctx.lookup(name);
> >  +            } else {
> >  +                // Split out the first name of the path
> >  +                // and look for it in the bindings map.
> >  +                CompositeName path = new CompositeName(name);
> >  +
> >  +                if (path.size() == 0) {
> >  +                    return this;
> >  +                } else {
> >  +                    Object obj = bindings.get(path.get(0));
> >  +                    if (obj == null){
> >  +                        throw new NameNotFoundException(name);
> >  +                    } else if (obj instanceof Context &&  
> >path.size() > 1){
> >  +                        Context subContext = (Context) obj;
> >  +                        obj = subContext.lookup(path.getSuffix(1));
> >  +                    }
> >  +                    return obj;
> >  +                }
> >               }
> >  -            throw new NameNotFoundException(name);
> >           }
> >           if (result instanceof LinkRef) {
> >               LinkRef ref = (LinkRef) result;
> >
> >
> >
> >

Mime
View raw message