1 17 18 package org.objectweb.jac.aspects.distribution.consistency; 19 20 import java.util.*; 21 import org.apache.log4j.Logger; 22 import org.objectweb.jac.core.*; 23 import org.objectweb.jac.core.dist.*; 24 import org.objectweb.jac.core.rtti.ClassRepository; 25 import org.objectweb.jac.util.*; 26 27 34 35 public class ClientServerConsistencyWrapper extends ConsistencyWrapper { 36 static Logger logger = Logger.getLogger("consistency"); 37 38 String hosts = null; 39 40 46 public ClientServerConsistencyWrapper(AspectComponent ac, String hosts) { 47 super(ac); 48 knownReplicas = null; 49 this.hosts = hosts; 50 } 51 52 53 public ClientServerConsistencyWrapper(AspectComponent ac) { 54 super(ac); 55 } 56 57 64 65 public Object whenCall(Interaction interaction) { 66 67 if( knownReplicas == null ) { 68 knownReplicas = Topology.getPartialTopology(hosts).getReplicas(interaction.wrappee); 69 } 70 71 if(knownReplicas != null && knownReplicas.size() > 0 && 72 (! ((RemoteRef)knownReplicas.get(0)).getRemCont().isLocal()) ) { 73 logger.debug("(client-server) call event on " + 74 NameRepository.get().getName(interaction.wrappee) + 75 ":" + interaction.method + ":" + 76 ((RemoteRef)knownReplicas.get(0)).getRemCont().getName()); 77 Object ret = ((RemoteRef)knownReplicas.get(0)).invokeRoleMethod( 78 "acceptRemoteCall", 79 new Object [] { null, new Object [] { interaction.method, interaction.args } } 80 ); 81 return ret; 82 } else { 83 84 return proceed(interaction); 85 } 86 } 87 88 94 95 public Object acceptRemoteCall(Wrappee wrappee, RemoteRef remoteReplica, 96 Object [] data) { 97 logger.debug("(client-server) remote call event on " + 98 NameRepository.get().getName(wrappee) + 99 ":" + (String )data[0] + ":" + 100 Arrays.asList((Object [])data[1])); 101 return ClassRepository.get().getClass(wrappee).getMethod((String )data[0]).invoke( 102 wrappee , (Object [])data[1] ); 103 } 104 } 105 | Popular Tags |