Package org.codehaus.aspectwerkz.definition

Examples of org.codehaus.aspectwerkz.definition.SystemDefinition


     */
    public void transform(final Context context, final Klass klass) throws NotFoundException, CannotCompileException {

        // loop over all the definitions
        for (Iterator it = m_definitions.iterator(); it.hasNext();) {
            SystemDefinition definition = (SystemDefinition)it.next();

            final CtClass ctClass = klass.getCtClass();
            ClassMetaData classMetaData = JavassistMetaDataMaker.createClassMetaData(ctClass);

            // do we need to prepare the class
View Full Code Here


     *
     * @param clazz
     */
    private static void makeProxyAdvisable(final Class clazz) {
        // changes occurs in the virtual definition only
        SystemDefinition definition = SystemDefinitionContainer.getVirtualDefinitionAt(clazz.getClassLoader());
        addAdvisableDefToSystemDef(clazz, definition);
    }
View Full Code Here

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

        Set definitions = SystemDefinitionContainer.getDefinitionsFor(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.getDefinitionsFor(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, final ClassLoader mixinCalledFromLoader) {
        MixinDefinition mixinDefinition = null;

        Set definitions = SystemDefinitionContainer.getDefinitionsFor(mixinCalledFromLoader);
        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



        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());



        /*

 
View Full Code Here



        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();) {
View Full Code Here

        //AXm_joinPointIndex =
        // TransformationUtil.getJoinPointIndex(klass.getCtClass()); //TODO
        // thread safe and reentrant
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.EXECUTION, classInfo, classInfo), ctClass)) {
                continue;
            }
View Full Code Here

    public void transform(final Context context, final Klass klass) {
        List definitions = context.getDefinitions();

        // loop over all the definitions
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            ExpressionContext ctx = new ExpressionContext(PointcutType.ANY, classInfo, classInfo);
            if (classFilter(ctClass, ctx, definition)) {
                continue;
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, classInfo, 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 = TransformationUtil.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.