1 31 package org.objectweb.proactive.ext.mixedlocation; 32 33 import org.objectweb.proactive.core.ProActiveException; 34 import org.objectweb.proactive.core.ProActiveRuntimeException; 35 import org.objectweb.proactive.core.body.MetaObjectFactory; 36 import org.objectweb.proactive.core.body.ProActiveMetaObjectFactory; 37 import org.objectweb.proactive.core.body.RemoteBodyFactory; 38 import org.objectweb.proactive.core.body.UniversalBody; 39 import org.objectweb.proactive.core.body.ibis.IbisRemoteBodyAdapter; 40 import org.objectweb.proactive.core.body.migration.MigrationManager; 41 import org.objectweb.proactive.core.body.migration.MigrationManagerFactory; 42 import org.objectweb.proactive.core.body.request.Request; 43 import org.objectweb.proactive.core.body.request.RequestFactory; 44 import org.objectweb.proactive.core.mop.MethodCall; 45 import org.objectweb.proactive.ext.locationserver.LocationServer; 46 import org.objectweb.proactive.ext.locationserver.LocationServerFactory; 47 48 49 59 public class MixedLocationMetaObjectFactory extends ProActiveMetaObjectFactory { 60 private static MetaObjectFactory instance = null; 64 65 69 72 protected MixedLocationMetaObjectFactory() { 73 super(); 74 } 75 76 public static synchronized MetaObjectFactory newInstance() { 80 if (instance == null) { 81 instance = new MixedLocationMetaObjectFactory(); 82 } 83 return instance; 84 } 85 86 protected RequestFactory newRequestFactorySingleton() { 90 return new RequestWithMixedLocationFactory(); 91 } 92 93 protected MigrationManagerFactory newMigrationManagerFactorySingleton() { 94 return new MigrationManagerFactoryImpl(); 95 } 96 97 protected class RequestWithMixedLocationFactory implements RequestFactory, 101 java.io.Serializable { 102 transient private LocationServer server = LocationServerFactory.getLocationServer(); 103 104 public Request newRequest(MethodCall methodCall, 105 UniversalBody sourceBody, boolean isOneWay, long sequenceID) { 106 return new RequestWithMixedLocation(methodCall, sourceBody, 107 isOneWay, sequenceID, server); 108 } 109 } 110 111 protected static class MigrationManagerFactoryImpl 112 implements MigrationManagerFactory, java.io.Serializable { 113 public MigrationManager newMigrationManager() { 114 return new MigrationManagerWithMixedLocation(LocationServerFactory.getLocationServer()); 116 } 117 } 118 119 120 protected RemoteBodyFactory newRemoteBodyFactorySingleton() { 121 if ("ibis".equals(System.getProperty("proactive.communication.protocol"))) { 122 if (logger.isDebugEnabled()) { 123 logger.debug("Factory is ibis"); 124 } 125 return new RemoteIbisBodyFactoryImpl(); 126 } else { 127 if (logger.isDebugEnabled()) { 128 logger.debug("Factory is rmi"); 129 } 130 return new RemoteRmiBodyFactoryImpl(); 131 } 132 } 133 134 protected static class RemoteIbisBodyFactoryImpl 135 implements RemoteBodyFactory, java.io.Serializable { 136 public UniversalBody newRemoteBody(UniversalBody body) { 137 try { 138 return new IbisRemoteBodyAdapter(body); 140 } catch (ProActiveException e) { 141 throw new ProActiveRuntimeException("Cannot create Ibis Remote body adapter ", 142 e); 143 } 144 } 145 } 146 148 protected static class RemoteRmiBodyFactoryImpl implements RemoteBodyFactory, 149 java.io.Serializable { 150 public UniversalBody newRemoteBody(UniversalBody body) { 151 try { 152 return new org.objectweb.proactive.core.body.rmi.RemoteBodyAdapter(body); 153 } catch (ProActiveException e) { 154 throw new ProActiveRuntimeException("Cannot create Remote body adapter ", 155 e); 156 } 157 } 158 } 159 } 161 | Popular Tags |