1 28 29 package com.caucho.iiop; 30 31 import com.caucho.log.Log; 32 import com.caucho.naming.AbstractModel; 33 import com.caucho.naming.MemoryModel; 34 35 import org.omg.CosNaming.NameComponent ; 36 import org.omg.CosNaming.NamingContextPackage.CannotProceed ; 37 import org.omg.CosNaming.NamingContextPackage.InvalidName ; 38 import org.omg.CosNaming.NamingContextPackage.NotFound ; 39 import org.omg.CosNaming.NamingContextPackage.NotFoundReason ; 40 41 import javax.naming.NamingException ; 42 import java.util.logging.Level ; 43 import java.util.logging.Logger ; 44 45 public class CosServer { 46 private static final Logger log = Log.open(CosServer.class); 47 48 private IiopProtocol _iiopServer; 49 private String _host; 50 private int _port; 51 52 AbstractModel _model = new MemoryModel(); 53 54 CosServer(IiopProtocol iiopServer) 55 { 56 _iiopServer = iiopServer; 57 } 58 59 void setHost(String host) 60 { 61 _host = host; 62 } 63 64 void setPort(int port) 65 { 66 _port = port; 67 } 68 69 public org.omg.CORBA.Object resolve(NameComponent []n) 70 throws NotFound , CannotProceed , InvalidName 71 { 72 Object value = null; 73 String host = _host; 74 String uri = ""; 75 76 try { 77 if (log.isLoggable(Level.FINE)) { 78 String name = ""; 79 80 for (int i = 0; i < n.length; i++) 81 name += "/" + n[i].id; 82 83 log.fine("IIOP NameService lookup: " + name); 84 } 85 86 for (int i = 0; i < n.length; i++) { 87 String name = n[i].id; 88 String type = n[i].kind; 89 90 value = _model.lookup(name); 91 92 if (value != null) 93 continue; 94 95 107 uri += "/" + name; 108 } 109 110 IiopSkeleton skel; 111 112 if (value != null) { 113 } 114 else if (uri.equals("")) { 115 String oid = "/NameService"; 116 skel = _iiopServer.getService(_host, _port, oid); 117 118 return skel; 119 } 120 else if ((skel = _iiopServer.getService(_host, _port, uri)) != null) { 121 return skel; 122 } 123 } catch (NamingException e) { 124 log.log(Level.FINE, e.toString(), e); 125 126 throw new NotFound (NotFoundReason.from_int(NotFoundReason._missing_node), n); 127 } 128 129 log.fine("IIOP COS NotFound: " + uri); 130 131 throw new NotFound (NotFoundReason.from_int(NotFoundReason._missing_node), n); 132 } 133 } 134 | Popular Tags |