Package org.codehaus.aspectwerkz.metadata

Examples of org.codehaus.aspectwerkz.metadata.MethodMetaData$NullMethodMetaData


                    getDeploymentModel());
            assertEquals("createTransientAdviceTest", ((XmlDefSystem)SystemLoader.getSystem("tests")).
                    getAdvice("createTransientAdviceTest").getName());

            // test it in action
            MethodMetaData methodMetaData = new MethodMetaData();
            methodMetaData.setName("createTransientAdviceTestMethod");
            methodMetaData.setParameterTypes(new String[]{});
            methodMetaData.setReturnType("void");
            methodMetaData.setExceptionTypes(new String[]{});

            ((ExecutionPointcut)SystemLoader.getSystem("tests").getAspectMetaData("DynamicDeploymentTest").
                    getExecutionPointcuts(m_classMetaData, methodMetaData).
                    get(0)).addAdvice("createTransientAdviceTest");
View Full Code Here


    public void testAddAdviceAtRuntime() {
        m_logString = "";
        addAdviceTestMethod();
        assertEquals("before1 invocation after1 ", m_logString);

        MethodMetaData methodMetaData = new MethodMetaData();
        methodMetaData.setName("addAdviceTestMethod");
        methodMetaData.setParameterTypes(new String[]{});
        methodMetaData.setReturnType("void");
        methodMetaData.setExceptionTypes(new String[]{});

        ((ExecutionPointcut)SystemLoader.getSystem("tests").getAspectMetaData("DynamicDeploymentTest").
                getExecutionPointcuts(m_classMetaData, methodMetaData).get(0)).addAdvice("methodAdvice3");

        m_logString = "";
View Full Code Here

    public void testRemoveAdviceAtRuntime() {
        m_logString = "";
        removeAdviceTestMethod();
        assertEquals("before1 before2 before2 invocation after2 after2 after1 ", m_logString);

        MethodMetaData methodMetaData = new MethodMetaData();
        methodMetaData.setName("removeAdviceTestMethod");
        methodMetaData.setParameterTypes(new String[]{});
        methodMetaData.setReturnType("void");
        methodMetaData.setExceptionTypes(new String[]{});

        List advices = ((ExecutionPointcut)SystemLoader.getSystem("tests").getAspectMetaData("DynamicDeploymentTest").
                getExecutionPointcuts(m_classMetaData, methodMetaData).get(0)).
                getAdviceIndexTuples();
        NameIndexTuple adviceTuple0 = (NameIndexTuple)advices.remove(0);
View Full Code Here

    public void testAddAdviceAtRuntime() {
        m_logString = "";
        addAdviceTestMethod();
        assertEquals("before1 invocation after1 ", m_logString);

        MethodMetaData methodMetaData = new MethodMetaData();
        methodMetaData.setName("addAdviceTestMethod");
        methodMetaData.setParameterTypes(new String[]{});
        methodMetaData.setReturnType("void");
        methodMetaData.setExceptionTypes(new String[]{});

        ExecutionPointcut methodPointcut = (ExecutionPointcut)SystemLoader.getSystem("tests").
                getAspectMetaData(ASPECT_NAME).
                getExecutionPointcuts(m_classMetaData, methodMetaData).get(0);
View Full Code Here

    public void testRemoveAdviceAtRuntime() {
        m_logString = "";
        removeAdviceTestMethod();
        assertEquals("before1 before2 invocation after2 after1 ", m_logString);

        MethodMetaData methodMetaData = new MethodMetaData();
        methodMetaData.setName("removeAdviceTestMethod");
        methodMetaData.setParameterTypes(new String[]{});
        methodMetaData.setReturnType("void");
        methodMetaData.setExceptionTypes(new String[]{});

        ExecutionPointcut methodPointcut = (ExecutionPointcut)SystemLoader.getSystem("tests").
                getAspectMetaData(ASPECT_NAME).
                getExecutionPointcuts(m_classMetaData, methodMetaData).get(0);
View Full Code Here

                    SystemLoader.getSystem("tests").
                    getAspectMetaData(NEW_ASPECT_NAME).
                    getName());

            // test an advice from the aspect in action
            MethodMetaData methodMetaData = new MethodMetaData();
            methodMetaData.setName("createAspectTestMethod");
            methodMetaData.setParameterTypes(new String[]{});
            methodMetaData.setReturnType("void");
            methodMetaData.setExceptionTypes(new String[]{});

            // get an existing pointcut
            ExecutionPointcut methodPointcut = (ExecutionPointcut)SystemLoader.getSystem("tests").
                    getAspectMetaData(ASPECT_NAME).
                    getExecutionPointcuts(m_classMetaData, methodMetaData).
View Full Code Here

            // build and sort the method lookup list
            final List methodLookupList = new ArrayList();
            for (int i = 0; i < methods.length; i++) {
                Method method = methods[i];

                MethodMetaData methodMetaData = BcelMetaDataMaker.createMethodMetaData(methods[i]);
                if (methodFilter(definition, classMetaData, methodMetaData, method)) {
                    continue;
                }
                methodLookupList.add(methods[i]);

                // TODO: does not work, needs to be thought through more
                // if advised swap add the prefixed one as well to enable second-round instrumentation
//                String originalPrefixedName =
//                        TransformationUtil.ORIGINAL_METHOD_PREFIX +
//                        methods[i].getName();
//                Method[] declaredMethods = cg.getMethods();
//                for (int j = 0; j < declaredMethods.length; j++) {
//                    Method declaredMethod = declaredMethods[j];
//                    if (declaredMethod.getName().startsWith(originalPrefixedName)) {
//                        methodLookupList.add(declaredMethod);
//                    }
//                }
            }

            Collections.sort(methodLookupList, BCELMethodComparator.getInstance());

            final Map methodSequences = new HashMap();
            final List newMethods = new ArrayList();
            Method clInitMethod = null;
            boolean isClassAdvised = false;

            for (int i = 0; i < methods.length; i++) {
                Method method = methods[i];
                MethodMetaData methodMetaData = BcelMetaDataMaker.createMethodMetaData(method);

                if (methodFilter(definition, classMetaData, methodMetaData, method)
                        || !method.isStatic()) {
                    continue;
                }

                isClassAdvised = true;

                // TODO: does not work, needs to be thought through more
                // if advised swap the method to the prefixed one
//                String originalPrefixedName =
//                        TransformationUtil.ORIGINAL_METHOD_PREFIX +
//                        methods[i].getName();
//                Method[] declaredMethods = cg.getMethods();
//                for (int j = 0; j < declaredMethods.length; j++) {
//                    Method declaredMethod = declaredMethods[j];
//                    if (declaredMethod.getName().startsWith(originalPrefixedName)) {
//                        method = declaredMethod;
//                    }
//                }

                final MethodGen mg = new MethodGen(method, cg.getClassName(), cpg);

                // take care of identification of overloaded methods by
                // inserting a sequence number
                if (methodSequences.containsKey(method.getName())) {
                    int sequence = ((Integer)methodSequences.get(methods[i].getName())).intValue();
                    methodSequences.remove(method.getName());
                    sequence++;
                    methodSequences.put(method.getName(), new Integer(sequence));
                }
                else {
                    methodSequences.put(method.getName(), new Integer(1));
                }

                final int methodLookupId = methodLookupList.indexOf(method);
                final int methodSequence = ((Integer)methodSequences.get(method.getName())).intValue();

                addStaticJoinPointField(cpg, cg, mg, methodSequence);

                // get the join point controller
                final String controllerClassName = definition.getJoinPointController(
                        classMetaData, methodMetaData
                );

                if (noClinitMethod) {
                    // no <clinit> method exists
                    if (clInitMethod == null) {
                        clInitMethod = createClInitMethodWithStaticJoinPointField(
                                cpg, cg,
                                method,
                                factory,
                                methodSequence
                        );
                    }
                    else {
                        clInitMethod = createStaticJoinPointField(
                                cpg, cg, clInitMethod,
                                method,
                                factory,
                                methodSequence
                        );
                    }
                }
                else {
                    // we have a <clinit> method
                    methods[indexClinit] = createStaticJoinPointField(
                            cpg, cg, methods[indexClinit],
                            method,
                            factory,
                            methodSequence
                    );
                }

                // create a proxy method for the original method
                newMethods.add(createProxyMethod(
                        cpg, cg,
                        methodMetaData.getName(),
                        mg, factory,
                        methodLookupId,
                        methodSequence,
                        method.getAccessFlags(),
                        definition.getUuid(),
View Full Code Here

            // the iterator is on a list and the loop body does list.remove
            // which is forbidden
            List methodMetaDataListFiltered = new ArrayList();
            for (Iterator it2 = methodMetaDataList.iterator(); it2.hasNext();) {
                MethodMetaData methodMetaData = (MethodMetaData)it2.next();

                // remove the ___AW_getUuid, ___AW_getMetaData, ___AW_addMetaData and class$ methods
                // as well as some other methods before sorting the method list
                if (!(
                        methodMetaData.getName().equals("equals") ||
                        methodMetaData.getName().equals("hashCode") ||
                        methodMetaData.getName().equals("getClass") ||
                        methodMetaData.getName().equals("toString") ||
                        methodMetaData.getName().equals("wait") ||
                        methodMetaData.getName().equals("notify") ||
                        methodMetaData.getName().equals("notifyAll") ||
                        methodMetaData.getName().equals(
                                TransformationUtil.GET_UUID_METHOD) ||
                        methodMetaData.getName().equals(
                                TransformationUtil.GET_UUID_METHOD) ||
                        methodMetaData.getName().equals(
                                TransformationUtil.GET_META_DATA_METHOD) ||
                        methodMetaData.getName().equals(
                                TransformationUtil.SET_META_DATA_METHOD) ||
                        methodMetaData.getName().equals(
                                TransformationUtil.CLASS_LOOKUP_METHOD) ||
                        methodMetaData.getName().startsWith(
                                TransformationUtil.ORIGINAL_METHOD_PREFIX))) {
                    methodMetaDataListFiltered.add(methodMetaData);
                }
            }

            // sort the list so that we can enshure that the indexes are in synch
            // see AbstractIntroductionContainerStrategy#AbstractIntroductionContainerStrategy
            Collections.sort(methodMetaDataListFiltered, MethodComparator.
                    getInstance(MethodComparator.METHOD_META_DATA));

            int methodIndex = -1; // start with -1 since the method array is 0 indexed
            for (Iterator it2 = methodMetaDataListFiltered.iterator(); it2.hasNext();) {
                MethodMetaData methodMetaData = (MethodMetaData)it2.next();
                if (methodMetaData.getReturnType() == null || methodMetaData.getName().equals("<init>")) {
                    continue;
                }
                methodIndex++;
                transformer.createProxyMethod(
                        cg, cpg, factory,
View Full Code Here

            }

            // build and sort the method lookup list
            final List methodLookupList = new ArrayList();
            for (int i = 0; i < methods.length; i++) {
                MethodMetaData methodMetaData = BcelMetaDataMaker.createMethodMetaData(methods[i]);
                if (methodFilter(definition, classMetaData, methodMetaData, methods[i])) {
                    continue;
                }
                methodLookupList.add(methods[i]);
            }

            Collections.sort(methodLookupList, BCELMethodComparator.getInstance());

            final Map methodSequences = new HashMap();
            final List proxyMethods = new ArrayList();
            boolean isClassAdvised = false;
            for (int i = 0; i < methods.length; i++) {
                MethodMetaData methodMetaData = BcelMetaDataMaker.createMethodMetaData(methods[i]);
                // filter the methods
                if (methodFilter(definition, classMetaData, methodMetaData, methods[i]) ||
                        methods[i].isStatic()) {
                    continue;
                }
View Full Code Here

                    catch (ClassNotFoundException e) {
                        throw new WrappedRuntimeException(e);
                    }

                    // create the method meta-data
                    MethodMetaData calleeSideMethodMetaData = BcelMetaDataMaker.createMethodMetaData(
                            invokeInstruction, cpg
                    );

                    // is this a caller side method pointcut?
                    if (m_definition.isPickedOutByCallPointcut(calleeSideClassMetaData, calleeSideMethodMetaData)) {
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.metadata.MethodMetaData$NullMethodMetaData

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.