1 8 package org.codehaus.aspectwerkz.annotation; 9 10 import org.codehaus.aspectwerkz.definition.MixinDefinition; 11 import org.codehaus.aspectwerkz.definition.SystemDefinition; 12 import org.codehaus.aspectwerkz.definition.DefinitionParserHelper; 13 import org.codehaus.aspectwerkz.reflect.ClassInfo; 14 import org.codehaus.aspectwerkz.annotation.instrumentation.asm.AsmAnnotations; 15 import org.codehaus.aspectwerkz.expression.ExpressionInfo; 16 import org.codehaus.aspectwerkz.expression.ExpressionNamespace; 17 import org.codehaus.aspectwerkz.DeploymentModel; 18 import org.codehaus.aspectwerkz.DeploymentModel; 19 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 28 public class MixinAnnotationParser { 29 30 33 private final static MixinAnnotationParser INSTANCE = new MixinAnnotationParser(); 34 35 38 private MixinAnnotationParser() { 39 } 40 41 47 public static void parse(final ClassInfo classInfo, final MixinDefinition mixinDef) { 48 INSTANCE.doParse(classInfo, mixinDef); 49 } 50 51 57 private void doParse(final ClassInfo classInfo, final MixinDefinition mixinDef) { 58 if (classInfo == null) { 59 throw new IllegalArgumentException ("class to parse can not be null"); 60 } 61 if (classInfo == null) { 62 throw new IllegalArgumentException ("class can not be null"); 63 } 64 final SystemDefinition systemDef = mixinDef.getSystemDefinition(); 65 final List annotations = AsmAnnotations.getAnnotations(AnnotationConstants.MIXIN, classInfo); 66 for (Iterator iterator = annotations.iterator(); iterator.hasNext();) { 67 Mixin annotation = (Mixin) iterator.next(); 68 if (annotation != null) { 69 String expression = AspectAnnotationParser.getExpressionElseValue( 70 annotation.value(), annotation.pointcut() 71 ); 72 final ExpressionInfo expressionInfo = new ExpressionInfo(expression, systemDef.getUuid()); 73 ExpressionNamespace.getNamespace(systemDef.getUuid()).addExpressionInfo( 74 DefinitionParserHelper.EXPRESSION_PREFIX + expression.hashCode(), 75 expressionInfo 76 ); 77 mixinDef.addExpressionInfo(expressionInfo); 78 mixinDef.setTransient(annotation.isTransient()); 79 if (annotation.deploymentModel() != null) { 80 mixinDef.setDeploymentModel(DeploymentModel.getDeploymentModelFor(annotation.deploymentModel())); 81 } 82 } 83 } 84 } 85 } | Popular Tags |