if (!isInstrumented(superclass)) {
if (!isInstrumentable(superclass)) {
//we're the top-most instrumentable class, so add the handler field
CtField handlerField = new CtField(handlerClass, "handler", implementation);
handlerField.setModifiers(Modifier.PROTECTED);
Initializer handlerInitializer = Initializer.byCall(handlerClass, "create");
implementation.addField(handlerField, handlerInitializer);
CtMethod getHandlerMethod = CtNewMethod.getter("getHandler", handlerField);
implementation.addMethod(getHandlerMethod);
}
else {
//in order for the below code to make reference to the handler instance we need to
//recursively instrument until we reach the top of the instrumentable class tree
instrumentClass(superclass);
}
}
CtField wicketComponentField = new CtField(componentClass, "component", implementation);
wicketComponentField.setModifiers(Modifier.STATIC);
Initializer componentInit = Initializer.byExpr("new org.jboss.seam.wicket.WicketComponent(" + className + ".class)");
implementation.addField(wicketComponentField, componentInit);
CtClass exception = classPool.get(Exception.class.getName());
implementation.addInterface(getInstrumentedComponentInterface());