final String aspectFieldName,
final CodeVisitor cv,
final String joinPointClassName) {
AdviceInfo adviceInfo = adviceMethodInfo.adviceInfo;
final CrossCuttingInfo info = adviceInfo.getAspectManager().getAspectContainer(adviceInfo.getAspectIndex())
.getCrossCuttingInfo();
final String aspectClassName = info.getAspectClass().getName().replace('.', '/');
final String aspectClassSignature = L + aspectClassName + SEMICOLON;
// add the aspect field
cw.visitField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, aspectFieldName, aspectClassSignature, null, null);
// retrieve the aspect set it to the field
cv.visitFieldInsn(GETSTATIC, joinPointClassName, SYSTEM_FIELD_NAME, SYSTEM_CLASS_SIGNATURE);
cv.visitLdcInsn(info.getUuid());
cv.visitMethodInsn(
INVOKEVIRTUAL,
SYSTEM_CLASS_NAME,
GET_ASPECT_MANAGER_METHOD_NAME,
GET_ASPECT_MANAGER_METHOD_SIGNATURE
);
cv.visitIntInsn(BIPUSH, adviceInfo.getAspectIndex());
cv.visitMethodInsn(
INVOKEVIRTUAL,
ASPECT_MANAGER_CLASS_NAME,
GET_ASPECT_CONTAINER_METHOD_NAME,
GET_ASPECT_CONTAINER_METHOD_SIGNATURE
);
switch (info.getDeploymentModel()) {
case DeploymentModel.PER_JVM:
cv.visitMethodInsn(
INVOKEINTERFACE,
ASPECT_CONTAINER_CLASS_NAME,
GET_PER_JVM_ASPECT_METHOD_NAME,
GET_PER_JVM_ASPECT_METHOD_SIGNATURE
);
break;
case DeploymentModel.PER_CLASS:
cv.visitFieldInsn(GETSTATIC, joinPointClassName, TARGET_CLASS_FIELD_NAME, CLASS_CLASS_SIGNATURE);
cv.visitMethodInsn(
INVOKEINTERFACE,
ASPECT_CONTAINER_CLASS_NAME,
GET_PER_CLASS_ASPECT_METHOD_NAME,
GET_PER_CLASS_ASPECT_METHOD_SIGNATURE
);
break;
default:
throw new UnsupportedOperationException(
"unsupported deployment model - " +
aspectFieldName + " " +
DeploymentModel.getDeploymentModelAsString(info.getDeploymentModel())
);
}
cv.visitTypeInsn(CHECKCAST, aspectClassName);
cv.visitFieldInsn(PUTSTATIC, joinPointClassName, aspectFieldName, aspectClassSignature);
return false;