Package org.codehaus.aspectwerkz

Examples of org.codehaus.aspectwerkz.CrossCuttingInfo


            final String aspectFieldName,
            final CodeVisitor cv,
            final String joinPointClassName) {

        AdviceInfo adviceInfo = adviceMethodInfo.adviceInfo;
        final CrossCuttingInfo info = adviceInfo.getAspectManager().getAspectContainer(adviceInfo.getAspectIndex())
                .getCrossCuttingInfo();
        final String aspectClassName = info.getAspectClass().getName().replace('.', '/');
        final String aspectClassSignature = L + aspectClassName + SEMICOLON;

        // add the aspect field
        cw.visitField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, aspectFieldName, aspectClassSignature, null, null);

        // retrieve the aspect set it to the field
        cv.visitFieldInsn(GETSTATIC, joinPointClassName, SYSTEM_FIELD_NAME, SYSTEM_CLASS_SIGNATURE);
        cv.visitLdcInsn(info.getUuid());
        cv.visitMethodInsn(
                INVOKEVIRTUAL,
                SYSTEM_CLASS_NAME,
                GET_ASPECT_MANAGER_METHOD_NAME,
                GET_ASPECT_MANAGER_METHOD_SIGNATURE
        );
        cv.visitIntInsn(BIPUSH, adviceInfo.getAspectIndex());
        cv.visitMethodInsn(
                INVOKEVIRTUAL,
                ASPECT_MANAGER_CLASS_NAME,
                GET_ASPECT_CONTAINER_METHOD_NAME,
                GET_ASPECT_CONTAINER_METHOD_SIGNATURE
        );
        switch (info.getDeploymentModel()) {
            case DeploymentModel.PER_JVM:
                cv.visitMethodInsn(
                        INVOKEINTERFACE,
                        ASPECT_CONTAINER_CLASS_NAME,
                        GET_PER_JVM_ASPECT_METHOD_NAME,
                        GET_PER_JVM_ASPECT_METHOD_SIGNATURE
                );
                break;
            case DeploymentModel.PER_CLASS:
                cv.visitFieldInsn(GETSTATIC, joinPointClassName, TARGET_CLASS_FIELD_NAME, CLASS_CLASS_SIGNATURE);
                cv.visitMethodInsn(
                        INVOKEINTERFACE,
                        ASPECT_CONTAINER_CLASS_NAME,
                        GET_PER_CLASS_ASPECT_METHOD_NAME,
                        GET_PER_CLASS_ASPECT_METHOD_SIGNATURE
                );
                break;
            default:
                throw new UnsupportedOperationException(
                        "unsupported deployment model - " +
                        aspectFieldName + " " +
                        DeploymentModel.getDeploymentModelAsString(info.getDeploymentModel())
                );
        }
        cv.visitTypeInsn(CHECKCAST, aspectClassName);
        cv.visitFieldInsn(PUTSTATIC, joinPointClassName, aspectFieldName, aspectClassSignature);
        return false;
View Full Code Here


            } else {
                deploymentModel = DeploymentModel.getDeploymentModelAsInt(aspectDef.getDeploymentModel());
            }

            //TODO: we could set the WHOLE AspectManager that defines the Aspect instead
            final CrossCuttingInfo crossCuttingInfoPrototype = new CrossCuttingInfo(
                    aspectManager.getUuid(),
                    aspectClass, aspectDef.getName(),
                    deploymentModel, aspectDef,
                    parameters
            );
            final AspectContainer container = createAspectContainer(crossCuttingInfoPrototype);
            crossCuttingInfoPrototype.setContainer(container);
            PointcutManager pointcutManager = new PointcutManager(aspectDef.getName(), deploymentModel);
            aspectManager.register(container, pointcutManager);
        } catch (Exception e) {
            throw new WrappedRuntimeException(e);
        }
View Full Code Here

        aspectDef.setDeploymentModel(DeploymentModel.getDeploymentModelAsString(deploymentModel));

        // parse the class attributes and create a definition
        AspectAnnotationParser.parse(aspectClass, aspectDef, m_definition);
        m_definition.addAspect(aspectDef);
        CrossCuttingInfo crossCuttingInfo = new CrossCuttingInfo(
            null,
            aspectClass,
            aspectDef.getName(),
            deploymentModel,
            aspectDef,
            new HashMap());
        AspectContainer container = StartupManager.createAspectContainer(crossCuttingInfo);
        crossCuttingInfo.setContainer(container);
        m_aspectRegistry.register(container, new PointcutManager(name, deploymentModel));
    }
