1 31 package org.objectweb.proactive.core.runtime.ibis; 32 33 import org.apache.log4j.Logger; 34 35 import org.objectweb.proactive.core.ProActiveException; 36 import org.objectweb.proactive.core.rmi.ClassServerHelper; 37 import org.objectweb.proactive.core.rmi.RegistryHelper; 38 import org.objectweb.proactive.core.runtime.ProActiveRuntime; 39 import org.objectweb.proactive.core.runtime.RuntimeFactory; 40 import org.objectweb.proactive.core.util.IbisProperties; 41 import org.objectweb.proactive.core.util.UrlBuilder; 42 43 44 public class RemoteRuntimeFactory extends RuntimeFactory { 45 protected static Logger logger = Logger.getLogger(RemoteRuntimeFactory.class.getName()); 46 47 static { 48 IbisProperties.load(); 49 } 50 51 protected static RegistryHelper registryHelper = new RegistryHelper(); 54 protected static ClassServerHelper classServerHelper = new ClassServerHelper(); 55 private static ProActiveRuntime defaultRmiRuntime = null; 56 57 public RemoteRuntimeFactory() throws java.io.IOException { 61 if ((System.getSecurityManager() == null) && 62 !("false".equals(System.getProperty("proactive.securitymanager")))) { 63 System.setSecurityManager(new java.rmi.RMISecurityManager ()); 64 } 65 66 registryHelper.initializeRegistry(); 67 } 68 69 public static void setClassServerClasspath(String v) { 73 classServerHelper.setClasspath(v); 74 } 75 76 public static void setShouldCreateClassServer(boolean v) { 77 classServerHelper.setShouldCreateClassServer(v); 78 } 79 80 public static void setRegistryPortNumber(int v) { 81 registryHelper.setRegistryPortNumber(v); 82 } 83 84 public static void setShouldCreateRegistry(boolean v) { 85 registryHelper.setShouldCreateRegistry(v); 86 } 87 88 protected synchronized ProActiveRuntime getProtocolSpecificRuntimeImpl() 95 throws ProActiveException { 96 if (defaultRmiRuntime == null) { 98 defaultRmiRuntime = createRuntimeAdapter(); 99 } 100 101 return defaultRmiRuntime; 102 } 103 104 protected ProActiveRuntime getRemoteRuntimeImpl(String s) 105 throws ProActiveException { 106 if (logger.isDebugEnabled()) { 108 logger.debug("looking for " + s); 109 } 110 try { 111 RemoteProActiveRuntime remoteProActiveRuntime = (RemoteProActiveRuntime) ibis.rmi.Naming.lookup(UrlBuilder.removeProtocol(s,"ibis:")); 112 if (logger.isDebugEnabled()) { 113 logger.debug(remoteProActiveRuntime.getClass().getName()); 114 } 115 return createRuntimeAdapter(remoteProActiveRuntime); 116 } catch (ibis.rmi.RemoteException e) { 117 throw new ProActiveException("Remote", e); 118 } catch (ibis.rmi.NotBoundException e) { 119 throw new ProActiveException("NotBound", e); 120 } catch (java.net.MalformedURLException e) { 121 throw new ProActiveException("Malformed URL:" + s, e); 122 } 123 } 124 125 protected RemoteProActiveRuntimeAdapter createRuntimeAdapter( 126 RemoteProActiveRuntime remoteProActiveRuntime) 127 throws ProActiveException { 128 return new RemoteProActiveRuntimeAdapter(remoteProActiveRuntime); 129 } 130 131 protected RemoteProActiveRuntimeAdapter createRuntimeAdapter() 132 throws ProActiveException { 133 return new RemoteProActiveRuntimeAdapter(); 134 } 135 136 protected static RegistryHelper getRegistryHelper() { 137 return registryHelper; 138 } 139 140 } 144 | Popular Tags |