Examples of JMethod


Examples of org.ow2.util.scan.api.metadata.structures.JMethod

     * @param method the annotation metadata of the method
     */
    private void generateCallSuperEncodedMethod(final EasyBeansEjbJarMethodMetadata method) {

        String generatedMethodName = MethodRenamer.encode(method.getMethodName());
        JMethod jMethod = method.getJMethod();
        MethodVisitor mv = this.cv.visitMethod(jMethod.getAccess(), generatedMethodName,
                jMethod.getDescriptor(), jMethod.getSignature(), jMethod.getExceptions());

        // Add some flags on the generated method
        CommonClassGenerator.addAnnotationsOnGeneratedMethod(mv);

        mv.visitCode();

        // Add bean (as first argument)
        mv.visitVarInsn(ALOAD, 0);

        // for each argument
        Type[] args = Type.getArgumentTypes(jMethod.getDescriptor());
        int methodArg = 1;
        for (Type type : args) {
            int opCode = CommonClassGenerator.putFieldLoadOpCode(type.getSort());
            mv.visitVarInsn(opCode, methodArg);
            // Double and Long are special parameters
            if (opCode == LLOAD || opCode == DLOAD) {
                methodArg++;
            }
            methodArg++;
        }

        // call super class method()
        mv.visitMethodInsn(INVOKESPECIAL, method.getClassMetadata().getSuperName(),
                jMethod.getName(), jMethod.getDescriptor());

        Type returnType = Type.getReturnType(jMethod.getDescriptor());
        CommonClassGenerator.addReturnType(returnType, mv);


        mv.visitMaxs(0, 0);
        mv.visitEnd();
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

            // Takes method metadata of the super class and adds them to the
            // bean class
            // Note : the flag inherited is set to true
            for (EasyBeansEjbJarMethodMetadata methodAnnotationMetadata : superClassMetadata.getMethodMetadataCollection()) {
                // check that the method has not be redefined
                JMethod method = methodAnnotationMetadata.getJMethod();

                EasyBeansEjbJarMethodMetadata beanMethod = beanclassAnnotationMetadata.getMethodMetadata(method);

                // overriding ?
                boolean overrided = true;
                overrided = !((method.getAccess() & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE);

                // Add only if it is not present or if current method is not
                // overriding super method (it means super method is private)
                if (beanMethod == null || (!overrided && beanMethod != null && !beanMethod.isInherited())) {

                    // Add a clone of the method to bean class
                    EasyBeansEjbJarMethodMetadata clonedMethodAnnotationMetadata =
                        (EasyBeansEjbJarMethodMetadata) methodAnnotationMetadata.clone();
                    // set new class linked to this method metadata
                    clonedMethodAnnotationMetadata
                            .setClassMetadata(beanclassAnnotationMetadata);

                    // method is inherited
                    clonedMethodAnnotationMetadata.setInherited(true, superClassMetadata);

                    // Final method ? ignore it
                    if ((method.getAccess() & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL) {
                        logger.warn("Ignoring final method ''{0}'' from the class ''{1}''", method.getName(),
                                beanclassAnnotationMetadata.getClassName());
                        clonedMethodAnnotationMetadata.setIgnored(true);
                    }

                    beanclassAnnotationMetadata
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();

        // add method in the class metadata
        JMethod method = new JMethod(ACC_PUBLIC, generatedMethodName, "()V", null, null);
        EasyBeansEjbJarMethodMetadata generatedMetadata = new EasyBeansEjbJarMethodMetadata(method, classMetaData);

        // Set value
        switch (interceptorType) {
            case POST_CONSTRUCT:
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

            }

            // for each method of the interface, set the business method to true
            // in bean
            for (EasyBeansEjbJarMethodMetadata methodData : itfMetadata.getMethodMetadataCollection()) {
                JMethod itfMethod = methodData.getJMethod();

                // Ignore class init method
                if (itfMethod.getName().equals(CLASS_INIT) || itfMethod.getName().equals(CONST_INIT)) {
                    continue;
                }

                // take the method from the bean class
                EasyBeansEjbJarMethodMetadata beanMethod = beanclassAnnotationMetadata.getMethodMetadata(itfMethod);
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

    protected void setMethodValue(final ICommonMethodMetadata<?, ?, ?> methodMetadata, final Class<?> clazz,
            final Object instance, final Object value) throws ArchiveInjectionException {

        // Value is obtained, set it
        // Get Method from the class
        JMethod jMethod = methodMetadata.getJMethod();
        Method method = MethodHelper.getMethod(jMethod, clazz);

        boolean accessible = method.isAccessible();
        try {
            // needs to be allowed to change value of the method
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

     * @param methodMetaData the metadata to check
     * @return ASM type of the first arg of the method.
     */
    protected Type validateSetterMethod(final ICommonMethodMetadata<?, ?, ?> methodMetaData) {

            JMethod jMethod = methodMetaData.getJMethod();
            // Should be a setter
            if (!jMethod.getName().startsWith("set") || jMethod.getName().equalsIgnoreCase("set")) {
                throw new IllegalStateException("Method '" + jMethod
                        + "' is invalid. Should be in the setter form setXXX().");
            }

            // Get type of interface
            // Get arguments of the method.
            Type[] args = Type.getArgumentTypes(jMethod.getDescriptor());
            if (args.length != 1) {
                throw new IllegalStateException("Method args '" + Arrays.asList(args) + "' for method '" + jMethod
                        + "' are invalid. Length should be of 1.");
            }
            return args[0];
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

     * Ensure that this method is a valid setter method and return ASM type of the first arg of the method.
     * @param methodMetaData the metadata to check
     * @return ASM type of the first arg of the method.
     */
    public static Type getSetterMethodType(final IEjbJarMethodMetadata methodMetaData) {
        JMethod jMethod = methodMetaData.getJMethod();
        // Should be a setter
        if (!jMethod.getName().startsWith("set") || jMethod.getName().equalsIgnoreCase("set")) {
            throw new IllegalStateException("Method '" + jMethod
                    + "' is invalid. Should be in the setter form setXXX().");
        }

        // Get type of interface
        // Get arguments of the method.
        Type[] args = Type.getArgumentTypes(jMethod.getDescriptor());
        if (args.length != 1) {
            throw new IllegalStateException("Method args '" + Arrays.asList(args) + "' for method '" + jMethod
                    + "' are invalid. Length should be of 1.");
        }
        return args[0];
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

     */
    private Type validateSetterMethod(final EasyBeansEjbJarMethodMetadata methodMetaData) {
        // validate access
        validateAccessMethodAnnotation(methodMetaData);

        JMethod jMethod = methodMetaData.getJMethod();
        // Should be a setter
        if (!jMethod.getName().startsWith("set") || jMethod.getName().equalsIgnoreCase("set")) {
            throw new IllegalStateException("Method '" + jMethod
                    + "' is invalid. Should be in the setter form setXXX().");
        }

        // Get type of interface
        // Get arguments of the method.
        Type[] args = Type.getArgumentTypes(jMethod.getDescriptor());
        if (args.length != 1) {
            throw new IllegalStateException("Method args '" + Arrays.asList(args) + "' for method '" + jMethod
                    + "' are invalid. Length should be of 1.");
        }
        return args[0];
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

                    + "', while only one is allowed. List of Methods : '" + aroundInvokeList + "'.";
            throw new InterceptorsValidationException(errMsg);
        }

        // Ensure that interceptor has a default constructor.
        JMethod defaultConstructor = new JMethod(0, CONSTRUCTOR_METHOD, DEFAULT_CONSTRUCTOR_DESCRIPTOR, null, null);
        if (interceptorMetaData.getMethodMetadata(defaultConstructor) == null) {
            throw new InterceptorsValidationException("No default constructor in the interceptor class '"
                    + interceptorMetaData.getClassName() + "'.");
        }
View Full Code Here

Examples of org.ow2.util.scan.api.metadata.structures.JMethod

                    // Store the invoker
                    interceptorTypeInvokers.put(interceptorType.toString(), invokers);

                    for (IJClassInterceptor interceptor : allInterceptors) {
                        String classname = interceptor.getClassName();
                        JMethod jMethod = interceptor.getJMethod();

                        // interceptor on the bean or outside ?
                        if (classMetadata.getClassName().equals(classname)) {
                            // interceptor is in the bean
                            // Add the invoker
                            invokers.add(new BeanInterceptorInvokerImpl(classname, jMethod, classLoader));
                        } else {
                            // outside of the bean
                            // Add the invoker
                            invokers.add(new StandaloneInterceptorInvokerImpl(classname, jMethod, classLoader));

                            // An interceptor instance will be required for this
                            // interceptor class
                            addInterceptorClass(classname);
                        }
                    }

                    // Add the method invocation call
                    JMethod interceptedMethod = methodMetadata.getJMethod();

                    String methodName = interceptedMethod.getName();
                    if (!methodMetadata.isLifeCycleMethod() && !methodName.contains("$generated")) {
                        methodName = MethodRenamer.encode(interceptedMethod.getName());
                    }

                    JMethod originalMethod = new JMethod(interceptedMethod.getAccess(), methodName, interceptedMethod.getDescriptor(), interceptedMethod.getSignature(), interceptedMethod
                            .getExceptions());
                    invokers.add(new BeanBusinessMethodInvokerImpl(classMetadata.getClassName(), originalMethod, classLoader));

                    // Put in cache the business methods of the bean
                    this.methods.put(methodSignature, MethodHelper.getMethod(classMetadata.getClassName(), methodMetadata
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.