Package org.aspectj.weaver.patterns

Examples of org.aspectj.weaver.patterns.Pointcut


                );

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

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

                ISourceLocation sl = struct.context.makeSourceLocation(struct.bMethod.getDeclarationLineNumber(), struct.bMethod.getDeclarationOffset());
                struct.ajAttributes.add(
View Full Code Here


            UnresolvedType[] argumentTypes = new UnresolvedType[struct.method.getArgumentTypes().length];
            for (int i = 0; i < argumentTypes.length; i++) {
                argumentTypes[i] = UnresolvedType.forSignature(struct.method.getArgumentTypes()[i].getSignature());
            }

            Pointcut pc = null;
            if (struct.method.isAbstract()) {
                if ((pointcutExpr != null && isNullOrEmpty(pointcutExpr.getValue().stringifyValue()))
                    || pointcutExpr == null) {
                    // abstract pointcut
                    // leave pc = null
                } else {
                    reportError("Found defined @Pointcut on an abstract method", struct);
                    return;//stop
                }
            } else {
                if (pointcutExpr != null) {
                    // use a LazyResolvedPointcutDefinition so that the pointcut is resolved lazily
                    // since for it to be resolved, we will need other pointcuts to be registered as well
                    pc = parsePointcut(pointcutExpr.getValue().stringifyValue(), struct, true);
                    if (pc == null) return;//parse error
                    pc.setLocation(struct.context, -1, -1);//FIXME AVASM !! bMethod is null here..
                } else {
                    reportError("Found undefined @Pointcut on a non-abstract method", struct);
                    return;
                }
            }
View Full Code Here

                IScope binding = new BindingScope(
                        struct.enclosingType,
                        struct.context,
                        bindings
                );
                Pointcut pc = parsePointcut(declareError.getValue().stringifyValue(), struct, false);
                if (pc == null) {
                    hasError = false;//cannot parse pointcut
                } else {
                    pc .resolve(binding);
                    DeclareErrorOrWarning deow = new DeclareErrorOrWarning(true, pc, struct.field.getConstantValue().toString());
                    deow.setLocation(struct.context, -1, -1);
                    struct.ajAttributes.add(new AjAttribute.DeclareAttribute(deow));
                    hasError = true;
                }
            }
        }
        Annotation warning = getAnnotation(runtimeAnnotations, AjcMemberMaker.DECLAREWARNING_ANNOTATION);
        boolean hasWarning = false;
        if (warning != null) {
            ElementNameValuePair declareWarning = getAnnotationElement(warning, VALUE);
            if (declareWarning != null) {
                if (!STRING_DESC.equals(struct.field.getSignature()) || struct.field.getConstantValue() == null) {
                    reportError("@DeclareWarning used on a non String constant field", struct);
                    return false;
                }
                FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
                IScope binding = new BindingScope(
                        struct.enclosingType,
                        struct.context,
                        bindings
                );
                Pointcut pc = parsePointcut(declareWarning.getValue().stringifyValue(), struct, false);
                if (pc == null) {
                    hasWarning = false;//cannot parse pointcut
                } else {
                    pc.resolve(binding);
                    DeclareErrorOrWarning deow = new DeclareErrorOrWarning(false, pc, struct.field.getConstantValue().toString());
                    deow.setLocation(struct.context, -1, -1);
                    struct.ajAttributes.add(new AjAttribute.DeclareAttribute(deow));
                    return hasWarning = true;
                }
View Full Code Here

     * @param allowIf
     * @return pointcut, unresolved
     */
    private static Pointcut parsePointcut(String pointcutString, AjAttributeStruct struct, boolean allowIf) {
        try {
            Pointcut pointcut = new PatternParser(pointcutString, struct.context).parsePointcut();
            if (!allowIf && pointcutString.indexOf("if()") >= 0 && hasIf(pointcut)) {
                reportError("if() pointcut is not allowed at this pointcut location '" + pointcutString +"'", struct);
                return null;
            }
            pointcut.setLocation(struct.context, -1, -1);//FIXME -1,-1 is not good enough
            return pointcut;
        } catch (ParserException e) {
            reportError("Invalid pointcut '" + pointcutString + "': " + e.toString(), struct);
            return null;
        }
View Full Code Here

        for (Iterator it = attributes.iterator(); it.hasNext();) {
            AjAttribute attr = (AjAttribute) it.next();
            if (attr instanceof AjAttribute.PointcutDeclarationAttribute) {
                AjAttribute.PointcutDeclarationAttribute pcAttr = (AjAttribute.PointcutDeclarationAttribute) attr;
                Pointcut pointcut = pcAttr.reify().getPointcut();
                if (pointcut instanceof KindedPointcut) {
                    try {
                        Field sigField = KindedPointcut.class.getDeclaredField("signature");
                        sigField.setAccessible(true);
                        SignaturePattern signature = (SignaturePattern) sigField.get(pointcut);
                        DefinitionParserHelper.createAndAddPointcutDefToAspectDef(
                                signature.getName().toString(), pointcut.toString(), aspectDef
                        );
                    } catch (Exception e) {
                        throw new WrappedRuntimeException(e);
                    }
                }
View Full Code Here

TOP

Related Classes of org.aspectj.weaver.patterns.Pointcut

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.