Package org.aspectj.apache.bcel.classfile.annotation

Examples of org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair


              Annotation a = annotationsOnThisType[i];
              if (a.getTypeName().equals(UnresolvedType.AT_RETENTION.getName())) {
                  List values = a.getValues();
                  boolean isRuntime = false;
                  for (Iterator it = values.iterator(); it.hasNext();) {
                        ElementNameValuePair element = (ElementNameValuePair) it.next();
                        ElementValue v = element.getValue();
                        retentionPolicy = v.stringifyValue();
                        return retentionPolicy;
                    }
              }
          }
View Full Code Here


          for (int i = 0; i < annotationsOnThisType.length; i++) {
              Annotation a = annotationsOnThisType[i];
              if (a.getTypeName().equals(UnresolvedType.AT_TARGET.getName())) {
                  List values = a.getValues();
                  for (Iterator it = values.iterator(); it.hasNext();) {
                        ElementNameValuePair element = (ElementNameValuePair) it.next();
                        ElementValue v = element.getValue();
                        String targetKind = v.stringifyValue();
                        if (targetKind.equals("ANNOTATION_TYPE")) {
              targetKinds.add(AnnotationTargetKind.ANNOTATION_TYPE);
                        } else if (targetKind.equals("CONSTRUCTOR")) {
              targetKinds.add(AnnotationTargetKind.CONSTRUCTOR);
View Full Code Here

      lookedForAtTargetAnnotation = true;
      atTargetAnnotation = retrieveAnnotationOnAnnotation(UnresolvedType.AT_TARGET);
      if (atTargetAnnotation != null) {
        supportedTargets = new HashSet();
        List values = atTargetAnnotation.getBcelAnnotation().getValues();
          ElementNameValuePair envp = (ElementNameValuePair)values.get(0);
          ArrayElementValue aev = (ArrayElementValue)envp.getValue();
          ElementValue[] evs = aev.getElementValuesArray();
          for (int i = 0; i < evs.length; i++) {
          EnumElementValue ev = (EnumElementValue)evs[i];
          supportedTargets.add(ev.getEnumValueString());
        }
View Full Code Here

                    return false;
                }
                extendsAspect = struct.enclosingType.getSuperclass().isAspect();
            }

            ElementNameValuePair aspectPerClause = getAnnotationElement(aspect, VALUE);
            final PerClause perClause;
            if (aspectPerClause == null) {
                // empty value means singleton unless inherited
                if (!extendsAspect) {
                    perClause = new PerSingleton();
                } else {
                    perClause = new PerFromSuper(struct.enclosingType.getSuperclass().getPerClause().getKind());
                }
            } else {
                String perX = aspectPerClause.getValue().stringifyValue();
                if (perX == null || perX.length() <= 0) {
                    perClause = new PerSingleton();
                } else {
                    perClause = parsePerClausePointcut(perX, struct);
                }
View Full Code Here

     * @return true if found
     */
    private static boolean handlePrecedenceAnnotation(RuntimeAnnotations runtimeAnnotations, AjAttributeStruct struct) {
        Annotation aspect = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREPRECEDENCE_ANNOTATION);
        if (aspect != null) {
            ElementNameValuePair precedence = getAnnotationElement(aspect, VALUE);
            if (precedence != null) {
                String precedencePattern = precedence.getValue().stringifyValue();
                PatternParser parser = new PatternParser(precedencePattern);
                DeclarePrecedence ajPrecedence = parser.parseDominates();
                struct.ajAttributes.add(new AjAttribute.DeclareAttribute(ajPrecedence));
                return true;
            }
View Full Code Here

     * @return true if found
     */
    private static boolean handleDeclareParentsAnnotation(RuntimeAnnotations runtimeAnnotations, AjAttributeFieldStruct struct) {//, ResolvedPointcutDefinition preResolvedPointcut) {
        Annotation decp = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREPARENTS_ANNOTATION);
        if (decp != null) {
            ElementNameValuePair decpPatternNVP = getAnnotationElement(decp, VALUE);
            String decpPattern = decpPatternNVP.getValue().stringifyValue();
            if (decpPattern != null) {
                TypePattern typePattern = parseTypePattern(decpPattern, struct);
                ResolvedType fieldType = UnresolvedType.forSignature(struct.field.getSignature()).resolve(struct.enclosingType.getWorld());
                if (fieldType.isInterface()) {
                    TypePattern parent = new ExactTypePattern(UnresolvedType.forSignature(struct.field.getSignature()), false, false);
                    parent.resolve(struct.enclosingType.getWorld());
                    // first add the declare implements like
                    List parents = new ArrayList(1); parents.add(parent);
                    DeclareParents dp = new DeclareParents(
                            typePattern,
                            parents,
                            false
                        );
                    //TODO kick ISourceLocation sl = struct.bField.getSourceLocation();    ??
                    dp.setLocation(struct.context,0,0); // not ideal...
                    struct.ajAttributes.add(
                            new AjAttribute.DeclareAttribute(
                                    dp
                            )
                    );


                    // do we have a defaultImpl=xxx.class (ie implementation)
                    String defaultImplClassName = null;
                    ElementNameValuePair defaultImplNVP = getAnnotationElement(decp, "defaultImpl");
                    if (defaultImplNVP != null) {
                        ClassElementValue defaultImpl = (ClassElementValue) defaultImplNVP.getValue();
                        defaultImplClassName = UnresolvedType.forSignature(defaultImpl.getClassString()).getName();
                        if (defaultImplClassName.equals("org.aspectj.lang.annotation.DeclareParents")) {
                            defaultImplClassName = null;
                        } else {
                            // check public no arg ctor
View Full Code Here

     * @return true if found
     */
    private static boolean handleBeforeAnnotation(RuntimeAnnotations runtimeAnnotations, AjAttributeMethodStruct struct, ResolvedPointcutDefinition preResolvedPointcut) {
        Annotation before = getAnnotation(runtimeAnnotations, AjcMemberMaker.BEFORE_ANNOTATION);
        if (before != null) {
            ElementNameValuePair beforeAdvice = getAnnotationElement(before, VALUE);
            if (beforeAdvice != null) {
                // this/target/args binding
                FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
                try {
                    bindings = extractBindings(struct);
                } catch (UnreadableDebugInfoException unreadableDebugInfoException) {
                    return false;
                }
                IScope binding = new BindingScope(
                        struct.enclosingType,
                        struct.context,
                        bindings
                );

                // joinpoint, staticJoinpoint binding
                int extraArgument = extractExtraArgument(struct.method);

                Pointcut pc = null;
                if (preResolvedPointcut != null) {
                    pc = preResolvedPointcut.getPointcut();
                    //pc.resolve(binding);
                } else {
                    pc = parsePointcut(beforeAdvice.getValue().stringifyValue(), struct, false);
                    if (pc == null) return false;//parse error
                    pc = pc.resolve(binding);
                }
                setIgnoreUnboundBindingNames(pc, bindings);

View Full Code Here

     * @return true if found
     */
    private static boolean handleAfterAnnotation(RuntimeAnnotations runtimeAnnotations, AjAttributeMethodStruct struct, ResolvedPointcutDefinition preResolvedPointcut) {
        Annotation after = getAnnotation(runtimeAnnotations, AjcMemberMaker.AFTER_ANNOTATION);
        if (after != null) {
            ElementNameValuePair afterAdvice = getAnnotationElement(after, VALUE);
            if (afterAdvice != null) {
                // this/target/args binding
                FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
                try {
                    bindings = extractBindings(struct);
                } catch (UnreadableDebugInfoException unreadableDebugInfoException) {
                    return false;
                }
                IScope binding = new BindingScope(
                        struct.enclosingType,
                        struct.context,
                        bindings
                );

                // joinpoint, staticJoinpoint binding
                int extraArgument = extractExtraArgument(struct.method);

                Pointcut pc = null;
                if (preResolvedPointcut != null) {
                    pc = preResolvedPointcut.getPointcut();
                } else {
                    pc = parsePointcut(afterAdvice.getValue().stringifyValue(), struct, false);
                    if (pc == null) return false;//parse error
                    pc.resolve(binding);
                }
                setIgnoreUnboundBindingNames(pc, bindings);

View Full Code Here

            BcelMethod owningMethod)
    throws ReturningFormalNotDeclaredInAdviceSignatureException
    {
        Annotation after = getAnnotation(runtimeAnnotations, AjcMemberMaker.AFTERRETURNING_ANNOTATION);
        if (after != null) {
            ElementNameValuePair annValue = getAnnotationElement(after, VALUE);
            ElementNameValuePair annPointcut = getAnnotationElement(after, POINTCUT);
            ElementNameValuePair annReturned = getAnnotationElement(after, RETURNING);

            // extract the pointcut and returned type/binding - do some checks
            String pointcut = null;
            String returned = null;
            if ((annValue != null && annPointcut != null) || (annValue == null && annPointcut == null)) {
                reportError("@AfterReturning: either 'value' or 'poincut' must be provided, not both", struct);
                return false;
            }
            if (annValue != null) {
                pointcut = annValue.getValue().stringifyValue();
            } else {
                pointcut = annPointcut.getValue().stringifyValue();
            }
            if (isNullOrEmpty(pointcut)) {
                reportError("@AfterReturning: either 'value' or 'poincut' must be provided, not both", struct);
                return false;
            }
            if (annReturned != null) {
                returned = annReturned.getValue().stringifyValue();
                if (isNullOrEmpty(returned)) {
                    returned = null;
                } else {
                       // check that thrownFormal exists as the last parameter in the advice
                    String[] pNames = owningMethod.getParameterNames();
View Full Code Here

            BcelMethod owningMethod)
    throws ThrownFormalNotDeclaredInAdviceSignatureException
    {
        Annotation after = getAnnotation(runtimeAnnotations, AjcMemberMaker.AFTERTHROWING_ANNOTATION);
        if (after != null) {
            ElementNameValuePair annValue = getAnnotationElement(after, VALUE);
            ElementNameValuePair annPointcut = getAnnotationElement(after, POINTCUT);
            ElementNameValuePair annThrown = getAnnotationElement(after, THROWING);

            // extract the pointcut and throwned type/binding - do some checks
            String pointcut = null;
            String thrownFormal = null;
            if ((annValue != null && annPointcut != null) || (annValue == null && annPointcut == null)) {
                reportError("@AfterThrowing: either 'value' or 'poincut' must be provided, not both", struct);
                return false;
            }
            if (annValue != null) {
                pointcut = annValue.getValue().stringifyValue();
            } else {
                pointcut = annPointcut.getValue().stringifyValue();
            }
            if (isNullOrEmpty(pointcut)) {
                reportError("@AfterThrowing: either 'value' or 'poincut' must be provided, not both", struct);
                return false;
            }
            if (annThrown != null) {
                thrownFormal = annThrown.getValue().stringifyValue();
                if (isNullOrEmpty(thrownFormal)) {
                    thrownFormal = null;
                } else {
                    // check that thrownFormal exists as the last parameter in the advice
                    String[] pNames = owningMethod.getParameterNames();
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.