Example usage for javax.naming.spi NamingManager getInitialContext

List of usage examples for javax.naming.spi NamingManager getInitialContext

Introduction

In this page you can find the example usage for javax.naming.spi NamingManager getInitialContext.

Prototype

public static Context getInitialContext(Hashtable<?, ?> env) throws NamingException 

Source Link

Document

Creates an initial context using the specified environment properties.

Usage

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

@AfterClass
public static void stop() throws NamingException {
    JqmClientFactory.resetClient(null);// w  w  w.  ja va2  s .  c  om
    Helpers.resetEmf();
    ((JndiContext) NamingManager.getInitialContext(null)).resetSingletons();
    s.shutdown();
    s.stop();
}

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

/**
 * Will create a JNDI Context and register it as the initial context factory builder
 * //from   ww w.  java2  s .co  m
 * @return the context
 * @throws NamingException
 *             on any issue during initial context factory builder registration
 */
static JndiContext createJndiContext() throws NamingException {
    try {
        if (!NamingManager.hasInitialContextFactoryBuilder()) {
            JndiContext ctx = new JndiContext();
            NamingManager.setInitialContextFactoryBuilder(ctx);
            return ctx;
        } else {
            return (JndiContext) NamingManager.getInitialContext(null);
        }
    } catch (Exception e) {
        jqmlogger.error("Could not create JNDI context: " + e.getMessage());
        NamingException ex = new NamingException("Could not initialize JNDI Context");
        ex.setRootCause(e);
        throw ex;
    }
}

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

private DataSource getDefaultConnection() throws NamingException {
    Object dso = NamingManager.getInitialContext(null).lookup(this.defaultCon);
    DataSource q = (DataSource) dso;

    return q;/*from  w  w w.  j a va2 s .  com*/
}

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

static ClassLoader getExtClassLoader() {
    try {/*from ww  w.j  a v a  2 s  .c om*/
        return ((JndiContext) NamingManager.getInitialContext(null)).getExtCl();
    } catch (NamingException e) {
        // Don't do anything - this actually cannot happen. Death to checked exceptions.
        return null;
    }
}