final AspectInfo aspectInfo,
final String joinPointClassName) {
String aspectClassSignature = aspectInfo.getAspectClassSignature();
String aspectClassName = aspectInfo.getAspectClassName();
// retrieve the aspect set it to the field
DeploymentModel deploymentModel = aspectInfo.getDeploymentModel();
if (deploymentModel.equals(DeploymentModel.PER_JVM)) {
// AW-355, we need a ClassLoader here
cv.visitFieldInsn(GETSTATIC, joinPointClassName, TARGET_CLASS_FIELD_NAME, CLASS_CLASS_SIGNATURE);
cv.visitMethodInsn(
INVOKEVIRTUAL, CLASS_CLASS, GETCLASSLOADER_METHOD_NAME,
CLASS_CLASS_GETCLASSLOADER_METHOD_SIGNATURE
);
cv.visitLdcInsn(aspectInfo.getAspectQualifiedName());
cv.visitMethodInsn(
INVOKESTATIC,
ASPECTS_CLASS_NAME,
ASPECT_OF_METHOD_NAME,
ASPECT_OF_PER_JVM_METHOD_SIGNATURE
);
cv.visitTypeInsn(CHECKCAST, aspectClassName);
cv.visitFieldInsn(PUTSTATIC, joinPointClassName, aspectInfo.getAspectFieldName(), aspectClassSignature);
} else if (deploymentModel.equals(DeploymentModel.PER_CLASS)) {
cv.visitLdcInsn(aspectInfo.getAspectQualifiedName());
cv.visitFieldInsn(GETSTATIC, joinPointClassName, TARGET_CLASS_FIELD_NAME, CLASS_CLASS_SIGNATURE);
cv.visitMethodInsn(
INVOKESTATIC,
ASPECTS_CLASS_NAME,
ASPECT_OF_METHOD_NAME,
ASPECT_OF_PER_CLASS_METHOD_SIGNATURE
);
cv.visitTypeInsn(CHECKCAST, aspectClassName);
cv.visitFieldInsn(PUTSTATIC, joinPointClassName, aspectInfo.getAspectFieldName(), aspectClassSignature);
} else if (deploymentModel.equals(DeploymentModel.PER_INSTANCE)) {
} else {
throw new UnsupportedOperationException(
"unsupported deployment model - " +
aspectInfo.getAspectClassName() + " " +
deploymentModel