Example usage for javax.naming Name getAll

List of usage examples for javax.naming Name getAll

Introduction

In this page you can find the example usage for javax.naming Name getAll.

Prototype

public Enumeration<String> getAll();

Source Link

Document

Retrieves the components of this name as an enumeration of strings.

Usage

From source file:com.enioka.jqm.tools.JndiContext.java

@Override
public void unbind(Name name) throws NamingException {
    this.unbind(StringUtils.join(Collections.list(name.getAll()), "/"));
}

From source file:com.enioka.jqm.tools.JndiContext.java

@Override
public Object lookup(Name name) throws NamingException {
    return this.lookup(StringUtils.join(Collections.list(name.getAll()), "/"));
}

From source file:com.enioka.jqm.tools.JndiContext.java

@Override
public void bind(Name name, Object obj) throws NamingException {
    this.bind(StringUtils.join(Collections.list(name.getAll()), "/"), obj);
}

From source file:de.micromata.genome.util.runtime.jndi.SimpleNamingContext.java

/**
 * Name to string.//from  www  .  j  a  va2 s.  c  om
 *
 * @param name the name
 * @return the string
 */
public String nameToString(Name name) {
    StringBuilder sb = new StringBuilder();
    Enumeration<String> en = name.getAll();
    while (en.hasMoreElements()) {
        String part = en.nextElement();
        if (sb.length() > 0) {
            sb.append('/');
        }
        sb.append(part);
    }
    return sb.toString();
}

From source file:jdao.JDAO.java

public static Context retrieveContext(String jndi_path) {
    InitialContext jndiContext = null;
    Context env = null;/* w  w  w  .ja v a  2  s  .c o m*/
    try {
        log("INFO: resolving " + jndi_path);

        env = jndiContext = new InitialContext();
        env = (Context) jndiContext.lookup(jndi_path);
    } catch (Exception xe) {
        try {
            Name jname = jndiContext.getNameParser(jndi_path).parse(jndi_path);
            Enumeration<String> en = jname.getAll();
            while (en.hasMoreElements()) {
                String name = en.nextElement();
                Context tmp = null;
                try {
                    tmp = (Context) env.lookup(name);
                    env = (Context) env.lookup(name);
                } catch (NameNotFoundException nnf) {
                    log("INFO: creating " + name);
                    env = env.createSubcontext(name);
                }
            }
        } catch (Exception xe2) {
            log("ERROR: resolving " + jndi_path, xe2);
        }
    }
    return env;
}

From source file:org.exoplatform.services.naming.InitialContextTest.java

public void testCompositeNameUsing() throws Exception {
    Name name = new CompositeName("java:comp/env/jdbc/jcr");
    Enumeration en = name.getAll();
    while (en.hasMoreElements()) {
        en.nextElement();/*from w ww  . ja  v  a 2  s  .  co m*/
    }
    InitialContext ctx = new InitialContext();
    ctx.bind(name, "foo");
    assertEquals("foo", ctx.lookup(name));
    try {
        ctx.bind(name, "foo2");
        fail("A NameAlreadyBoundException is expected here");
    } catch (NameAlreadyBoundException e) {
        // expected exception
    }
    assertEquals("foo", ctx.lookup(name));
    assertEquals("foo", ctx.lookup("java:comp/env/jdbc/jcr"));
    ctx.unbind(name);
    try {
        ctx.lookup(name);
        fail("A NameNotFoundException is expected here");
    } catch (NameNotFoundException e) {
        // expected exception
    }
}

From source file:org.force66.beantester.utils.GenericProxyHandlerTest.java

@Test
public void testBasic() throws Exception {

    performRoundTrip(this.makeProxy(Name.class));

    Name nameProxy = (Name) this.makeProxy(Name.class);
    Assert.assertTrue(!nameProxy.equals(null));
    Assert.assertTrue(!nameProxy.equals("foo"));
    Assert.assertTrue(new GenericProxyHandler() != null);

    try {//from  w  ww  . j  a  v  a2s  .co m
        nameProxy.getAll();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e.getMessage().contains("This is a generic interface proxy with no functionality"));
    }

}

From source file:org.jkcsoft.java.util.JndiHelper.java

public static Object lookup(Context jndi, String name) throws NamingException {
    //        String l_name = cleanName(p_name);

    Object retObj = jndi.lookup(name);

    if (log.isDebugEnabled()) {
        try {//  w w w.j a  v a  2 s.c o  m
            StringBuilder sbLog = new StringBuilder();

            NameParser parser = jndi.getNameParser(name);
            Name jndiName = parser.parse(name);
            List lNames = Collections.list(jndiName.getAll());
            if (lNames != null) {
                Iterator iNames = lNames.iterator();
                while (iNames.hasNext()) {
                    String elemName = (String) iNames.next();
                    Strings.appendLine(sbLog, "name [" + elemName + "]");
                }
            }
            log.debug("Jndi parse of [" + name + "] => " + sbLog);
        } catch (NamingException e) {
            log.warn("Error in getting JNDI name info", e);
        }
    }

    return retObj;
}