Package org.codehaus.aspectwerkz.definition

Examples of org.codehaus.aspectwerkz.definition.IntroductionDefinition


        if (newImplementationClass == null) {
            throw new IllegalArgumentException("new implementation class class can not be null");
        }

        // check compatibility
        IntroductionDefinition def = m_prototype.getIntroductionDefinition();
        for (Iterator intfs = def.getInterfaceClassNames().iterator(); intfs.hasNext();) {
            if (!findInterfaceInHierarchy(newImplementationClass, (String)intfs.next())) {
                throw new DefinitionException("new implementation class is not compatible");
            }
        }
View Full Code Here


                isClassAdvised = true;
            }
        }
        List introDefs = definition.getIntroductionDefinitions(ctx);
        for (Iterator it = introDefs.iterator(); it.hasNext();) {
            IntroductionDefinition introductionDef = (IntroductionDefinition) it.next();
            List interfaceClassNames = introductionDef.getInterfaceClassNames();
            if (addInterfaces(interfaceClassNames, ctClass)) {
                isClassAdvised = true;
            }
        }
        if (isClassAdvised) {
View Full Code Here

        final ExpressionContext ctx,
        final CtClass ctClass) {
        List introductionDefs = definition.getIntroductionDefinitions(ctx);
        boolean isClassAdvised = false;
        for (Iterator it = introductionDefs.iterator(); it.hasNext();) {
            IntroductionDefinition introDef = (IntroductionDefinition) it.next();
            int methodIndex = 0;
            List methodsToIntroduce = introDef.getMethodsToIntroduce();
            for (Iterator mit = methodsToIntroduce.iterator(); mit.hasNext(); methodIndex++) {
                MethodInfo methodToIntroduce = (MethodInfo) mit.next();
                if (methodToIntroduce == null) {
                    continue;
                }
                createProxyMethod(
                    ctClass,
                    methodToIntroduce,
                    definition.getMixinIndexByName(introDef.getName()),
                    methodIndex,
                    definition,
                    context);
                isClassAdvised = true;
            }
View Full Code Here

                                // 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);
                                    IntroductionContainer introductionContainer = new IntroductionContainer(
                                        mixinPrototype,
                                        aspectContainer);
                                    aspectContainer.addIntroductionContainer(introDef.getName(), introductionContainer);

                                    // prepare the aspectContainer
                                    mixinPrototype.setContainer(introductionContainer);
                                    final Mixin[] tmpMixins = new Mixin[m_mixins.length + 1];
                                    java.lang.System.arraycopy(m_mixins, 0, tmpMixins, 0, m_mixins.length);
View Full Code Here

        if (newImplementationClass == null) {
            throw new IllegalArgumentException("new implementation class class can not be null");
        }

        // check compatibility
        IntroductionDefinition def = m_prototype.getIntroductionDefinition();
        for (Iterator intfs = def.getInterfaceClassNames().iterator(); intfs.hasNext();) {
            if (!findInterfaceInHierarchy(newImplementationClass, (String)intfs.next())) {
                throw new DefinitionException("new implementation class is not compatible");
            }
        }
View Full Code Here

            final AddImplementationTransformer transformer) {

        List introductionDefs = definition.getIntroductionDefinitions(classMetaData);
        boolean isClassAdvised = false;
        for (Iterator it = introductionDefs.iterator(); it.hasNext();) {
            IntroductionDefinition introDef = (IntroductionDefinition)it.next();
            int methodIndex = 0;
            for (Iterator mit = introDef.getMethodIntroductions().iterator(); mit.hasNext(); methodIndex++) {
                int mixinIndex = definition.getMixinIndexByName(introDef.getName());
                isClassAdvised = true;
                //TODO any use case for a method already implemented ?
                transformer.createProxyMethod(
                        ctClass,
                        (MethodMetaData)mit.next(),
View Full Code Here

                                }

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

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

                                    // prepare the container
                                    mixin.setContainer(new IntroductionContainer(mixin, container));
View Full Code Here

    public void testIntroductionTag() {
        try {
            AspectWerkzDefinition aspectwerkz = XmlDefinitionParser.parseNoCache(m_input.toURL());
            Iterator it = aspectwerkz.getIntroductionDefinitions().iterator();
            IntroductionDefinition introduction2 = (IntroductionDefinition)it.next();
            assertEquals("mixin", introduction2.getName());
            assertEquals("mixins.Mixin", introduction2.getInterface());
            assertEquals("mixins.MixinImpl", introduction2.getImplementation());
            assertEquals("perInstance", introduction2.getDeploymentModel());
            assertEquals("attribute", introduction2.getAttribute());
        }
        catch (Exception e) {
            System.out.println("e = " + e);
            fail();
        }
View Full Code Here

     * @param definition the AspectWerkz definition
     */
    private static void handleIntroductionDefinitions(final Element root,
                                                      final AspectWerkzDefinition definition) {
        for (Iterator it = definition.getIntroductionDefinitions().iterator(); it.hasNext();) {
            IntroductionDefinition def = (IntroductionDefinition)it.next();
            addIntroductionDefElement(root, def);
        }
    }
View Full Code Here

        for (int i = 0; i < introductionDefTags.length; i++) {
            if (introductionDefTags[i] == null) {
                continue;
            }

            IntroductionDefinition introDef = new IntroductionDefinition();
            introDef.setName(introductionDefTags[i].getNamedParameter("name"));
            introDef.setInterface(javaClass.getFullyQualifiedName());
            introDef.setImplementation(introductionDefTags[i].getNamedParameter("implementation"));
            introDef.setDeploymentModel(introductionDefTags[i].getNamedParameter("deployment-model"));
            introDef.setIsPersistent(introductionDefTags[i].getNamedParameter("persistent"));
            introDef.setAttribute(introductionDefTags[i].getNamedParameter("attribute"));

            definition.addIntroduction(introDef);
        }
    }
View Full Code Here

TOP

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

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.