FileDocCategorySizeDatePackage
MultiplexerContext.javaAPI DocJBoss 4.2.17814Fri Jul 13 20:53:48 BST 2007org.jboss.ejb3.naming

MultiplexerContext

public class MultiplexerContext extends Object implements Context, Serializable
A context which combines two contexts. Read operations are combined, write operations are done on the first context. All other operations are not supported.
author
Carlo de Wolf
version
$Revision: $

Fields Summary
private static final long
serialVersionUID
private static final Logger
log
private Context
contextOne
private Context
contextTwo
Constructors Summary
public MultiplexerContext(Context contextOne, Context contextTwo)


         
   
      assert contextOne != null;
      assert contextTwo != null;
      
      this.contextOne = contextOne;
      this.contextTwo = contextTwo;
   
Methods Summary
private voidaddAll(java.util.Collection collection, javax.naming.NamingEnumeration ne)

      // TODO: how about duplicates?
      while(ne.hasMore())
      {
         T ncp = ne.next();
         collection.add(ncp);
      }
   
public java.lang.ObjectaddToEnvironment(java.lang.String propName, java.lang.Object propVal)

      throw new OperationNotSupportedException();
   
public voidbind(javax.naming.Name name, java.lang.Object obj)

      log.trace("bind: " + name + " -> " +obj);
      getContextOne().bind(name, obj);  
   
public voidbind(java.lang.String name, java.lang.Object obj)

      log.trace("bind: " + name + " -> " +obj);
      getContextOne().bind(name, obj);
   
public voidclose()

      // do nothing
   
public javax.naming.NamecomposeName(javax.naming.Name name, javax.naming.Name prefix)

      return getContextOne().composeName(name, prefix);
   
public java.lang.StringcomposeName(java.lang.String name, java.lang.String prefix)

      return getContextOne().composeName(name, prefix);
   
public javax.naming.ContextcreateSubcontext(java.lang.String name)

      return getContextOne().createSubcontext(name);
   
public javax.naming.ContextcreateSubcontext(javax.naming.Name name)

      return getContextOne().createSubcontext(name);
   
public voiddestroySubcontext(javax.naming.Name name)

      getContextOne().destroySubcontext(name);
   
public voiddestroySubcontext(java.lang.String name)

      getContextOne().destroySubcontext(name);
   
private javax.naming.ContextgetContextOne()

      return contextOne;
   
private javax.naming.ContextgetContextTwo()

      return contextTwo;
   
public java.util.HashtablegetEnvironment()

      throw new UnsupportedOperationException();
   
public java.lang.StringgetNameInNamespace()

      throw new UnsupportedOperationException();
   
public javax.naming.NameParsergetNameParser(javax.naming.Name name)

      return getContextOne().getNameParser(name);
   
public javax.naming.NameParsergetNameParser(java.lang.String name)

      return getContextOne().getNameParser(name);
   
public javax.naming.NamingEnumerationlist(javax.naming.Name name)

      Collection<NameClassPair> set = new ArrayList<NameClassPair>();
      addAll(set, getContextOne().list(name));
      addAll(set, getContextTwo().list(name));
      return new NamingEnumerationImpl<NameClassPair>(set);
   
public javax.naming.NamingEnumerationlist(java.lang.String name)

      Collection<NameClassPair> set = new ArrayList<NameClassPair>();
      addAll(set, getContextOne().list(name));
      addAll(set, getContextTwo().list(name));
      return new NamingEnumerationImpl<NameClassPair>(set);
   
public javax.naming.NamingEnumerationlistBindings(javax.naming.Name name)

      Collection<Binding> set = new ArrayList<Binding>();
      addAll(set, getContextOne().listBindings(name));
      addAll(set, getContextTwo().listBindings(name));
      return new NamingEnumerationImpl<Binding>(set);
   
public javax.naming.NamingEnumerationlistBindings(java.lang.String name)

      Collection<Binding> set = new ArrayList<Binding>();
      addAll(set, getContextOne().listBindings(name));
      addAll(set, getContextTwo().listBindings(name));
      return new NamingEnumerationImpl<Binding>(set);
   
public java.lang.Objectlookup(javax.naming.Name name)

      log.trace("lookup: " + name);
      try
      {
         return getContextOne().lookup(name);
      }
      catch(NamingException e)
      {
         return getContextTwo().lookup(name);
      }
   
public java.lang.Objectlookup(java.lang.String name)

      log.trace("lookup: " + name);
      try
      {
         return getContextOne().lookup(name);
      }
      catch(NamingException e)
      {
         return getContextTwo().lookup(name);
      }
   
public java.lang.ObjectlookupLink(javax.naming.Name name)

      try
      {
         return getContextOne().lookupLink(name);
      }
      catch(NamingException e)
      {
         return getContextTwo().lookupLink(name);
      }
   
public java.lang.ObjectlookupLink(java.lang.String name)

      try
      {
         return getContextOne().lookupLink(name);
      }
      catch(NamingException e)
      {
         return getContextTwo().lookupLink(name);
      }
   
public voidrebind(javax.naming.Name name, java.lang.Object obj)

      getContextOne().rebind(name, obj);
   
public voidrebind(java.lang.String name, java.lang.Object obj)

      getContextOne().rebind(name, obj);
   
public java.lang.ObjectremoveFromEnvironment(java.lang.String propName)

      throw new UnsupportedOperationException();
   
public voidrename(javax.naming.Name oldName, javax.naming.Name newName)

      getContextOne().rename(oldName, newName);
   
public voidrename(java.lang.String oldName, java.lang.String newName)

      getContextOne().rename(oldName, newName);
   
public voidunbind(javax.naming.Name name)

      getContextOne().unbind(name);
   
public voidunbind(java.lang.String name)

      getContextOne().unbind(name);