1 4 package com.tc.aspectwerkz.aspect.container; 5 6 import com.tc.asm.MethodVisitor; 7 import com.tc.asm.Label; 8 9 15 public class PerJVMAspectFactoryCompiler extends AbstractAspectFactoryCompiler { 16 17 public PerJVMAspectFactoryCompiler(String uuid, 18 String aspectClassName, 19 String aspectQualifiedName, 20 String containerClassName, 21 String rawParameters, 22 ClassLoader loader) { 23 super(uuid, aspectClassName, aspectQualifiedName, containerClassName, rawParameters, loader); 24 } 25 26 protected void createAspectOf() { 27 m_cw.visitField( 28 ACC_PUBLIC + ACC_STATIC, 29 FACTORY_SINGLE_ASPECT_FIELD_NAME, 30 m_aspectClassSignature, 31 null, 32 null 33 ); 34 35 MethodVisitor cv = m_cw.visitMethod( 36 ACC_PUBLIC + ACC_STATIC + ACC_FINAL, 37 FACTORY_ASPECTOF_METHOD_NAME, 38 "()" + m_aspectClassSignature, 39 null, 40 null 41 ); 42 43 cv.visitFieldInsn(GETSTATIC, m_aspectFactoryClassName, FACTORY_SINGLE_ASPECT_FIELD_NAME, m_aspectClassSignature); 44 Label ifNonNull = new Label(); 45 cv.visitJumpInsn(IFNONNULL, ifNonNull); 46 if (m_hasAspectContainer) { 47 cv.visitFieldInsn(GETSTATIC, m_aspectFactoryClassName, FACTORY_CONTAINER_FIELD_NAME, ASPECT_CONTAINER_CLASS_SIGNATURE); 48 cv.visitMethodInsn(INVOKEINTERFACE, ASPECT_CONTAINER_CLASS_NAME, ASPECT_CONTAINER_ASPECTOF_METHOD_NAME, ASPECT_CONTAINER_ASPECTOF_PERJVM_METHOD_SIGNATURE); 49 cv.visitTypeInsn(CHECKCAST, m_aspectClassName); 50 } else { 51 cv.visitTypeInsn(NEW, m_aspectClassName); 52 cv.visitInsn(DUP); 53 cv.visitMethodInsn(INVOKESPECIAL, m_aspectClassName, INIT_METHOD_NAME, NO_PARAM_RETURN_VOID_SIGNATURE); 54 } 55 cv.visitFieldInsn(PUTSTATIC, m_aspectFactoryClassName, FACTORY_SINGLE_ASPECT_FIELD_NAME, m_aspectClassSignature); 56 cv.visitLabel(ifNonNull); 57 cv.visitFieldInsn(GETSTATIC, m_aspectFactoryClassName, FACTORY_SINGLE_ASPECT_FIELD_NAME, m_aspectClassSignature); 58 cv.visitInsn(ARETURN); 59 cv.visitMaxs(0, 0); 60 } 61 62 protected void createHasAspect() { 63 MethodVisitor cv = m_cw.visitMethod( 64 ACC_STATIC + ACC_PUBLIC + ACC_FINAL, 65 FACTORY_HASASPECT_METHOD_NAME, 66 NO_PARAM_RETURN_BOOLEAN_SIGNATURE, 67 null, 68 null 69 ); 70 71 cv.visitFieldInsn(GETSTATIC, m_aspectFactoryClassName, FACTORY_SINGLE_ASPECT_FIELD_NAME, m_aspectClassSignature); 72 Label ifNonNull = new Label(); 73 cv.visitJumpInsn(IFNONNULL, ifNonNull); 74 cv.visitInsn(ICONST_0); 75 cv.visitInsn(IRETURN); 76 cv.visitLabel(ifNonNull); 77 cv.visitInsn(ICONST_1); 78 cv.visitInsn(IRETURN); 79 cv.visitMaxs(0, 0); 80 } 81 82 protected void createOtherArtifacts() { 83 ; 84 } 85 } 86 | Popular Tags |