我试图在下面的示例代码中执行 readObject() 后从建议 readObject() 连接点的 after 建议中获取读取字符串的值。
public class Eg {
private ObjectOutputStream output;
private ObjectInputStream input;
Public String request="";
public Eg(File source){
output; // output stream to client
input= new ObjectInputStream( file );
}
public void method() {
try{
while(true) {
request =(String) input.readObject();
//do something with request
}//while
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
}
和我的方面:
public aspect ReadStringGetter {
public pointcut readOperation() :
execution(* java.io.ObjectInputStream.readObject());
after() : readOperation() {
Eg eg = (Eg) thisJoinPoint.getThis();
System.out.println(eg.request);
}
}