*/
public void transform(final Context context, final Klass klass) throws NotFoundException, CannotCompileException {
m_joinPointIndex = TransformationUtil.getJoinPointIndex(klass.getCtClass());
for (Iterator it = m_definitions.iterator(); it.hasNext();) {
final SystemDefinition definition = (SystemDefinition)it.next();
final CtClass ctClass = klass.getCtClass();
ClassMetaData classMetaData = JavassistMetaDataMaker.createClassMetaData(ctClass);
// filter caller classes
if (classFilter(definition, classMetaData, ctClass)) {
return;
}
ctClass.instrument(
new ExprEditor() {
public void edit(MethodCall methodCall) throws CannotCompileException {
try {
CtBehavior where = null;
try {
where = methodCall.where();
}
catch (RuntimeException e) {
// <clinit> access leads to a bug in Javassist
where = ctClass.getClassInitializer();
}
// filter caller methods
if (methodFilterCaller(where)) {
return;
}
// get the callee method name, signature and class name
CtMethod calleeMethod = methodCall.getMethod();
String calleeClassName = methodCall.getClassName();
// filter callee classes
if (!definition.inIncludePackage(calleeClassName)) {
return;
}
// filter callee methods
if (methodFilterCallee(calleeMethod)) {
return;
}
// create the class meta-data
ClassMetaData calleeSideClassMetaData;
try {
calleeSideClassMetaData =
JavassistMetaDataMaker.createClassMetaData(
context.getClassPool().get(calleeClassName)
);
}
catch (NotFoundException e) {
throw new WrappedRuntimeException(e);
}
// create the method meta-data
MethodMetaData calleeSideMethodMetaData = JavassistMetaDataMaker.createMethodMetaData(
methodCall.getMethod()
);
// is this a caller side method pointcut?
if (definition.isPickedOutByCallPointcut(
calleeSideClassMetaData, calleeSideMethodMetaData
)) {
// // TODO: should this caller data be passed to the join point? It is possible.
// String callerMethodName = callerBehaviour.getName();