1 package org.objectweb.jac.aspects.distribution; 2 3 4 import org.aopalliance.intercept.ConstructorInvocation; 5 import org.aopalliance.intercept.MethodInvocation; 6 import org.apache.log4j.Logger; 7 import org.objectweb.jac.core.AspectComponent; 8 import org.objectweb.jac.core.Interaction; 9 import org.objectweb.jac.core.Wrapper; 10 import org.objectweb.jac.core.dist.Deployment; 11 import org.objectweb.jac.core.dist.Topology; 12 import org.objectweb.jac.util.Log; 13 14 17 18 public class DeploymentWrapper extends Wrapper { 19 static Logger logger = Logger.getLogger("deployment"); 20 21 String hostExpr; 22 boolean state = true; 23 24 32 33 public DeploymentWrapper( 34 AspectComponent ac, 35 String hostExpr, 36 Boolean state) { 37 super(ac); 38 this.hostExpr = hostExpr; 39 this.state = state.booleanValue(); 40 } 41 42 public Object invoke(MethodInvocation invocation) throws Throwable { 43 throw new Exception ("This wrapper does not support invocation wrapping"); 44 } 45 46 public Object construct(ConstructorInvocation invocation) 47 throws Throwable 48 { 49 return deploy((Interaction) invocation); 50 } 51 52 55 56 public Object deploy(Interaction i) { 57 Object o = proceed(i); 58 logger.debug("deploy upcalled with " + hostExpr 59 + " wrappee=" + i.wrappee 60 + ", topology=" + Topology.get()); 61 Topology topology = Topology.getPartialTopology(hostExpr); 62 Deployment dep = new Deployment(ac, topology); 63 if (state) { 64 dep.replicate(i.wrappee); 65 } else { 66 dep.replicateStruct(i.wrappee); 67 } 68 return o; 69 } 70 } 71 | Popular Tags |