Oi pessoal, boa tarde.
Dada a seguinte estrutura, que está funcionando muito bem:
public class Person {
public boolean isUnderAge() {
return false;
}
@Remotable
public Integer create() {
return persistenceStrategy.create( this );
}
@Remotable
public void load() {
persistenceStrategy.load( this );
}
}
public class RemoteInterceptor {
// ...
@Around( "execution( @my.package.local.Remotable * my.package.entities...*.*(..) )" )
public Object around( JoinPoint point ) throws Throwable {
Object target = point.getTarget();
Signature signature = point.getSignature();
String methodName = signature.getName();
MethodRtti methodRtti = ( MethodRtti ) point.getRtti();
Object[] args = methodRtti.getParameterValues();
Object returnValue = null;
try {
returnValue = remoteProcedureCaller.call( target, methodName, args );
}
catch( Exception e ) {
e.printStackTrace();
}
return returnValue;
}
}
public class RemotingTest {
public static void main( String[] bananinha ) {
Person p = new Person( "lipe", 20 );
p.create();
Person p2 = new Person( 1 );
p2.load();
}
}
Como eu faria para:
- poder encapsular diversas chamadas remotas num objeto só, enviar este objeto para o servidor, executar os métodos e retornar para o cliente os valores de retorno da execução dos métodos para os chamadores. Algo como
// this object should be sent to the server and executed there
public class Command {
public void addCommand( Object target, String methodName, Object .. params ) {
// add to the list
}
public void execute() {
// etc
}
}
- criar uma transação, algo como
public class RemotingTest {
public static void main( String[] bananinha ) {
Person p = new Person( "lipe", 20 );
Person p2 = new Person( 1 );
Transaction.begin();
p.create();
p2.load();
Transaction.commit();
}
}
Quanto a 2, louds sugeriu utilizar ThreadLocal para demarcação das transações, mas AspectWerkz infezlimente não suporta mais um per-thread model dos interceptors.
Alguém tem alguma luz? Algo que deveria estudar? Ou devo desistir pois é impossível?
Valeu pessoal.

