Package javax.naming

Examples of javax.naming.CompositeName


                }
                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 {
                    String first = path.get(0);
                    Object value = bindings.get(first);
                    if (value == null) {
                        throw new NameNotFoundException(name);
                    } else if (value instanceof Context && path.size() > 1) {
                        Context subContext = (Context)value;
                        value = subContext.lookup(path.getSuffix(1));
                    }
                    return value;
                }
            }
        }
View Full Code Here


        result.addAll(name);
        return result;
    }

    public String composeName(String name, String prefix) throws NamingException {
        CompositeName result = new CompositeName(prefix);
        result.addAll(new CompositeName(name));
        return result.toString();
    }
View Full Code Here

           Name contextName = parser.parse(context.getNameInNamespace());
           Name baseName = parser.parse(base);
  
           // Bugzilla 32269
           Name entryName =
               parser.parse(new CompositeName(result.getName()).get(0));
  
           Name name = contextName.addAll(baseName);
           name = name.addAll(entryName);
           return name.toString();
        } else {
View Full Code Here

                Context ctx = new InitialContext();
                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;
                }
            }
        }
View Full Code Here

        result.addAll(name);
        return result;
    }

    public String composeName(String name, String prefix) throws NamingException {
        CompositeName result = new CompositeName(prefix);
        result.addAll(new CompositeName(name));
        return result.toString();
    }
View Full Code Here

    protected Object federate(String compositName) throws NamingException {
        ObjectFactory factories [] = getFederatedFactories();
        for (ObjectFactory factory : factories) {
            try {
                CompositeName name = new CompositeName(compositName);
                Object obj = factory.getObjectInstance(null, name, null, null);

                if (obj instanceof Context)
                    return ((Context) obj).lookup(compositName);
                else if (obj != null)
View Full Code Here

    public NameParser getNameParser(Name name) throws NamingException {
        return getNameParser(name.toString());
    }

    public String composeName(String name, String prefix) throws NamingException {
        Name result = composeName(new CompositeName(name),
                                  new CompositeName(prefix));
        return result.toString();
    }
View Full Code Here

*/
public class BasicContextTest extends AbstractContextTest {

    public void testInitialContext() throws NamingException {
        assertEquals("Hello", initialContext.lookup("java:comp/env/hello"));
        assertEquals("Hello", initialContext.lookup(new CompositeName("java:comp/env/hello")));
    }
View Full Code Here

            envContext.lookup("foo");
            fail();
        } catch (NamingException e) {
            // OK
        }
        assertEquals("Hello", envContext.lookup(new CompositeName("hello")));
        assertEquals("Hello", compContext.lookup(new CompositeName("env/hello")));
        assertEquals("Hello", envContext.lookup(new CompoundName("hello", syntax)));
        assertEquals("Hello", compContext.lookup(new CompoundName("env/hello", syntax)));

        assertEquals(envContext, envContext.lookup(""));
    }
View Full Code Here

    }

    public void testComposeName() throws NamingException {
        assertEquals("org/research/user/jane", envContext.composeName("user/jane", "org/research"));
        assertEquals("research/user/jane", envContext.composeName("user/jane", "research"));
        assertEquals(new CompositeName("org/research/user/jane"), envContext.composeName(new CompositeName("user/jane"), new CompositeName("org/research")));
        assertEquals(new CompositeName("research/user/jane"), envContext.composeName(new CompositeName("user/jane"), new CompositeName("research")));
    }
View Full Code Here

TOP

Related Classes of javax.naming.CompositeName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.