Package org.codehaus.aspectwerkz.definition

Examples of org.codehaus.aspectwerkz.definition.SystemDefinition


        final List afterThrowingAdvices = new ArrayList();

        final Set systemDefinitions = SystemDefinitionContainer.getRegularAndVirtualDefinitionsFor(loader);

        for (Iterator iterator = systemDefinitions.iterator(); iterator.hasNext();) {
            SystemDefinition systemDefinition = (SystemDefinition) iterator.next();
            Collection aspects = systemDefinition.getAspectDefinitions();
            for (Iterator iterator1 = aspects.iterator(); iterator1.hasNext();) {
                AspectDefinition aspectDefinition = (AspectDefinition) iterator1.next();
                if (aspectDefinition.getName().equals(Virtual.class.getName())) {
                    continue;
                }
View Full Code Here


            throw new IllegalArgumentException("class to parse can not be null");
        }
        if (classInfo == null) {
            throw new IllegalArgumentException("class can not be null");
        }
        final SystemDefinition systemDef = mixinDef.getSystemDefinition();
        final List annotations = AsmAnnotations.getAnnotations(AOPAnnotationConstants.ANNOTATION_MIXIN(), classInfo);
        for (Iterator iterator = annotations.iterator(); iterator.hasNext();) {
            Mixin annotation = (Mixin) iterator.next();
            if (annotation != null) {
                String expression = AspectAnnotationParser.getExpressionElseValue(
                        annotation.value(), annotation.pointcut()
                );
                final ExpressionInfo expressionInfo = new ExpressionInfo(expression, systemDef.getUuid());
                ExpressionNamespace.getNamespace(systemDef.getUuid()).addExpressionInfo(
                        DefinitionParserHelper.EXPRESSION_PREFIX + expression.hashCode(),
                        expressionInfo
                );
                mixinDef.addExpressionInfo(expressionInfo);
                mixinDef.setTransient(annotation.isTransient());
View Full Code Here

    private static AspectContainer createAspectContainer(final Class aspectClass) {
        AspectDefinition aspectDefinition = null;

        Set definitions = SystemDefinitionContainer.getRegularAndVirtualDefinitionsFor(aspectClass.getClassLoader());
        for (Iterator iterator = definitions.iterator(); iterator.hasNext() && aspectDefinition == null;) {
            SystemDefinition systemDefinition = (SystemDefinition) iterator.next();
            for (Iterator iterator1 = systemDefinition.getAspectDefinitions().iterator(); iterator1.hasNext();) {
                AspectDefinition aspectDef = (AspectDefinition) iterator1.next();
                if (aspectClass.getName().replace('/', '.').equals(aspectDef.getClassName())) {
                    aspectDefinition = aspectDef;
                    break;
                }
View Full Code Here

        final Set definitionsBottomUp = SystemDefinitionContainer.getRegularAndVirtualDefinitionsFor(loader);
        // TODO: bottom up is broken now
        //Collections.reverse(definitionsBottomUp);

        for (Iterator iterator = definitionsBottomUp.iterator(); iterator.hasNext();) {
            SystemDefinition definition = (SystemDefinition) iterator.next();
            for (Iterator iterator1 = definition.getAspectDefinitions().iterator(); iterator1.hasNext();) {
                AspectDefinition aspectDefinition = (AspectDefinition) iterator1.next();
                if (qualifiedName.equals(aspectDefinition.getQualifiedName())) {
                    return aspectDefinition.getClassName();
                }
            }
View Full Code Here

    private static MixinFactory createMixinFactory(final Class mixinClass) {
        MixinDefinition mixinDefinition = null;

        Set definitions = SystemDefinitionContainer.getRegularAndVirtualDefinitionsFor(mixinClass.getClassLoader());
        for (Iterator iterator = definitions.iterator(); iterator.hasNext() && mixinDefinition == null;) {
            SystemDefinition systemDefinition = (SystemDefinition) iterator.next();
            for (Iterator iterator1 = systemDefinition.getMixinDefinitions().iterator(); iterator1.hasNext();) {
                MixinDefinition mixinDef = (MixinDefinition) iterator1.next();
                if (mixinClass.getName().replace('/', '.').equals(mixinDef.getMixinImpl().getName())) {
                    mixinDefinition = mixinDef;
                    break;
                }
View Full Code Here

     */
    public static void addPointcutForLoggingAdvice(String pointcut, String pointcutName) {
        //if (true) return;

        final String aspectName = "examples.logging.JavaLoggingAspect";
        SystemDefinition sysDef = DefinitionLoader.getDefinition(HotSwapTarget.class.getClassLoader(), "hotdeployed");
        AspectDefinition aspectDef = sysDef.getAspectDefinition(aspectName);
        ExpressionNamespace namespace = ExpressionNamespace.getNamespace(aspectDef.getFullQualifiedName());
        ExpressionInfo expressionInfo = new ExpressionInfo(pointcut, aspectDef.getFullQualifiedName());
        namespace.addExpressionInfo(pointcutName, expressionInfo);
        AdviceDefinition newDef = null;
        for (Iterator arounds = aspectDef.getAroundAdvices().iterator(); arounds.hasNext();) {
            AdviceDefinition around = (AdviceDefinition)arounds.next();
            if (around.getName().equals(aspectName + ".logMethod")) {
                // copy the logMethod advice
                // note: we could add a totally new advice as well
                newDef = around.copyAt(expressionInfo);
                break;
            }
        }
        aspectDef.addAroundAdvice(newDef);

        //TODO: experimental API
        StartupManager.reinitializeSystem(HotSwapTarget.class.getClassLoader(), sysDef);
        System.out.println("sysDef = " + sysDef.getClass().getClassLoader());

        /*
        ExecutionPointcut pointcutInstance = new ExecutionPointcut("samples", newDef.getExpression());
        PointcutManager pointcutManager = SystemLoader.getSystem("samples").
                getAspectManager().getPointcutManager(aspectName);
View Full Code Here

     */
    public static void removePointcutForLoggingAdvice(String pointcut, String pointcutName) {
        //if (true) return;

        final String aspectName = "examples.logging.JavaLoggingAspect";
        SystemDefinition sysDef = DefinitionLoader.getDefinition(HotSwapTarget.class.getClassLoader(), "hotdeployed");
        AspectDefinition aspectDef = sysDef.getAspectDefinition(aspectName);
        List removedAdviceDefs = new ArrayList();
        for (Iterator arounds = aspectDef.getAroundAdvices().iterator(); arounds.hasNext();) {
            AdviceDefinition around = (AdviceDefinition)arounds.next();
            if (pointcutName.equals(around.getExpressionInfo().getExpressionAsString())) {
                System.out.println("<removing> " + around.getName() + " at " + pointcutName);
View Full Code Here

            System.arraycopy(parentAspectManagers, 0, m_aspectManagers, 0, parentAspectManagers.length);
        }

        // note: we should be able to go directly to the correct index instead of this loop and check
        for (int i = 0; i < m_aspectManagers.length; i++) {
            SystemDefinition def = (SystemDefinition)definitions.get(i);
            String uuid = def.getUuid();

            // check if the SystemDefinition comes from a parent AspectSystem before adding it
            AspectManager aspectManager = null;
            try {
                aspectManager = getAspectManager(uuid);
View Full Code Here

     * @param definitions
     * @TODO AVAOPC algo is crapped, check earlier and avoid exception but do a WARN (in SysDefContainer)
     */
    private static void assertUuidUniqueWithinHierarchy(final List definitions) {
        for (int i = 0; i < definitions.size(); i++) {
            SystemDefinition systemDefinition = (SystemDefinition)definitions.get(i);
            for (int j = 0; j < definitions.size(); j++) {
                if (j == i) {
                    continue;
                }
                SystemDefinition systemDefinition2 = (SystemDefinition)definitions.get(j);
                if (systemDefinition2.getUuid().equals(systemDefinition.getUuid())) {
                    throw new DefinitionException(
                            "UUID is not unique within hierarchy: " + systemDefinition.getUuid()
                    );
                }
            }
View Full Code Here

        //AXm_joinPointIndex =
        // TransformationUtil.getJoinPointIndex(klass.getCtClass()); //TODO is
        // not thread safe / reentrant
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            final SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.CALL, null, classInfo), ctClass)) {
                continue;
            }
            ctClass.instrument(new ExprEditor() {
                public void edit(NewExpr newExpr) throws CannotCompileException {
                    try {
                        CtBehavior where = null;
                        try {
                            where = newExpr.where();
                        } catch (RuntimeException e) {
                            // <clinit> access leads to a bug in Javassist
                            where = ctClass.getClassInitializer();
                        }

                        // filter caller methods
                        if (methodFilterCaller(where)) {
                            return;
                        }
                        CtConstructor ctConstructor = newExpr.getConstructor();
                        String calleeClassName = newExpr.getClassName();

                        // filter callee classes
                        if (!definition.inIncludePackage(calleeClassName)) {
                            return;
                        }

                        // filter the constructors
                        if (constructorFilter(ctConstructor)) {
                            return;
                        }

                        // create the caller method info
                        MemberInfo withinMethodInfo = null;
                        if (where instanceof CtMethod) {
                            withinMethodInfo = JavassistMethodInfo.getMethodInfo((CtMethod) where, context.getLoader());
                        } else if (where instanceof CtConstructor) {
                            withinMethodInfo = JavassistConstructorInfo.getConstructorInfo(
                                (CtConstructor) where,
                                context.getLoader());
                        }

                        // create the constructor info
                        CtConstructor constructor = newExpr.getConstructor();
                        ConstructorInfo calleeSideConstructorInfo = JavassistConstructorInfo.getConstructorInfo(
                            constructor,
                            context.getLoader());
                        ExpressionContext ctx = new ExpressionContext(
                            PointcutType.CALL,
                            calleeSideConstructorInfo,
                            withinMethodInfo);

                        // is this a caller side method pointcut?
                        if (definition.hasPointcut(ctx)) {
                            // check the callee class is not the same as target
                            // class, if that is the case
                            // then we have have class loaded and set in the
                            // ___AW_clazz already
                            String declaringClassMethodName = TransformationConstants.STATIC_CLASS_FIELD;
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.definition.SystemDefinition

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.