View Full Code Here

        final AdviceInfo adviceTuple,
        final ClassWriter cw,
        final String aspectFieldName,
        final CodeVisitor cv,
        final String className) {
        final CrossCuttingInfo info = adviceTuple.getAspectManager().getAspectContainer(adviceTuple.getAspectIndex())
                .getCrossCuttingInfo();
        final String aspectClassName = info.getAspectClass().getName().replace('.', '/');
        final String aspectClassSignature = L + aspectClassName + SEMICOLON;

        // add the aspect field
        cw.visitField(Constants.ACC_PRIVATE, aspectFieldName, aspectClassSignature, null, null);

        // handle the init in the constructor
        cv.visitVarInsn(Constants.ALOAD, 0);
        cv.visitVarInsn(Constants.ALOAD, 0);
        cv.visitFieldInsn(Constants.GETFIELD, className, SYSTEM_FIELD_NAME, SYSTEM_CLASS_SIGNATURE);
        cv.visitLdcInsn(adviceTuple.getAspectManager().getUuid());
        cv.visitMethodInsn(
            Constants.INVOKEVIRTUAL,
            SYSTEM_CLASS_NAME,
            GET_ASPECT_MANAGER_METHOD_NAME,
            GET_ASPECT_MANAGER_METHOD_NAME_SIGNATURE);
        cv.visitIntInsn(Constants.BIPUSH, adviceTuple.getAspectIndex());
        cv.visitMethodInsn(
            Constants.INVOKEVIRTUAL,
            ASPECT_MANAGER_CLASS_NAME,
            GET_ASPECT_CONTAINER_METHOD_NAME,
            GET_ASPECT_METHOD_SIGNATURE);
        switch (info.getDeploymentModel()) {
            case DeploymentModel.PER_JVM:
                cv.visitMethodInsn(
                    Constants.INVOKEINTERFACE,
                    ASPECT_CONTAINER_CLASS_NAME,
                    GET_PER_JVM_ASPECT_METHOD_NAME,
View Full Code Here

            synchronized (m_aspectIndexes) {
                synchronized (m_adviceIndexes) {
                    synchronized (m_mixins) {
                        synchronized (m_pointcutManagerMap) {
                            try {
                                CrossCuttingInfo crossCuttingInfo = aspectContainer.getCrossCuttingInfo();
                                m_pointcutManagerMap.put(crossCuttingInfo.getName(), pointcutManager);
                                final int indexAspect = m_aspectContainers.length + 1;
                                m_aspectIndexes.put(crossCuttingInfo.getName(), indexAspect);
                                final Object[] tmpAspects = new Object[m_aspectContainers.length + 1];
                                java.lang.System.arraycopy(
                                    m_aspectContainers,
                                    0,
                                    tmpAspects,
                                    0,
                                    m_aspectContainers.length);
                                tmpAspects[m_aspectContainers.length] = aspectContainer;
                                m_aspectContainers = new AspectContainer[m_aspectContainers.length + 1];
                                java.lang.System.arraycopy(tmpAspects, 0, m_aspectContainers, 0, tmpAspects.length);

                                // retrieve a sorted advices list => matches the sorted method list
                                // in the
                                // aspectContainer
                                List advices = crossCuttingInfo.getAspectDefinition().getAllAdvices();
                                for (Iterator it = advices.iterator(); it.hasNext();) {
                                    final AdviceDefinition adviceDef = (AdviceDefinition) it.next();
                                    AdviceInfo tuple = new AdviceInfo(
                                        indexAspect,
                                        adviceDef.getMethodIndex(),
                                        m_aspectManager,
                                        adviceDef.getType(),
                                        adviceDef.getSpecialArgumentType());

                                    //prefix AdviceName with AspectName to allow AspectReuse
                                    m_adviceIndexes.put(crossCuttingInfo.getName() + "/" + adviceDef.getName(), tuple);
                                }

                                // mixins
                                List introductions = crossCuttingInfo.getAspectDefinition().getIntroductions();

                                for (Iterator it = introductions.iterator(); it.hasNext();) {
                                    IntroductionDefinition introDef = (IntroductionDefinition) it.next();

                                    // load default mixinPrototype impl from the aspect which
                                    // defines it
                                    Class defaultImplClass = crossCuttingInfo.getAspectClass().getClassLoader()
                                            .loadClass(introDef.getName());

                                    Introduction mixinPrototype = new Introduction(
                                        introDef.getName(),
                                        defaultImplClass,
View Full Code Here

            } else {
                deploymentModel = DeploymentModel.getDeploymentModelAsInt(aspectDef.getDeploymentModel());
            }

            //TODO: we could set the WHOLE AspectManager that defines the Aspect instead
            final CrossCuttingInfo crossCuttingInfoPrototype = new CrossCuttingInfo(
                aspectManager.getUuid(),
                aspectClass,
                aspectDef.getName(),
                deploymentModel,
                aspectDef,
                parameters);
            final AspectContainer container = createAspectContainer(crossCuttingInfoPrototype);
            crossCuttingInfoPrototype.setContainer(container);
            PointcutManager pointcutManager = new PointcutManager(aspectDef.getName(), deploymentModel);
            aspectManager.register(container, pointcutManager);
        } catch (Exception e) {
            throw new WrappedRuntimeException(e);
        }
View Full Code Here

     * @param className
     */
    private static boolean initAspectField(
            final IndexTuple adviceTuple, final ClassWriter cw,
            final String aspectFieldName, final CodeVisitor cv, final String className) {
        final CrossCuttingInfo info = adviceTuple.getAspectManager().getAspectContainer(adviceTuple.getAspectIndex())
                .getCrossCuttingInfo();
        final String aspectClassName = info.getAspectClass().getName().replace('.', '/');
        final String aspectClassSignature = L + aspectClassName + SEMICOLON;

        // add the aspect field
        cw.visitField(Constants.ACC_PRIVATE, aspectFieldName, aspectClassSignature, null, null);

        // handle the init in the constructor
        cv.visitVarInsn(Constants.ALOAD, 0);
        cv.visitVarInsn(Constants.ALOAD, 0);
        cv.visitFieldInsn(Constants.GETFIELD, className, SYSTEM_FIELD_NAME, SYSTEM_CLASS_SIGNATURE);
        cv.visitLdcInsn(adviceTuple.getAspectManager().getUuid());
        cv.visitMethodInsn(
                Constants.INVOKEVIRTUAL, SYSTEM_CLASS_NAME, GET_ASPECT_MANAGER_METHOD_NAME,
                GET_ASPECT_MANAGER_METHOD_NAME_SIGNATURE
        );
        cv.visitIntInsn(Constants.BIPUSH, adviceTuple.getAspectIndex());
        cv.visitMethodInsn(
                Constants.INVOKEVIRTUAL, ASPECT_MANAGER_CLASS_NAME, GET_ASPECT_CONTAINER_METHOD_NAME,
                GET_ASPECT_METHOD_SIGNATURE
        );
        switch (info.getDeploymentModel()) {
            case DeploymentModel.PER_JVM:
                cv.visitMethodInsn(
                        Constants.INVOKEINTERFACE, ASPECT_CONTAINER_CLASS_NAME,
                        GET_PER_JVM_ASPECT_METHOD_NAME, GET_PER_JVM_ASPECT_METHOD_SIGNATURE
                );
View Full Code Here

        aspectDef.setDeploymentModel(DeploymentModel.getDeploymentModelAsString(deploymentModel));

        // parse the class attributes and create a definition
        m_annotationParser.parse(aspectClass, aspectDef, m_definition);
        m_definition.addAspect(aspectDef);
        CrossCuttingInfo crossCuttingInfo = new CrossCuttingInfo(
                null, aspectClass, aspectDef.getName(),
                deploymentModel, aspectDef, new HashMap()
        );
        AspectContainer container = StartupManager.createAspectContainer(crossCuttingInfo);
        crossCuttingInfo.setContainer(container);
        m_aspectRegistry.register(container, new PointcutManager(name, deploymentModel));
    }
View Full Code Here

            synchronized (m_aspectIndexes) {
                synchronized (m_adviceIndexes) {
                    synchronized (m_mixins) {
                        synchronized (m_pointcutManagerMap) {
                            try {
                                CrossCuttingInfo crossCuttingInfo = aspectContainer.getCrossCuttingInfo();
                                m_pointcutManagerMap.put(crossCuttingInfo.getName(), pointcutManager);
                                final int indexAspect = m_aspectContainers.length + 1;
                                m_aspectIndexes.put(crossCuttingInfo.getName(), indexAspect);
                                final Object[] tmpAspects = new Object[m_aspectContainers.length + 1];
                                java.lang.System.arraycopy(
                                        m_aspectContainers, 0, tmpAspects, 0,
                                        m_aspectContainers.length
                                );
                                tmpAspects[m_aspectContainers.length] = aspectContainer;
                                m_aspectContainers = new AspectContainer[m_aspectContainers.length + 1];
                                java.lang.System.arraycopy(tmpAspects, 0, m_aspectContainers, 0, tmpAspects.length);

                                // retrieve a sorted advices list => matches the sorted method list in the aspectContainer
                                List advices = crossCuttingInfo.getAspectDefinition().getAllAdvices();
                                for (Iterator it = advices.iterator(); it.hasNext();) {
                                    final AdviceDefinition adviceDef = (AdviceDefinition)it.next();
                                    IndexTuple tuple = new IndexTuple(
                                            indexAspect, adviceDef.getMethodIndex(),
                                            m_aspectManager
                                    );

                                    //prefix AdviceName with AspectName to allow AspectReuse
                                    m_adviceIndexes.put(crossCuttingInfo.getName() + "/" + adviceDef.getName(), tuple);
                                }

                                // mixins
                                List introductions = crossCuttingInfo.getAspectDefinition().getIntroductions();
                                for (Iterator it = introductions.iterator(); it.hasNext();) {
                                    IntroductionDefinition introDef = (IntroductionDefinition)it.next();

                                    // load default mixinPrototype impl from the aspect which defines it
                                    Class defaultImplClass = crossCuttingInfo.getAspectClass().getClassLoader()
                                            .loadClass(introDef.getName());
                                    Introduction mixinPrototype = new Introduction(
                                            introDef.getName(),
                                            defaultImplClass, crossCuttingInfo,
                                            introDef
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.CrossCuttingInfo

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.