@Override protected Context getDefaultInitCtx() throws NamingException { if (!gotDefault) { // if there is an initial context factory prop in the env use it to create the default ctx final String factoryClassName = myProps != null ? (String) myProps.get(Context.INITIAL_CONTEXT_FACTORY) : null; if(factoryClassName == null || InitialContextFactory.class.getName().equals(factoryClassName)) { defaultInitCtx = new DefaultInitialContext(myProps); } else { final ClassLoader classLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { final Class<?> factoryClass = Class.forName(factoryClassName, true, classLoader); defaultInitCtx = ((javax.naming.spi.InitialContextFactory)factoryClass.newInstance()).getInitialContext(myProps); } catch (NamingException e) { throw e; } catch (Exception e) { throw NamingLogger.ROOT_LOGGER.failedToInstantiate(e, "InitialContextFactory", factoryClassName, classLoader); } } gotDefault = true; } return defaultInitCtx; }
/** {@inheritDoc} */ @Override public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { // NOPMD try { final Class<?> clazz = Class.forName(initialContextFactory); final InitialContextFactory icf = (InitialContextFactory) clazz.newInstance(); final Context context = icf.getInitialContext(environment); final JdbcWrapper jdbcWrapper = JdbcWrapper.SINGLETON; return jdbcWrapper.createContextProxy(context); } catch (final ClassNotFoundException e) { throw createNamingException(e); } catch (final InstantiationException e) { throw createNamingException(e); } catch (final IllegalAccessException e) { throw createNamingException(e); } }
builder.bind("myobject", obj); Context context1 = factory.getInitialContext(null); assertTrue("Correct DataSource registered", context1.lookup("java:comp/env/jdbc/myds") == ds); assertTrue("Correct Object registered", context1.lookup("myobject") == obj); Context context2 = factory.getInitialContext(env2); assertTrue("Correct DataSource registered", context2.lookup("java:comp/env/jdbc/myds") == ds); assertTrue("Correct Object registered", context2.lookup("myobject") == obj);
public Context getInitialContext( Hashtable<?, ?> env ) throws NamingException { return factory.getInitialContext( env ); } }
public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { return typeDefaults.get(FactoryType.detect(environment, pretendNoFactoryBuilder)).getInitialContext( environment); } };
public synchronized Context getInitialContext(Hashtable environment) throws NamingException { Context context = contextFactory.getInitialContext(environment); for (Map.Entry<String, Object> entry : globalBindings.entrySet()) { context.bind(entry.getKey(),entry.getValue()); } return (Context) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Context.class}, new JNDIContextHandler(context)); }
public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { Context ctx = factory.getInitialContext(environment); Set<Class<?>> implementedIfaces = getAllImplementedInterfaces(ctx.getClass()); Class<?>[] ii = new Class<?>[implementedIfaces.size()]; implementedIfaces.toArray(ii); return (Context) Proxy.newProxyInstance(ctx.getClass().getClassLoader(), ii, new DecoratingInvocationHandler<Context, ContextDecorator>(pickers, ctx)); }
/** * load the context factory */ private Context loadInitialContext(String factoryClass, Hashtable env) { Object factory = ConnectorsUtil.loadObject(factoryClass); if (factory == null) { System.err.println("Cannot load external-jndi-resource " + "factory-class '" + factoryClass + "'"); return null; } else if (! (factory instanceof javax.naming.spi.InitialContextFactory)) { System.err.println("external-jndi-resource factory-class '" + factoryClass + "' must be of type " + "javax.naming.spi.InitialContextFactory"); return null; } Context context = null; try { context = ((InitialContextFactory)factory).getInitialContext(env); } catch (NamingException ne) { System.err.println("Exception thrown creating initial context " + "for external JNDI factory '" + factoryClass + "' " + ne.getMessage()); } return context; }
public synchronized Context getInitialContext(Hashtable environment) throws NamingException { env = environment; String otherName = (String)environment.get(Context.INITIAL_CONTEXT_FACTORY); if (otherName != null && !getClass().getName().equals(otherName)) { try { InitialContextFactory otherFactory = (InitialContextFactory)Thread.currentThread(). getContextClassLoader().loadClass(otherName).newInstance(); return otherFactory.getInitialContext(environment); } catch (Exception e) { // No NB ErrorManager here! e.printStackTrace(); } } // Get the open project based on the open page Project currentProj = CurrentProject.getInstance().getOpenedProject(); // Construct a new context object for the current project return DesignTimeContext.createDesignTimeContext(currentProj, environment); } }
@Override protected Context getDefaultInitCtx() throws NamingException { if (!gotDefault) { // if there is an initial context factory prop in the env use it to create the default ctx final String factoryClassName = myProps != null ? (String) myProps.get(Context.INITIAL_CONTEXT_FACTORY) : null; if(factoryClassName == null || InitialContextFactory.class.getName().equals(factoryClassName)) { defaultInitCtx = new DefaultInitialContext(myProps); } else { final ClassLoader classLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { final Class<?> factoryClass = Class.forName(factoryClassName, true, classLoader); defaultInitCtx = ((javax.naming.spi.InitialContextFactory)factoryClass.newInstance()).getInitialContext(myProps); } catch (NamingException e) { throw e; } catch (Exception e) { throw NamingLogger.ROOT_LOGGER.failedToInstantiate(e, "InitialContextFactory", factoryClassName, classLoader); } } gotDefault = true; } return defaultInitCtx; }
@Override protected Context getDefaultInitCtx() throws NamingException { if (!gotDefault) { // if there is an initial context factory prop in the env use it to create the default ctx final String factoryClassName = myProps != null ? (String) myProps.get(Context.INITIAL_CONTEXT_FACTORY) : null; if(factoryClassName == null || InitialContextFactory.class.getName().equals(factoryClassName)) { defaultInitCtx = new DefaultInitialContext(myProps); } else { final ClassLoader classLoader = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { final Class<?> factoryClass = Class.forName(factoryClassName, true, classLoader); defaultInitCtx = ((javax.naming.spi.InitialContextFactory)factoryClass.newInstance()).getInitialContext(myProps); } catch (NamingException e) { throw e; } catch (Exception e) { throw NamingLogger.ROOT_LOGGER.failedToInstantiate(e, "InitialContextFactory", factoryClassName, classLoader); } } gotDefault = true; } return defaultInitCtx; }
/** {@inheritDoc} */ @Override public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { // NOPMD try { final Class<?> clazz = Class.forName(initialContextFactory); final InitialContextFactory icf = (InitialContextFactory) clazz.newInstance(); final Context context = icf.getInitialContext(environment); final JdbcWrapper jdbcWrapper = JdbcWrapper.SINGLETON; return jdbcWrapper.createContextProxy(context); } catch (final ClassNotFoundException e) { throw createNamingException(e); } catch (final InstantiationException e) { throw createNamingException(e); } catch (final IllegalAccessException e) { throw createNamingException(e); } }
wrapped = factory.getInitialContext(environment);
private ResolveResult findContextFor(String name) throws NamingException { String rname = getRelativeName(name); Context context = null; if (rname.equals("")) { // null name refers to this context context = new scnURLContext(myEnv); } else { // other names are component independant context = namingFactory.getInitialContext(myEnv); } // Check context is not null to avoid nullPointerException if (context == null) { throw new NameNotFoundException("No context for this component"); } // Build a ResolveResult object to return ResolveResult r = new ResolveResult(context, rname); return r; }
private ResolveResult findContextFor(String name) throws NamingException { String rname = getRelativeName(name); Context context = null; if (rname.equals("")) { // null name refers to this context context = new hascnURLContext(myEnv); } else { // other names are component independant context = namingFactory.getInitialContext(myEnv); } // Check context is not null to avoid nullPointerException if (context == null) { throw new NameNotFoundException("No context for this component"); } // Build a ResolveResult object to return ResolveResult r = new ResolveResult(context, rname); return r; }
try { context = ((InitialContextFactory) factory).getInitialContext(env);
try { context = ((InitialContextFactory) factory).getInitialContext(env);
public Context getInitialContext( final Hashtable environment ) throws NamingException { final Hashtable hashtable = new Hashtable(); if ( environment != null ) { hashtable.putAll( environment ); } final String o = (String) hashtable.get( "java.naming.factory.initial" ); if ( StringUtils.isEmpty( o ) == false && DebugJndiContextFactory.class.getName().equals( o ) == false ) { final InitialContextFactory contextFactory = ObjectUtilities.loadAndInstantiate( o, DebugJndiContextFactory.class, InitialContextFactory.class ); return contextFactory.getInitialContext( environment ); } hashtable.put( JndiLoader.SIMPLE_DELIMITER, "/" ); try { final File directory = GoldenSampleGenerator.findMarker(); final File jndi = new File( directory, "jndi" ); if ( jndi != null ) { hashtable.put( SimpleContext.SIMPLE_ROOT, jndi.getAbsolutePath() ); } } catch ( SecurityException se ) { // ignore .. } return new SimpleContext( hashtable ); } }