1 29 30 package com.caucho.iiop; 31 32 import com.caucho.log.Log; 33 import com.caucho.management.j2ee.J2EEManagedObject; 34 import com.caucho.management.j2ee.RMI_IIOPResource; 35 import com.caucho.server.connection.Connection; 36 import com.caucho.server.port.Protocol; 37 import com.caucho.server.port.ServerRequest; 38 39 import java.util.logging.Logger ; 40 41 49 public class IiopProtocol extends Protocol { 50 private static final Logger log = Log.open(IiopProtocol.class); 51 52 static final String COPYRIGHT = 53 "Copyright (c) 1998-2006 Caucho Technology. All rights reserved."; 54 55 private String _protocolName = "iiop"; 56 private CosServer _cos; 57 58 private IiopContext _iiopContext; 59 60 63 public IiopProtocol() 64 { 65 _iiopContext = new IiopContext(); 66 67 _cos = new CosServer(this); 68 69 IiopContext.setLocalContext(_iiopContext); 70 } 71 72 75 public String getProtocolName() 76 { 77 return _protocolName; 78 } 79 80 83 public void setProtocolName(String name) 84 { 85 _protocolName = name; 86 } 87 88 public void init() 89 { 90 J2EEManagedObject.register(new RMI_IIOPResource(this)); 91 92 } 93 94 public CosServer getCos() 95 { 96 return _cos; 97 } 98 99 public IiopSkeleton getService(String host, int port, String oid) 100 { 101 return lookupService(host, port, oid); 102 } 103 104 107 private IiopSkeleton lookupService(String host, int port, String oid) 108 { 109 String url; 110 String local; 111 112 int p = oid.indexOf('?'); 113 114 if (p < 0) { 115 url = oid; 116 local = null; 117 } 118 else { 119 url = oid.substring(0, p); 120 local = oid.substring(p + 1); 121 } 122 123 IiopRemoteService service = _iiopContext.getService(url); 124 125 if (service == null) 126 return null; 127 else if (local == null) { 128 return new IiopSkeleton(service.getHome(), 129 service.getHomeAPI(), 130 service.getClassLoader(), 131 host, port, url); 132 } 133 else { 134 Object obj = service.getObject(local); 135 136 if (obj == null) 137 return null; 138 139 return new IiopSkeleton(obj, service.getObjectAPI(), 140 service.getClassLoader(), 141 host, port, url + '?' + local); 142 } 143 } 144 145 148 public ServerRequest createRequest(Connection conn) 149 { 150 return new IiopRequest(this, conn); 151 } 152 } 153 | Popular Tags |