[jboss-user] [Microcontainer] - Re: How do I programmatically declare a JNDI name dependency

alesj do-not-reply at jboss.com
Wed Aug 29 07:55:14 EDT 2007


  | /**
  |  * JNDI aware KernelRegistryPlugin.
  |  * 
  |  * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
  |  */
  | public class JNDIKernelRegistryPlugin implements KernelRegistryPlugin
  | {
  |    private Hashtable properties;
  |    private Context context;
  | 
  |    public void setProperties(Hashtable properties)
  |    {
  |       this.properties = properties;
  |    }
  | 
  |    public void create() throws NamingException
  |    {
  |       if (properties != null)
  |          context = new InitialContext(properties);
  |       else
  |          context = new InitialContext();
  |    }
  |    
  |    public void destroy() throws NamingException
  |    {
  |       if (context != null)
  |          context.close();
  |       context = null;
  |    }
  |    
  |    public KernelRegistryEntry getEntry(Object name)
  |    {
  |       try
  |       {
  |          Object target = context.lookup(name.toString());
  |          return new AbstractKernelRegistryEntry(name, target);
  |       }
  |       catch (NamingException e)
  |       {
  |       }
  |       return null;
  |    }
  | }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079108#4079108

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079108



More information about the jboss-user mailing list