1 18 package org.apache.geronimo.interop.adapter; 19 20 import org.apache.geronimo.interop.rmi.iiop.RemoteInterface; 21 import org.apache.geronimo.interop.rmi.iiop.ObjectRef; 22 import org.apache.geronimo.interop.naming.NameService; 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 public class CorbaAdapter extends Adapter { 27 28 private final Log log = LogFactory.getLog(CorbaAdapter.class); 29 30 private ClassLoader classLoader; 31 32 private NameService nameService = NameService.getInstance(); 33 34 private String bindNames[]; 35 private String ids[]; 36 private String remoteClassName; 37 private String remoteInterfaceClassName; 38 39 private Class remoteClassClass; 40 private Class remoteInterfaceClass; 41 private RemoteInterface remoteInterfaceObject; 42 private Object remoteClassObject; 43 44 public CorbaAdapter( String [] bindNames, String [] ids, String remoteClassName, 45 String remoteInterfaceName, ClassLoader classLoader ) { 46 this.bindNames = bindNames; 47 this.ids = ids; 48 this.remoteClassName = remoteClassName; 49 this.remoteInterfaceClassName = remoteInterfaceName; 50 this.classLoader = classLoader; 51 52 this.remoteInterfaceClassName += "_Skeleton"; 53 54 loadRemoteInterface(); 55 loadRemoteObject(); 56 } 57 58 public Object getAdapterID() 59 { 60 return "CorbaAdapter"; 61 } 62 63 67 public String [] getBindNames() { 68 return bindNames; 69 } 70 71 75 public ClassLoader getClassLoader() { 76 return classLoader; 77 } 78 79 83 public void setClassLoader(ClassLoader cl) { 84 this.classLoader = cl; 85 } 86 87 94 public void invoke(java.lang.String methodName, byte[] objectKey, org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { 95 if (remoteInterfaceObject != null) { 96 remoteInterfaceObject.invoke(methodName, objectKey, this, input, output); 97 } else { 98 throw new org.omg.CORBA.OBJECT_NOT_EXIST (new String (objectKey)); 99 } 100 } 101 102 public void start() 103 { 104 log.info( "Starting CorbaAdapter: " ); 105 nameService.bindAdapter( this ); 106 } 107 108 public void stop() 109 { 110 log.info( "Stopping CorbaAdapter: " ); 111 nameService.unbindAdapter( this ); 112 } 113 114 public ObjectRef getObjectRef() 115 { 116 return remoteInterfaceObject.getObjectRef(); 117 } 122 123 protected void loadRemoteInterface() 124 { 125 remoteInterfaceClass = loadClass( remoteInterfaceClassName, classLoader ); 126 127 if (remoteInterfaceClass != null) 128 { 129 remoteInterfaceObject = null; 130 try { 131 remoteInterfaceObject = (RemoteInterface)remoteInterfaceClass.newInstance(); 132 } catch (IllegalAccessException e) { 133 e.printStackTrace(); 134 } catch (InstantiationException e) { 135 e.printStackTrace(); 136 } 137 } 138 } 139 140 protected void loadRemoteObject() 141 { 142 remoteClassClass = loadClass( remoteClassName, classLoader ); 143 144 if (remoteClassClass != null) 145 { 146 remoteClassObject = null; 147 try { 148 remoteClassObject = remoteClassClass.newInstance(); 149 } catch (IllegalAccessException e) { 150 e.printStackTrace(); 151 } catch (InstantiationException e) { 152 e.printStackTrace(); 153 } 154 } 155 } 156 157 public Object getServant() 158 { 159 return remoteClassObject; 160 } 161 162 public Object getEJBContainer() 163 { 164 return null; } 166 167 public Object getEJBHome() 168 { 169 return null; } 171 172 } 173 | Popular Tags |