geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: svn commit: r465917 - in /geronimo/server/trunk/modules: geronimo-client/src/main/java/org/apache/geronimo/client/ geronimo-naming/src/main/java/org/apache/geronimo/naming/enc/ geronimo-naming/src/test/java/org/apache/geronimo/gjndi/
Date Fri, 20 Oct 2006 07:44:11 GMT

On Oct 19, 2006, at 11:19 PM, Jacek Laskowski wrote:

> On 10/20/06, dain@apache.org <dain@apache.org> wrote:
>> Author: dain
>> Date: Thu Oct 19 15:44:24 2006
>> New Revision: 465917
> ...
>> +        boolean containsEnv = false;
>> +        for (Iterator iterator = map.entrySet().iterator();  
>> iterator.hasNext();) {
>> +            Map.Entry entry = (Map.Entry) iterator.next();
>> +            String name = (String) entry.getKey();
>> +            Object value = entry.getValue();
>> +
>> +            if (name.startsWith("env/")) {
>> +                containsEnv = true;
>> +            }
>>              if (value instanceof KernelAwareReference) {
>>                  ((KernelAwareReference) value).setKernel(kernel);
>>              }
>>              if (value instanceof ClassLoaderAwareReference) {
>>                  ((ClassLoaderAwareReference) value).setClassLoader 
>> (classLoader);
>>              }
>> +        }
>> +
>> +        if (!containsEnv) {
>> +            Context env = new ImmutableContext("java:comp/env",  
>> Collections.EMPTY_MAP, false);
>> +            map.put("env", env);
>>          }
>
> I haven't tested it out, but...reading the code seems to set
> containsEnv to false every time. It's because name.startsWith("env/")
> checks whether env + '/' whereas map contains only env (with no
> trailing slash).
>
> BTW, why doesn't it simply use map.get("env") to verify whether
> java:comp/env is available?

My understanding of this code is that the map keys are the complete  
paths to the objects bound into jndi.  You can't really bind anything  
to env, it would have to be env/foo, and although I don't think  
there's any way to bind anything to envthisisalongername it's easier  
to just check startsWith("env/") to avoid any confusion.  So, you'd  
never get map.get("env") != null, and startsWith("env/") while  
probably redundant is certainly accurate.

thanks
david jencks

>
> -- 
> Jacek Laskowski
> http://www.jaceklaskowski.pl


Mime
View raw message