1 17 18 package org.objectweb.jac.aspects.distribution; 19 20 21 import java.util.*; 22 import org.apache.log4j.Logger; 23 import org.objectweb.jac.core.*; 24 import org.objectweb.jac.core.dist.*; 25 import org.objectweb.jac.util.*; 26 27 40 41 public class RemoteAccessAC extends AspectComponent implements RemoteAccessConf { 42 static Logger logger = Logger.getLogger("remoteaccess"); 43 static Logger loggerSerial = Logger.getLogger("serialization"); 44 45 public void whenSerialized ( SerializedJacObject finalObject ) { 46 47 loggerSerial.debug("DeploymentAC.whenSerialize"); 48 NameRepository nr = (NameRepository) NameRepository.get(); 49 Wrappee orgObject = (Wrappee)attr( "orgObject" ); 50 String name = nr.getName( orgObject ); 51 loggerSerial.debug(name + " is not matching any rule"); 53 finalObject.disableForwarding(); 54 Object [] state = ObjectState.getState(orgObject); 55 String [] fieldsName = (String []) state[0]; 56 Object [] fieldsValue = (Object []) state[1]; 57 58 for ( int i = 0; i < fieldsName.length; i++ ) { 59 loggerSerial.debug(" serializing field "+fieldsName[i]+ 60 " - "+fieldsValue[i]); 61 finalObject.addField( fieldsName[i], fieldsValue[i] ); 62 } 63 64 73 } 74 75 80 81 public void whenDeserialized ( SerializedJacObject orgObject ) { 82 loggerSerial.debug("DeploymentAC.whenDeserialize"); 83 if ( ! orgObject.isForwarder() ) { 84 loggerSerial.debug("not a forwarder"); 85 Wrappee finalObject = (Wrappee)attr("finalObject"); 86 RemoteRef server; 87 if( (server = (RemoteRef) orgObject.getACInfos( ACManager.get().getName( this ) ) ) != null ) { 88 Wrapping.wrapAll(finalObject,null,new StubWrapper(this,server)); 89 } else { 90 Iterator it = orgObject.getFields().keySet().iterator(); 91 while ( it.hasNext() ) { 92 String fn = (String ) it.next(); 93 loggerSerial.debug("setting field "+fn+" <- "+ 94 orgObject.getField( fn )); 95 ObjectState.setFieldValue(finalObject,fn, 96 ObjectState.getField(orgObject,fn) ); 97 } 98 } 99 } 100 } 101 102 105 106 public void whenCreatingRemoteAccess(Wrappee wrappee, String serverHost) { 107 Wrapping.wrapAll(wrappee,null,new StubWrapper(this,serverHost)); 108 } 109 110 public void createRemoteAccess(String nameExpr, 111 String classExpr, 112 String methodExpr, 113 String serverHost) { 114 try { 115 pointcut(nameExpr, classExpr, methodExpr, 116 StubWrapper.class.getName(), 117 new Object [] {serverHost}, "invoke", null, true); 118 } catch ( Exception e ) { 121 logger.error("createRemoteAccess: pointcut creation failed",e); 122 } 123 } 124 125 } 126 | Popular Tags |