SharedComponentList implements ComponentLifecycle, ComponentLifecycleExtension { public void bindJNDI(String componentId) throws CoreException { Collection<AdaptrisComponent> comps = all(); String id = Args.notNull(componentId, "componentId"); for (AdaptrisComponent c : comps) { if (id.equals(c.getUniqueId())) { bind(getContext(), c, isDebug()); break; } } } SharedComponentList(); List<AdaptrisConnection> getConnections(); void setConnections(List<AdaptrisConnection> l); List<Service> getServices(); void setServices(List<Service> serviceLists); @Override void init(); @Override void start(); @Override void stop(); @Override void close(); @Override void prepare(); void bindJNDI(String componentId); Collection<String> getConnectionIds(); Collection<String> getServiceIds(); boolean addService(Service c); Collection<Service> addServices(Collection<Service> coll); boolean addConnection(AdaptrisConnection c); Collection<AdaptrisConnection> addConnections(Collection<AdaptrisConnection> coll); Collection<AdaptrisConnection> removeConnection(String id); Collection<Service> removeService(String id); boolean containsConnection(String id); boolean containsService(String id); Boolean getDebug(); void setDebug(Boolean debug); SharedComponentLifecycleStrategy getLifecycleStrategy(); void setLifecycleStrategy(SharedComponentLifecycleStrategy ls); TransactionManager getTransactionManager(); void setTransactionManager(TransactionManager tm);  }
@Test public void testBindJNDI() throws Exception { Adapter adapter = new Adapter(); adapter.setUniqueId(getName()); Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, JndiContextFactory.class.getName()); InitialContext initialContext = new InitialContext(env); try { start(adapter); adapter.getSharedComponents().addConnection(new NullConnection(getName())); adapter.getSharedComponents().bindJNDI(getName()); NullConnection lookedup = (NullConnection) initialContext.lookup("adapter:comp/env/" + getName()); assertNotNull(lookedup); assertEquals(getName(), lookedup.getUniqueId()); adapter.getSharedComponents().bindJNDI("ShouldGetIgnored"); } finally { stop(adapter); } }