Examples of ExpressionNamespace


Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

        return FALSE;
    }

    public Object visit(Anonymous node, Object data) {
        Expression expression = null;
        ExpressionNamespace ns = (ExpressionNamespace)data;
        String expr = node.name;
        int hash = node.name.hashCode();
        String exprAutoName = null;
        if (hash >= 0) {
            exprAutoName = "__AW__"+hash;
        } else {
            exprAutoName = "__AW____"+(-1*hash);
        }
        if (ns.getExpression(exprAutoName) != null) {
            return new StringBuffer(exprAutoName);
        }
        // register it
        if (expr.startsWith("execution(")) {
            expression = ns.createExecutionExpression(
                    expr.substring(10, expr.length()-1),
                    "", exprAutoName
            );
        } else if (expr.startsWith("call(")) {
            expression = ns.createCallExpression(
                    expr.substring(5, expr.length()-1),
                    "", exprAutoName
            );
        } else if (expr.startsWith("cflow(")) {
            expression = ns.createCflowExpression(
                    expr.substring(6, expr.length()-1),
                    "", exprAutoName
            );
        } else if (expr.startsWith("set(")) {
            expression = ns.createSetExpression(
                    expr.substring(4, expr.length()-1),
                    "", exprAutoName
            );
        } else if (expr.startsWith("get(")) {
            expression = ns.createGetExpression(
                    expr.substring(4, expr.length()-1),
                    "", exprAutoName
            );
        } else if (expr.startsWith("class(")) {
            expression = ns.createClassExpression(
                    expr.substring(6, expr.length()-1),
                    "", exprAutoName
            );
        } else if (expr.startsWith("handler(")) {
            expression = ns.createHandlerExpression(
                    expr.substring(8, expr.length()-1),
                    "", exprAutoName
            );
        } else if (expr.startsWith("attribute(")) {
            expression = ns.createAttributeExpression(
                    expr.substring(10, expr.length()-1),
                    exprAutoName
            );
        } else {
            throw new RuntimeException("unknown anonymous: "+expr);
        }

        // register the expression
        ns.registerExpression(expression);

        return new StringBuffer(exprAutoName);
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

    public Object visit(NotNode node, Object data) {
        return getLeftHS(node, data);
    }

    public Object visit(Identifier node, Object data) {
        ExpressionNamespace space = (ExpressionNamespace)data;
        Expression expression = space.getExpression(node.name);
        if (expression != null) {
            //((TypeVisitorContext)data).addTypes(expression.getType());
            //return expression.getType();
            //TODO AVO allow nested lookup of type ??
            Set set = new HashSet();
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

        }
    }

    public void testBuildExpressionWithTheSamePointcutTypes() {
        try {
            ExpressionNamespace space = ExpressionNamespace.getExpressionNamespace();
            space.registerExpression(
                    space.createExpression("* test.ExpressionTest.set(..)", "", "pc1", PointcutType.EXECUTION)
            );
            space.registerExpression(
                    space.createExpression("* test.ExpressionTest.get(..)", "", "pc2", PointcutType.EXECUTION)
            );
            Expression root = ExpressionNamespace.getExpressionNamespace().createExpression("pc1&&pc2");
        }
        catch (Exception e) {
            fail(e.toString());
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

        }
    }

    public void testBuildExpressionWithDifferentPointcutTypes() {
        try {
            ExpressionNamespace space = ExpressionNamespace.getExpressionNamespace();
            space.registerExpression(
                    space.createExpression("* test.ExpressionTest.set(..)", "", "pc1", PointcutType.EXECUTION)
            );
            space.registerExpression(
                    space.createExpression("call(* test.ExpressionTest.get(..))", "", "pc2"));//implicit type
            Expression root = ExpressionNamespace.getExpressionNamespace().createExpression("pc1 && NOT pc2");
            fail("expected exception");
        }
        catch (Exception e) {
        }
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

        }
    }

    public void testBuildExpressionWithDifferentPointcutTypesButOneIsCflow() {
        try {
            ExpressionNamespace space = ExpressionNamespace.getExpressionNamespace();
            space.registerExpression(
                    space.createExpression("* test.ExpressionTest.set(..)", "", "pc1", PointcutType.EXECUTION)
            );
            space.registerExpression(
                    space.createExpression("* test.ExpressionTest.get(..)", "", "cf1", PointcutType.CFLOW)
            );
            space.registerExpression(
                    space.createExpression("* test.ExpressionTest.get2(..)", "", "cf2", PointcutType.CFLOW)
            );
            Expression root1 = ExpressionNamespace.getExpressionNamespace().createExpression("pc1 AND (cf1 OR cf2)");
            Expression root2 = ExpressionNamespace.getExpressionNamespace().createExpression("pc1 AND cf1");
        }
        catch (Exception e) {
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

        }
    }

    public void testMatchSingleAnonymousExpression() {
        try {
            ExpressionNamespace space = ExpressionNamespace.getExpressionNamespace();
            Expression root = space.createExpression("* test.ExpressionTest.set(..)", PointcutType.EXECUTION);

            Expression rootAnonymous = space.createExpression("execution(* test.ExpressionTest.set(..))");//type autodetection
            Expression rootAnonymous2 = space.createExpression("execution(* test.hierarchicalpattern.DummyInterface1+.testMethod1(..))");//type autodetection

            ClassMetaData classMetaDataTrue = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            ClassMetaData classMetaDataFalse = ReflectionMetaDataMaker.createClassMetaData(ExpressionException.class);
            MethodMetaData methodMetaDataTrue = ReflectionMetaDataMaker.createMethodMetaData(
                    ExpressionTest.class.getDeclaredMethod("set", new Class[]{})
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

    }


    public void testOneLevel_EXECUTION_OR() {
        try {
            ExpressionNamespace space = ExpressionNamespace.getExpressionNamespace();
            space.registerExpression("* test.ExpressionTest.set(..)", "", "pc1", PointcutType.EXECUTION);
            space.registerExpression("* test.ExpressionTest.get(..)", "", "pc2", PointcutType.EXECUTION);

            Expression root = space.createExpression("pc1 || pc2");
            Expression rootAnonymous = space.createExpression("pc1 || execution(* test.ExpressionTest.get(..))");
            Expression rootAnonymousAnonymous = space.createExpression(
                    "execution(* test.ExpressionTest.set(..)) || execution(* test.ExpressionTest.get(..))");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            ClassMetaData classMetaData2 = ReflectionMetaDataMaker.createClassMetaData(ExpressionException.class);
            MethodMetaData methodMetaData1 = ReflectionMetaDataMaker.createMethodMetaData(
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

        }
    }

    public void testOneLevel_EXECUTION_OR_WITHATTRIBUTE() {
        try {
            ExpressionNamespace space = ExpressionNamespace.getExpressionNamespace();
            space.registerExpression("* test.ExpressionTest.set(..)", "", "pc1", PointcutType.EXECUTION);
            space.registerExpression("* test.ExpressionTest.get(..)", "", "pc2", PointcutType.EXECUTION);
            space.registerExpression("ATTR", "", "pc3", PointcutType.ATTRIBUTE);


            Expression root = space.createExpression("pc1 || (pc2 && pc3)");
            Expression rootAnonymous = space.createExpression("pc1 || (execution(* test.ExpressionTest.get(..)) && attribute(ATTR))");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            ClassMetaData classMetaData2 = ReflectionMetaDataMaker.createClassMetaData(ExpressionException.class);
            MethodMetaData methodMetaData1 = ReflectionMetaDataMaker.createMethodMetaData(
                    ExpressionTest.class.getDeclaredMethod("set", new Class[]{})
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

        }
    }

    public void testOneLevel_CALL_OR() {
        try {
            ExpressionNamespace space = ExpressionNamespace.getExpressionNamespace();
            space.registerExpression("*->* test.ExpressionTest.set(..)", "", "pc1", PointcutType.CALL);
            space.registerExpression("*->* test.ExpressionTest.get(..)", "", "pc2", PointcutType.CALL);

            Expression root = space.createExpression("pc1 || pc2");
            Expression rootAnonymous = space.createExpression("pc1 || call(*->* test.ExpressionTest.get(..))");



            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            MethodMetaData methodMetaData1 = ReflectionMetaDataMaker.createMethodMetaData(
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.expression.ExpressionNamespace

//        Boolean isInInOrNotIn = (Boolean)IN_INORNOTIN_EXPR.get();
//        if (isInInOrNotIn.booleanValue()) {
//            ((List)data).add(node.name);
//        }
        CflowIdentifierLookupVisitorContext context = (CflowIdentifierLookupVisitorContext)data;
        ExpressionNamespace space = context.getNamespace();
        Expression expression = space.getExpression(node.name);
        if (expression != null) {
            if (! (expression instanceof LeafExpression)) {
                context.addNames(expression.getCflowExpressions().keySet());
                return data;
            } else {
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.