1 28 package org.objectweb.carol.rmi.multi; 29 30 import java.rmi.NoSuchObjectException ; 31 import java.rmi.Remote ; 32 import java.rmi.RemoteException ; 33 import java.rmi.server.RemoteObject ; 34 import java.util.Properties ; 35 36 import javax.rmi.CORBA.PortableRemoteObjectDelegate ; 37 38 import org.objectweb.carol.rmi.jrmp.interceptor.JClientRequestInterceptor; 39 import org.objectweb.carol.rmi.jrmp.interceptor.JInterceptorStore; 40 import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInterceptor; 41 import org.objectweb.carol.rmi.jrmp.server.JUnicastRemoteObject; 42 import org.objectweb.carol.rmi.util.PortNumber; 43 import org.objectweb.carol.util.configuration.CarolDefaultValues; 44 import org.objectweb.carol.util.configuration.ConfigurationRepository; 45 46 50 public class JrmpPRODelegate implements PortableRemoteObjectDelegate { 51 52 55 private int port; 56 57 60 private JServerRequestInterceptor[] sis = null; 61 62 65 private JClientRequestInterceptor[] cis = null; 66 67 71 public JrmpPRODelegate(boolean usingCmi) { 72 sis = JInterceptorStore.getLocalServerInterceptors(); 73 cis = JInterceptorStore.getLocalClientInterceptors(); 74 Properties prop = ConfigurationRepository.getProperties(); 75 if (!usingCmi && prop != null) { 76 String propertyName = CarolDefaultValues.SERVER_JRMP_PORT; 77 this.port = PortNumber.strToint(prop.getProperty(propertyName, "0"), propertyName); 78 } 79 } 80 81 84 public JrmpPRODelegate() { 85 this(false); 86 } 87 88 95 public void exportObject(Remote obj) throws RemoteException { 96 JUnicastRemoteObject.exportObject(obj, port, sis, cis); 97 } 98 99 106 public void unexportObject(Remote obj) throws NoSuchObjectException { 107 JUnicastRemoteObject.unexportObject(obj, true); 108 } 109 110 122 public void connect(Remote target, Remote source) throws RemoteException { 123 } 125 126 134 public Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException { 135 if (narrowTo.isAssignableFrom(narrowFrom.getClass())) { 136 return narrowFrom; 137 } else { 138 throw new ClassCastException ("Cannot cast '" + narrowFrom.getClass().getName() + "' in '" 139 + narrowTo.getName() + "'."); 140 } 141 } 142 143 152 public Remote toStub(Remote obj) throws NoSuchObjectException { 153 return RemoteObject.toStub(obj); 154 } 155 } | Popular Tags |