@Test public void testGetInitialContext() throws Exception { final int port = Integer.parseInt(System.getProperty("ejbd.port", "4201")); final JNDIContext jndiContext = new JNDIContext(); final Hashtable<String, String> env = new Hashtable<String, String>(); assertEquals(jndiContext, "ejbd: assertEquals(jndiContext, "http: assertEquals(jndiContext, "anything: assertEquals(jndiContext, " assertEquals(jndiContext, "localhost", "ejbd: assertEquals(jndiContext, "localhost:" + port, "ejbd: assertEquals(jndiContext, "", "ejbd: assertEquals(jndiContext, "ejbd: assertEquals(jndiContext, "http: assertEquals(jndiContext, "anything: assertEquals(jndiContext, " assertEquals(jndiContext, "127.0.0.1", "ejbd: assertEquals(jndiContext, "127.0.0.1:" + port, "ejbd: }
@Override public Context getInitialContext(final Hashtable environment) throws NamingException { if (environment == null) { throw new NamingException("Invalid argument, hashtable cannot be null."); } else { env = decipher((Hashtable) environment.clone()); } final String userID = (String) env.get(Context.SECURITY_PRINCIPAL); final String psswrd = (String) env.get(Context.SECURITY_CREDENTIALS); String providerUrl = (String) env.get(Context.PROVIDER_URL); final String serializer = (String) env.get(SERIALIZER); final boolean authWithRequest = "true".equalsIgnoreCase(String.class.cast(env.get(AUTHENTICATE_WITH_THE_REQUEST))); moduleId = (String) env.get("openejb.client.moduleId"); final URI location; try { providerUrl = addMissingParts(providerUrl); location = new URI(providerUrl); } catch (URISyntaxException e) { throw (ConfigurationException) new ConfigurationException("Property value for " + Context.PROVIDER_URL + " invalid: " + providerUrl + " - " + e.getMessage()).initCause(e); } this.server = new ServerMetaData(location); final Client.Context context = Client.getContext(this.server); context.getProperties().putAll(environment); final String strategy = context.getOptions().get("openejb.client.connection.strategy", "default"); context.getClusterMetaData().setConnectionStrategy(strategy); Client.fireEvent(new RemoteInitialContextCreated(location)); if (userID != null) { if (!authWithRequest) { authenticate(userID, psswrd); } else { authenticationInfo = new AuthenticationInfo(String.class.cast(env.get("openejb.authentication.realmName")), userID, psswrd.toCharArray()); } } if (client == null) { client = new ClientMetaData(); } if (serializer != null) { try { client.setSerializer(EJBDSerializer.class.cast(Thread.currentThread().getContextClassLoader().loadClass(serializer).newInstance())); } catch (final Exception e) { } } final int queue = Integer.parseInt(getProperty(env, JNDIContext.POOL_QUEUE_SIZE, "2")); blockingQueue = new LinkedBlockingQueue<Runnable>((queue < 2 ? 2 : queue)); threads = Integer.parseInt(getProperty(env, "openejb.client.invoker.threads", "-1")); return this; }
JNDIContext implements InitialContextFactory, Context { @Override public Context getInitialContext(final Hashtable environment) throws NamingException { if (environment == null) { throw new NamingException("Invalid argument, hashtable cannot be null."); } else { env = decipher((Hashtable) environment.clone()); } final String userID = (String) env.get(Context.SECURITY_PRINCIPAL); final String psswrd = (String) env.get(Context.SECURITY_CREDENTIALS); String providerUrl = (String) env.get(Context.PROVIDER_URL); final String serializer = (String) env.get(SERIALIZER); final boolean authWithRequest = "true".equalsIgnoreCase(String.class.cast(env.get(AUTHENTICATE_WITH_THE_REQUEST))); moduleId = (String) env.get("openejb.client.moduleId"); final URI location; try { providerUrl = addMissingParts(providerUrl); location = new URI(providerUrl); } catch (URISyntaxException e) { throw (ConfigurationException) new ConfigurationException("Property value for " + Context.PROVIDER_URL + " invalid: " + providerUrl + " - " + e.getMessage()).initCause(e); } this.server = new ServerMetaData(location); final Client.Context context = Client.getContext(this.server); context.getProperties().putAll(environment); final String strategy = context.getOptions().get("openejb.client.connection.strategy", "default"); context.getClusterMetaData().setConnectionStrategy(strategy); Client.fireEvent(new RemoteInitialContextCreated(location)); if (userID != null) { if (!authWithRequest) { authenticate(userID, psswrd); } else { authenticationInfo = new AuthenticationInfo(String.class.cast(env.get("openejb.authentication.realmName")), userID, psswrd.toCharArray()); } } if (client == null) { client = new ClientMetaData(); } if (serializer != null) { try { client.setSerializer(EJBDSerializer.class.cast(Thread.currentThread().getContextClassLoader().loadClass(serializer).newInstance())); } catch (final Exception e) { } } final int queue = Integer.parseInt(getProperty(env, JNDIContext.POOL_QUEUE_SIZE, "2")); blockingQueue = new LinkedBlockingQueue<Runnable>((queue < 2 ? 2 : queue)); threads = Integer.parseInt(getProperty(env, "openejb.client.invoker.threads", "-1")); return this; } }
JNDIContext implements InitialContextFactory, Context { @Override public Context getInitialContext(final Hashtable environment) throws NamingException { if (environment == null) { throw new NamingException("Invalid argument, hashtable cannot be null."); } else { env = decipher((Hashtable) environment.clone()); } final String userID = (String) env.get(Context.SECURITY_PRINCIPAL); final String psswrd = (String) env.get(Context.SECURITY_CREDENTIALS); String providerUrl = (String) env.get(Context.PROVIDER_URL); final String serializer = (String) env.get(SERIALIZER); final boolean authWithRequest = "true".equalsIgnoreCase(String.class.cast(env.get(AUTHENTICATE_WITH_THE_REQUEST))); moduleId = (String) env.get("openejb.client.moduleId"); final URI location; try { providerUrl = addMissingParts(providerUrl); location = new URI(providerUrl); } catch (URISyntaxException e) { throw (ConfigurationException) new ConfigurationException("Property value for " + Context.PROVIDER_URL + " invalid: " + providerUrl + " - " + e.getMessage()).initCause(e); } this.server = new ServerMetaData(location); final Client.Context context = Client.getContext(this.server); context.getProperties().putAll(environment); final String strategy = context.getOptions().get("openejb.client.connection.strategy", "default"); context.getClusterMetaData().setConnectionStrategy(strategy); Client.fireEvent(new RemoteInitialContextCreated(location)); if (userID != null) { if (!authWithRequest) { authenticate(userID, psswrd); } else { authenticationInfo = new AuthenticationInfo(String.class.cast(env.get("openejb.authentication.realmName")), userID, psswrd.toCharArray()); } } if (client == null) { client = new ClientMetaData(); } if (serializer != null) { try { client.setSerializer(EJBDSerializer.class.cast(Thread.currentThread().getContextClassLoader().loadClass(serializer).newInstance())); } catch (final Exception e) { } } final int queue = Integer.parseInt(getProperty(env, JNDIContext.POOL_QUEUE_SIZE, "2")); blockingQueue = new LinkedBlockingQueue<Runnable>((queue < 2 ? 2 : queue)); threads = Integer.parseInt(getProperty(env, "openejb.client.invoker.threads", "-1")); return this; } JNDIContext();  JNDIContext(final JNDIContext that); }
JNDIContext implements InitialContextFactory, Context { @Override public Context getInitialContext(final Hashtable environment) throws NamingException { if (environment == null) { throw new NamingException("Invalid argument, hashtable cannot be null."); } else { env = decipher((Hashtable) environment.clone()); } final String userID = (String) env.get(Context.SECURITY_PRINCIPAL); final String psswrd = (String) env.get(Context.SECURITY_CREDENTIALS); String providerUrl = (String) env.get(Context.PROVIDER_URL); final String serializer = (String) env.get(SERIALIZER); final boolean authWithRequest = "true".equalsIgnoreCase(String.class.cast(env.get(AUTHENTICATE_WITH_THE_REQUEST))); moduleId = (String) env.get("openejb.client.moduleId"); final URI location; try { providerUrl = addMissingParts(providerUrl); location = new URI(providerUrl); } catch (URISyntaxException e) { throw (ConfigurationException) new ConfigurationException("Property value for " + Context.PROVIDER_URL + " invalid: " + providerUrl + " - " + e.getMessage()).initCause(e); } this.server = new ServerMetaData(location); final Client.Context context = Client.getContext(this.server); context.getProperties().putAll(environment); final String strategy = context.getOptions().get("openejb.client.connection.strategy", "default"); context.getClusterMetaData().setConnectionStrategy(strategy); Client.fireEvent(new RemoteInitialContextCreated(location)); if (userID != null) { if (!authWithRequest) { authenticate(userID, psswrd); } else { authenticationInfo = new AuthenticationInfo(String.class.cast(env.get("openejb.authentication.realmName")), userID, psswrd.toCharArray()); } } if (client == null) { client = new ClientMetaData(); } if (serializer != null) { try { client.setSerializer(EJBDSerializer.class.cast(Thread.currentThread().getContextClassLoader().loadClass(serializer).newInstance())); } catch (final Exception e) { } } final int queue = Integer.parseInt(getProperty(env, JNDIContext.POOL_QUEUE_SIZE, "2")); blockingQueue = new LinkedBlockingQueue<Runnable>((queue < 2 ? 2 : queue)); threads = Integer.parseInt(getProperty(env, "openejb.client.invoker.threads", "-1")); return this; } JNDIContext();  JNDIContext(final JNDIContext that); static ThreadPoolExecutor globalExecutor(); static ThreadPoolExecutor newExecutor(final int threads, final BlockingQueue<Runnable> blockingQueue); @Override Context getInitialContext(final Hashtable environment); void authenticate(final String userID, final String psswrd); EJBHomeProxy createEJBHomeProxy(final EJBMetaDataImpl ejbData); @Override Object lookup(String name); @Override Object lookup(final Name name); @SuppressWarnings("unchecked") @Override NamingEnumeration<NameClassPair> list(String name); @Override NamingEnumeration<NameClassPair> list(final Name name); @SuppressWarnings("unchecked") @Override NamingEnumeration<Binding> listBindings(final String name); @Override NamingEnumeration<Binding> listBindings(final Name name); @Override Object lookupLink(final String name); @Override Object lookupLink(final Name name); @Override NameParser getNameParser(final String name); @Override NameParser getNameParser(final Name name); @Override String composeName(final String name, final String prefix); @Override Name composeName(final Name name, final Name prefix); @SuppressWarnings("unchecked") @Override Object addToEnvironment(final String key, final Object value); @Override Object removeFromEnvironment(final String key); @Override Hashtable getEnvironment(); @Override String getNameInNamespace(); @Override void close(); @Override void bind(final String name, final Object obj); @Override void bind(final Name name, final Object obj); @Override void rebind(final String name, final Object obj); @Override void rebind(final Name name, final Object obj); @Override void unbind(final String name); @Override void unbind(final Name name); @Override void rename(final String oldname, final String newname); @Override void rename(final Name oldname, final Name newname); @Override void destroySubcontext(final String name); @Override void destroySubcontext(final Name name); @Override Context createSubcontext(final String name); @Override Context createSubcontext(final Name name); }
JNDIContext implements InitialContextFactory, Context { @Override public Context getInitialContext(final Hashtable environment) throws NamingException { if (environment == null) { throw new NamingException("Invalid argument, hashtable cannot be null."); } else { env = decipher((Hashtable) environment.clone()); } final String userID = (String) env.get(Context.SECURITY_PRINCIPAL); final String psswrd = (String) env.get(Context.SECURITY_CREDENTIALS); String providerUrl = (String) env.get(Context.PROVIDER_URL); final String serializer = (String) env.get(SERIALIZER); final boolean authWithRequest = "true".equalsIgnoreCase(String.class.cast(env.get(AUTHENTICATE_WITH_THE_REQUEST))); moduleId = (String) env.get("openejb.client.moduleId"); final URI location; try { providerUrl = addMissingParts(providerUrl); location = new URI(providerUrl); } catch (URISyntaxException e) { throw (ConfigurationException) new ConfigurationException("Property value for " + Context.PROVIDER_URL + " invalid: " + providerUrl + " - " + e.getMessage()).initCause(e); } this.server = new ServerMetaData(location); final Client.Context context = Client.getContext(this.server); context.getProperties().putAll(environment); final String strategy = context.getOptions().get("openejb.client.connection.strategy", "default"); context.getClusterMetaData().setConnectionStrategy(strategy); Client.fireEvent(new RemoteInitialContextCreated(location)); if (userID != null) { if (!authWithRequest) { authenticate(userID, psswrd); } else { authenticationInfo = new AuthenticationInfo(String.class.cast(env.get("openejb.authentication.realmName")), userID, psswrd.toCharArray()); } } if (client == null) { client = new ClientMetaData(); } if (serializer != null) { try { client.setSerializer(EJBDSerializer.class.cast(Thread.currentThread().getContextClassLoader().loadClass(serializer).newInstance())); } catch (final Exception e) { } } final int queue = Integer.parseInt(getProperty(env, JNDIContext.POOL_QUEUE_SIZE, "2")); blockingQueue = new LinkedBlockingQueue<Runnable>((queue < 2 ? 2 : queue)); threads = Integer.parseInt(getProperty(env, "openejb.client.invoker.threads", "-1")); return this; } JNDIContext();  JNDIContext(final JNDIContext that); static ThreadPoolExecutor globalExecutor(); static ThreadPoolExecutor newExecutor(final int threads, final BlockingQueue<Runnable> blockingQueue); @Override Context getInitialContext(final Hashtable environment); void authenticate(final String userID, final String psswrd); EJBHomeProxy createEJBHomeProxy(final EJBMetaDataImpl ejbData); @Override Object lookup(String name); @Override Object lookup(final Name name); @SuppressWarnings("unchecked") @Override NamingEnumeration<NameClassPair> list(String name); @Override NamingEnumeration<NameClassPair> list(final Name name); @SuppressWarnings("unchecked") @Override NamingEnumeration<Binding> listBindings(final String name); @Override NamingEnumeration<Binding> listBindings(final Name name); @Override Object lookupLink(final String name); @Override Object lookupLink(final Name name); @Override NameParser getNameParser(final String name); @Override NameParser getNameParser(final Name name); @Override String composeName(final String name, final String prefix); @Override Name composeName(final Name name, final Name prefix); @SuppressWarnings("unchecked") @Override Object addToEnvironment(final String key, final Object value); @Override Object removeFromEnvironment(final String key); @Override Hashtable getEnvironment(); @Override String getNameInNamespace(); @Override void close(); @Override void bind(final String name, final Object obj); @Override void bind(final Name name, final Object obj); @Override void rebind(final String name, final Object obj); @Override void rebind(final Name name, final Object obj); @Override void unbind(final String name); @Override void unbind(final Name name); @Override void rename(final String oldname, final String newname); @Override void rename(final Name oldname, final Name newname); @Override void destroySubcontext(final String name); @Override void destroySubcontext(final Name name); @Override Context createSubcontext(final String name); @Override Context createSubcontext(final Name name); static final String DEFAULT_PROVIDER_URL; static final String SERIALIZER; static final String AUTHENTICATE_WITH_THE_REQUEST; static final String POOL_QUEUE_SIZE; static final String POOL_THREAD_NUMBER; }