I'm tring to get something from HBase.Using AspectJ's load time weaving.I have wrote the AbstractAspect.aj and aop.xml.I also have tried use "ajc -outxml AbstractAspect.aj" to generate aop.xml,it is too simple and can not get the method's parameters.I doubt if the way(LTW) could get context.
AbstractAspect.aj:
package com.test.apectj.aj;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetRequest;
import com.google.protobuf.RpcController;
public abstract aspect AbstractAspect {
pointcut scan();
pointcut multi();
pointcut getdata(final RpcController controller, final GetRequest request): target(org.apache.hadoop.hbase.protobuf.generated.ClientProtos) && call (public * org.apache.hadoop.hbase.regionserver.HRegionServer.get(RpcController, GetRequest)) && args(controller, request);
pointcut scope();
before() : scan() {
System.out.println("[aop]before methon scan()");
System.out.println(thisEnclosingJoinPointStaticPart);
System.out.println(thisJoinPoint.getSourceLocation());
}
before() : multi() {
System.out.println("[aop]before methon multi()");
System.out.println("[aop]Execute multiple actions on a table: get,
mutate,and/orexecCoprocessor");
}
after() : multi(){
System.out.println("[aop]after methon multi()");
}
before(RpcController controller, GetRequest request) : getdata(controller, request)
{
System.out.println("[aop]before methon get()");
System.out.println("[aop]Get data from a table");
System.out.println(request.toString());
}
}
aop.xml:
<?xml version="1.0" encoding="UTF-8"?>
<aspectj>
<aspects>
<concrete-aspect name="com.test.apectj.aj.ConcreteAspect"
extends="com.test.apectj.aj.AbstractAspect">
<pointcut name="scan"
expression="execution(public * org.apache.hadoop.hbase.regionserver.HRegionServer.scan(com.google.protobuf.RpcController, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest)) AND target(org.apache.hadoop.hbase.regionserver.HRegionServer)" />
<pointcut name="multi"
expression="execution(public * org.apache.hadoop.hbase.regionserver.HRegionServer.multi(..)) AND target(org.apache.hadoop.hbase.regionserver.HRegionServer)" />
<pointcut name="getdata()"
expression="call(public * org.apache.hadoop.hbase.regionserver.HRegionServer.get(..))" />
</concrete-aspect>
</aspects>
<weaver options="-verbose -Xset:weaveJavaxPackages=true">
</weaver>
</aspectj>
when running:
- no arguments[ pointcut: scan() multi() ]: success. Can print information
- have arguments[ pointcut: getdata() ]: failure. Warning like this:...
[AppClassLoader@4d97507c] warning at com/test/apectj/aj/E:\EclipseWorkspace\hbase-regionserver-aop\src\com\test\apectj\aj\AbstractAspect.aj:25::0 does not match because declaring type is org.apache.hadoop.hbase.protobuf.generated.ClientProtos$ClientService$BlockingInterface, if match desired use target(org.apache.hadoop.hbase.regionserver.HRegionServer)
[Xlint:unmatchedSuperTypeInCall]
see also: org/apache/hadoop/hbase/protobuf/generated/ClientProtos.java:28857::0
Only a simple abstract pointcut can be implemented when using this mechanism,if the mothod is not abstract.
My question is whether this way could get parameters?If possible,how to config.