[jboss-user] [JBoss AOP] - ObjectInput

slv do-not-reply at jboss.com
Thu Jan 22 06:48:23 EST 2009


Hello,
  I am currently playing around with JBoss AOP, but I can't seem to  make my pointcuts work.

This is the xml file:

  | <aop>
  | 	<aspect class="main.Aspect" />
  | 	<bind pointcut="execution(void $instanceof{java.io.ObjectOutput}->writeObject($instanceof{java.lang.Object}))">
  | 		<around aspect="main.Aspect" name="secureWrite" />
  | 	</bind>
  | 	<bind pointcut="execution($instanceof{java.lang.Object} $instanceof{java.io.ObjectInput}->readObject())">
  | 		<around aspect="main.Aspect" name="secureRead" />
  | 	</bind>
  | </aop>
  | 

My Aspect class is this:

  | package main;
  | 
  | import org.jboss.aop.joinpoint.MethodInvocation;
  | 
  | public class Aspect {
  | 	private final SecureCommunication secure;
  | 
  | 	public Aspect() {
  | 		secure = new SecureCommunicationRSA();
  | 	}
  | 
  | 	public Object secureWrite(MethodInvocation invocation) throws Throwable {
  | 		System.out.println("Writing secure");
  | 		Object[] args = invocation.getArguments();
  | 		for (int i = 0; i < args.length; i++) {
  | 			args = secure.encrypt(args);
  | 		}
  | 		return invocation.invokeNext();
  | 	}
  | 
  | 	public Object secureRead(MethodInvocation invocation) throws Throwable {
  | 		System.out.println("Reading secure");
  | 		return secure.decrypt(invocation.invokeNext());
  | 	}
  | }
  | 

And the class I want to instrument is this:
package main;
  | 
  | import java.io.File;
  | import java.io.FileInputStream;
  | import java.io.FileOutputStream;
  | import java.io.IOException;
  | import java.io.ObjectInput;
  | import java.io.ObjectInputStream;
  | import java.io.ObjectOutput;
  | import java.io.ObjectOutputStream;
  | 
  | public class Main {
  | 
  | 	/**
  | 	 * @param args
  | 	 */
  | 	public static void main(String[] args) throws IOException,
  | 			ClassNotFoundException {
  | 		ObjectOutput out = new ObjectOutputStream(new FileOutputStream(
  | 				new File("test")));
  | 		out.writeObject("this");
  | 		out.writeObject("is");
  | 		out.writeObject("a test");
  | 		out.close();
  | 
  | 		ObjectInput in = new ObjectInputStream(new FileInputStream(new File(
  | 				"test")));
  | 		System.out.println(in.readObject());
  | 		System.out.println(in.readObject());
  | 		System.out.println(in.readObject());
  | 
  | 	}
  | 
  | }
  | 

When I try to apply the aspects, I get the following message
anonymous wrote : 
  | [aop-debug] org.jboss.aop.instrument.Instrumentor trying to transform main.Main
  | [aop-debug] org.jboss.aop.instrument.CallerTransformer There are no caller pointcuts!
  | [aop-debug] org.jboss.aop.instrument.JoinpointSimpleClassifier javassist.CtMethod at 44a4fe33[public static main ([Ljava/lang/String;)V] matches no pointcuts
  | [aop-debug] org.jboss.aop.instrument.JoinpointSimpleClassifier javassist.CtConstructor at 176e552[public Main ()V] matches no pointcuts
  | [aop-debug] org.jboss.aop.instrument.Instrumentor was main.Main converted: false
  | [no comp needed] /home/slv/Desktop/EncryptionTest/classes/main/Main.class
  | 

Can you please help me? I tried so many things and I can't make it work.

Thank you, 
  Silviu

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4203960#4203960

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4203960



More information about the jboss-user mailing list