1 22 package org.jboss.ha.jndi; 23 24 import java.util.Collection ; 25 26 import javax.naming.Name ; 27 import javax.naming.NamingException ; 28 29 import org.jnp.interfaces.Naming; 30 31 import org.jboss.cache.Fqn; 32 import org.jboss.cache.Cache; 33 import org.jboss.ha.framework.interfaces.HAPartition; 34 import org.jboss.logging.Logger; 35 36 44 public class HAJNDI 45 implements org.jnp.interfaces.Naming 46 { 47 48 static final long serialVersionUID = -6277328603304171620L; 49 50 public static final String ROOT = "__HA_JNDI__"; 51 public static final Fqn ROOTFQN = new Fqn(new Object [] { ROOT }); 52 53 private static Logger log = Logger.getLogger(HAJNDI.class); 55 56 protected HAPartition partition; 57 protected TreeHead delegate; 58 protected Naming haStub; 59 60 62 public HAJNDI(HAPartition partition, Cache cache) 63 throws NamingException 64 { 65 if (partition == null) 66 throw new IllegalArgumentException ("Null partition"); 67 if (cache == null) 68 throw new IllegalArgumentException ("Null cache"); 69 this.partition = partition; 70 delegate = new TreeHead(cache, HAJNDI.ROOTFQN); 71 delegate.setPartition(this.partition); 72 delegate.setHARMIHead(this); 73 74 } 75 76 78 public void init() throws Exception 79 { 80 delegate.init(); 81 } 82 83 public void stop() throws Exception 84 { 85 delegate.stop(); 86 } 87 88 public void destroy() throws Exception 89 { 90 delegate.destroy(); 91 } 92 93 public void setHAStub (Naming stub) 94 { 95 this.haStub = stub; 96 } 97 98 public Naming getHAStub () 99 { 100 return this.haStub; 101 } 102 103 105 106 public synchronized void bind(Name name, Object obj, String className) 107 throws NamingException 108 { 109 delegate.bind (name, obj, className); 110 } 111 112 public synchronized void rebind(Name name, Object obj, String className) 113 throws NamingException 114 { 115 delegate.rebind (name, obj, className); 116 } 117 118 public synchronized void unbind(Name name) 119 throws NamingException 120 { 121 delegate.unbind (name); 122 } 123 124 public Object lookup(Name name) 125 throws NamingException 126 { 127 return delegate.lookup (name); 128 } 129 130 public Collection list(Name name) 131 throws NamingException 132 { 133 return delegate.list(name) ; 134 } 135 136 public Collection listBindings(Name name) 137 throws NamingException 138 { 139 return delegate.listBindings(name); 140 } 141 142 public javax.naming.Context createSubcontext(Name name) 143 throws NamingException 144 { 145 return delegate.createSubcontext(name); 146 } 147 } 148 | Popular Tags |