Examples of PerClause


Examples of org.aspectj.weaver.patterns.PerClause

   */
  public byte[] getBytes() {
    if (!isValid) {
      throw new RuntimeException("Must validate first");
    }
    PerClause parentPerClause = (parent != null ? parent.getPerClause() : null);
    if (parentPerClause == null) {
      parentPerClause = new PerSingleton();
    }
    PerClause.Kind perclauseKind = PerClause.SINGLETON;
    String perclauseString = null;
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

    // but we don't need this level of detail, and working with real per
    // clauses
    // at this stage of compilation is not worth the trouble
    if (!isAnnotationStyleAspect()) {
      if (declaration instanceof AspectDeclaration) {
        PerClause pc = ((AspectDeclaration) declaration).perClause;
        if (pc != null) {
          return pc;
        }
      }
      return new PerSingleton();
    } else {
      // for @Aspect, we do need the real kind though we don't need the
      // real perClause
      // at least try to get the right perclause
      PerClause pc = null;
      if (declaration instanceof AspectDeclaration) {
        pc = ((AspectDeclaration) declaration).perClause;
      }
      if (pc == null) {
        PerClause.Kind kind = getPerClauseForTypeDeclaration(declaration);
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

  // adapted from AspectDeclaration
  private PerClause.Kind lookupPerClauseKind(ReferenceBinding binding) {
    final PerClause.Kind kind;
    if (binding instanceof BinaryTypeBinding) {
      ResolvedType superTypeX = factory.fromEclipse(binding);
      PerClause perClause = superTypeX.getPerClause();
      // clause is null for non aspect classes since coming from BCEL
      // attributes
      if (perClause != null) {
        kind = superTypeX.getPerClause().getKind();
      } else {
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

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

      NameValuePair 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);
        }
      }
      if (perClause == null) {
        // could not parse it, ignore the aspect
        return false;
      } else {
        perClause.setLocation(struct.context, -1, -1);// struct.context.getOffset(),
        // struct.context.getOffset()+1);//FIXME
        // AVASM
        // Not setting version here
        // struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo());
        AjAttribute.Aspect aspectAttribute = new AjAttribute.Aspect(perClause);
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

   */
  private static PerClause parsePerClausePointcut(String perClauseString, AjAttributeStruct struct) {
    final String pointcutString;
    Pointcut pointcut = null;
    TypePattern typePattern = null;
    final PerClause perClause;
    if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERCFLOW.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERCFLOW.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerCflow(pointcut, false);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERCFLOWBELOW.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERCFLOWBELOW.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerCflow(pointcut, true);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTARGET.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTARGET.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerObject(pointcut, false);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTHIS.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTHIS.extractPointcut(perClauseString);
      pointcut = parsePointcut(pointcutString, struct, false);
      perClause = new PerObject(pointcut, true);
    } else if (perClauseString.startsWith(PerClause.KindAnnotationPrefix.PERTYPEWITHIN.getName())) {
      pointcutString = PerClause.KindAnnotationPrefix.PERTYPEWITHIN.extractPointcut(perClauseString);
      typePattern = parseTypePattern(pointcutString, struct);
      perClause = new PerTypeWithin(typePattern);
    } else if (perClauseString.equalsIgnoreCase(PerClause.SINGLETON.getName() + "()")) {
      perClause = new PerSingleton();
    } else {
      // could not parse the @AJ perclause - fallback to singleton and
      // issue an error
      reportError("@Aspect per clause cannot be read '" + perClauseString + "'", struct);
      return null;
    }

    if (!PerClause.SINGLETON.equals(perClause.getKind()) && !PerClause.PERTYPEWITHIN.equals(perClause.getKind())
        && pointcut == null) {
      // we could not parse the pointcut
      return null;
    }
    if (PerClause.PERTYPEWITHIN.equals(perClause.getKind()) && typePattern == null) {
      // we could not parse the type pattern
      return null;
    }
    return perClause;
  }
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

    return this.typeVariables;
  }

  @Override
  public PerClause getPerClause() {
    PerClause pclause = getDelegate().getPerClause();
    if (pclause != null && isParameterizedType()) { // could cache the result here...
      Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap();
      pclause = (PerClause) pclause.parameterizeWith(parameterizationMap, world);
    }
    return pclause;
  }
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

 
 
  public PerClause parsePerClause(Parser parser) {
    PatternParser patternParser = new PatternParser(tokenSource);
    try {
      PerClause ret = patternParser.maybeParsePerClause();
      checkEof(parser);
      if (ret == null) return new PerSingleton();
      else return ret;
    } catch (ParserException pe) {
      reportError(parser, pe);
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

          }
        });
  }

  private PerClause.Kind lookupPerClauseKind(ReferenceBinding binding) {
    PerClause perClause;
    if (binding instanceof BinaryTypeBinding) {
      ResolvedType superTypeX = factory.fromEclipse(binding);
      perClause = superTypeX.getPerClause();
    } else if (binding instanceof SourceTypeBinding) {
      SourceTypeBinding sourceSc = (SourceTypeBinding) binding;
      if (sourceSc.scope.referenceContext instanceof AspectDeclaration) {
        perClause = ((AspectDeclaration) sourceSc.scope.referenceContext).perClause;
      } else {
        return null;
      }
    } else if (binding instanceof ParameterizedTypeBinding) {
      ParameterizedTypeBinding pBinding = (ParameterizedTypeBinding) binding;
      if (pBinding.type instanceof SourceTypeBinding) {
        SourceTypeBinding sourceSc = (SourceTypeBinding) pBinding.type;
        if (sourceSc.scope != null && sourceSc.scope.referenceContext instanceof AspectDeclaration) {
          perClause = ((AspectDeclaration) sourceSc.scope.referenceContext).perClause;
        } else {
          return null;
        }
      } else {
        perClause = null;
      }
    } else {
      // XXX need to handle this too
      return null;
    }
    if (perClause == null) {
      return lookupPerClauseKind(binding.superclass());
    } else {
      return perClause.getKind();
    }
  }
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

      throw new RuntimeException("Must validate first");
    }
    if (bytes != null) {
      return bytes;
    }
    PerClause parentPerClause = (parent != null ? parent.getPerClause() : null);
    if (parentPerClause == null) {
      parentPerClause = new PerSingleton();
    }
    PerClause.Kind perclauseKind = PerClause.SINGLETON;
    String perclauseString = null;
View Full Code Here

Examples of org.aspectj.weaver.patterns.PerClause

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

      NameValuePair 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);
        }
      }
      if (perClause == null) {
        // could not parse it, ignore the aspect
        return false;
      } else {
        perClause.setLocation(struct.context, -1, -1);// struct.context.getOffset(),
        // struct.context.getOffset()+1);//FIXME
        // AVASM
        // Not setting version here
        // struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo());
        AjAttribute.Aspect aspectAttribute = new AjAttribute.Aspect(perClause);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.