1 29 30 package com.caucho.ejb.protocol; 31 32 import com.caucho.config.ConfigException; 33 import com.caucho.ejb.AbstractServer; 34 import com.caucho.iiop.IiopContext; 35 import com.caucho.iiop.IiopRemoteService; 36 import com.caucho.util.L10N; 37 38 import javax.ejb.EJBHome ; 39 import java.util.logging.Logger ; 40 41 46 public class IiopProtocolContainer extends ProtocolContainer { 47 private static final Logger log 48 = Logger.getLogger(IiopProtocolContainer.class.getName()); 49 private static final L10N L = new L10N(IiopProtocolContainer.class); 50 51 private IiopContext _context; 52 53 private IiopProtocolContainer(IiopContext context) 54 { 55 _context = context; 56 } 57 58 61 public static IiopProtocolContainer createProtocolContainer() 62 { 63 IiopContext context = IiopContext.getLocalContext(); 64 65 if (context != null) 66 return new IiopProtocolContainer(context); 67 else 68 return null; 69 } 70 71 74 public static EJBHome findRemoteEJB(String ejbName) 75 { 76 IiopContext context = IiopContext.getLocalContext(); 77 78 if (context == null) 79 return null; 80 81 if (! ejbName.startsWith("/")) 82 ejbName = "/" + ejbName; 83 84 IiopRemoteService service = context.getService(ejbName); 85 86 if (service != null) 87 return (EJBHome ) service.getHome(); 88 else 89 return null; 90 } 91 92 public String getName() 93 { 94 return "iiop"; 95 } 96 97 100 @Override 101 public void addServer(AbstractServer server) 102 { 103 if (server.getRemoteObject() == null) 104 return; 105 106 String name = getName(server); 107 108 log.fine("iiop: add server " + name); 109 110 EjbIiopRemoteService service = new EjbIiopRemoteService(server); 111 112 _context.setService(name, service); 113 } 114 115 private String getName(AbstractServer server) 116 { 117 String name = server.getProtocolId(); 118 if (name == null) 119 name = server.getEJBName(); 120 121 if (! name.startsWith("/")) 122 name = "/" + name; 123 124 return name; 125 } 126 127 130 public void removeServer(AbstractServer server) 131 { 132 if (server.getRemoteObject() == null) 133 return; 134 135 String name = getName(server); 136 137 _context.removeService(name); 138 } 139 140 protected HandleEncoder createHandleEncoder(AbstractServer server, 141 Class primaryKeyClass) 142 throws ConfigException 143 { 144 String name = getName(server); 145 146 if (_urlPrefix != null) 147 return new HandleEncoder(server, _urlPrefix + name); 148 else 149 return new HandleEncoder(server, name); 150 } 151 152 155 public Skeleton getSkeleton(String uri, String queryString) 156 throws Exception 157 { 158 throw new UnsupportedOperationException (); 159 } 160 } 161 | Popular Tags |