1 18 package org.apache.geronimo.interop.rmi.iiop.server; 19 20 import javax.naming.NameNotFoundException ; 21 import javax.naming.NamingException ; 22 23 import org.apache.geronimo.interop.adapter.Adapter; 24 import org.apache.geronimo.interop.naming.NameService; 25 import org.apache.geronimo.interop.naming.NameServiceLog; 26 import org.apache.geronimo.interop.rmi.iiop.CorbaObject; 27 import org.omg.CosNaming.BindingIteratorHolder ; 28 import org.omg.CosNaming.BindingListHolder ; 29 import org.omg.CosNaming.NameComponent ; 30 import org.omg.CosNaming.NamingContext ; 31 import org.omg.CosNaming.NamingContextExt ; 32 import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress ; 33 import org.omg.CosNaming.NamingContextPackage.AlreadyBound ; 34 import org.omg.CosNaming.NamingContextPackage.CannotProceed ; 35 import org.omg.CosNaming.NamingContextPackage.InvalidName ; 36 import org.omg.CosNaming.NamingContextPackage.NotFound ; 37 import org.omg.CosNaming.NamingContextPackage.NotFoundReason ; 38 import org.omg.CosNaming.NamingContextPackage.NotEmpty ; 39 40 public class ServerNamingContext extends CorbaObject implements NamingContextExt { 41 42 private NameService nameService; 43 protected static ServerNamingContext snc = null; 44 45 public ServerNamingContext() 46 { 47 nameService = NameService.getInstance(); 48 } 49 50 public org.omg.CORBA.Object resolve_str(String name) throws NotFound , CannotProceed , InvalidName { 51 return lookup(name, null); 52 } 53 54 public String to_string(NameComponent [] n) throws InvalidName { 55 throw NoImplement(); 56 } 57 58 public NameComponent [] to_name(String sn) throws InvalidName { 59 throw NoImplement(); 60 } 61 62 public String to_url(String addr, String sn) throws InvalidAddress , InvalidName { 63 throw NoImplement(); 64 } 65 66 public org.omg.CORBA.Object resolve(NameComponent [] name) throws NotFound , CannotProceed , InvalidName { 67 return lookup(toString(name), name); 68 } 69 70 public void bind(NameComponent [] n, org.omg.CORBA.Object obj) throws NotFound , CannotProceed , InvalidName , AlreadyBound { 71 throw NoImplement(); 72 } 73 74 public void bind_context(NameComponent [] n, NamingContext nc) throws NotFound , CannotProceed , InvalidName , AlreadyBound { 75 throw NoImplement(); 76 } 77 78 public void rebind(NameComponent [] n, org.omg.CORBA.Object obj) throws NotFound , CannotProceed , InvalidName { 79 throw NoImplement(); 80 } 81 82 public void rebind_context(NameComponent [] n, NamingContext nc) throws NotFound , CannotProceed , InvalidName { 83 throw NoImplement(); 84 } 85 86 public void unbind(NameComponent [] n) throws NotFound , CannotProceed , InvalidName { 87 throw NoImplement(); 88 } 89 90 public void list(int how_many, BindingListHolder bl, BindingIteratorHolder bi) { 91 throw NoImplement(); 92 } 93 94 public NamingContext new_context() { 95 throw NoImplement(); 96 } 97 98 public NamingContext bind_new_context(NameComponent [] n) throws NotFound , AlreadyBound , CannotProceed , InvalidName { 99 throw NoImplement(); 100 } 101 102 public void destroy() throws NotEmpty { 103 } 105 106 protected org.omg.CORBA.NO_IMPLEMENT NoImplement() { 107 return new org.omg.CORBA.NO_IMPLEMENT (); 108 } 109 110 protected org.omg.CORBA.Object lookup(String nameString, NameComponent [] name) throws NotFound { 111 try { 112 Object object = nameService.lookup(nameString); 113 114 if (object instanceof Adapter) { 115 Adapter a = (Adapter) object; 116 return a.getObjectRef(); 119 } else { 120 NameServiceLog.getInstance().warnObjectHasNoRemoteInterface(nameString, object.getClass().getName()); 121 throw new NotFound (NotFoundReason.not_object, name); 122 } 123 } catch (NameNotFoundException notFound) { 124 throw new NotFound (NotFoundReason.missing_node, name); 126 } catch (NamingException ex) { 127 NameServiceLog.getInstance().warnNameNotFound(nameString, ex); 128 throw new NotFound (NotFoundReason.missing_node, name); 129 } 130 } 131 132 protected String toString(NameComponent [] name) { 133 int n = name.length; 134 if (n == 1) { 135 return name[0].id; 136 } else { 137 StringBuffer nameBuffer = new StringBuffer (); 138 for (int i = 0; i < n; i++) { 139 if (i > 0) { 140 nameBuffer.append('/'); 141 } 142 nameBuffer.append(name[i].id); 143 if (name[i].kind.length() > 0) { 144 nameBuffer.append(",kind="); 145 nameBuffer.append(name[i].kind); 146 } 147 } 148 return nameBuffer.toString(); 149 } 150 } 151 } 152 | Popular Tags |