Package org.ow2.easybeans.deployment.annotations.exceptions

Examples of org.ow2.easybeans.deployment.annotations.exceptions.InterceptorsValidationException


                compareMetaData = method.getOriginalClassMetadata();
            } else {
                compareMetaData = method.getClassMetadata();
            }
            if (compareMetaData.equals(wantToAddClassMetadata)) {
                throw new InterceptorsValidationException("Class " + getClassName() + " has already a " + itcType
                        + " method which is " + method.getMethodName() + ", cannot set new method "
                        + postConstructMethodMetadata.getMethodName());
            }
        }
    }
View Full Code Here


            // Check if the timeout method is valid
            if (method.isTimeout()) {

                // There is already a timer method that have been found.
                if (alreadyFoundTimerMethod != null) {
                    throw new InterceptorsValidationException(
                            "A bean cannot have more than one timer method, previous timer method is '" + alreadyFoundTimerMethod
                                    + "' while the new one is '" + method + "'.");
                }

                // flag this method as already found
                alreadyFoundTimerMethod = method;

                // Check that the signature is valid
                // void and Timer parameter
                if (!BeanClassAdapter.TIMER_JMETHOD.getDescriptor().equals(method.getJMethod().getDescriptor())) {
                    throw new InterceptorsValidationException("The timeout method '" + method
                            + "' hasn't a valid signature. The valid signature should be '"
                            + BeanClassAdapter.TIMER_JMETHOD.getDescriptor() + "'.");
                }

                // No static or final
View Full Code Here

     * @param desc the description of the access.
     * @param className the name of the class of the given method.
     */
    public static void ensureNoAccess(final int acc, final JMethod jMethod, final String desc, final String className) {
        if ((jMethod.getAccess() & acc) == acc) {
            throw new InterceptorsValidationException("The method '" + jMethod + "' of the class '" + className
                    + "' is not compliant on the method access. It shouldn't use the '" + desc + "' keyword.");
        }
    }
View Full Code Here

                    if (interfaceMetaData != null) {
                        for (EasyBeansEjbJarMethodMetadata method : interfaceMetaData
                                .getMethodMetadataCollection()) {
                            // no AroundInvoke or PostConstruct
                            if (method.isAroundInvoke()) {
                                throw new InterceptorsValidationException("The method '" + method
                                        + "' in the bean class '" + bean.getClassName()
                                        + "' cannot be an AroundInvoke as it is an interface");
                            }
                            if (method.isLifeCycleMethod()) {
                                throw new InterceptorsValidationException("The method '" + method
                                        + "' in the bean class '" + bean.getClassName()
                                        + "' cannot be a lifecycle as it is an interface");
                            }
                        }
                    }
View Full Code Here

            final EasyBeansEjbJarClassMetadata interceptorMetaData) {
        List<EasyBeansEjbJarMethodMetadata> aroundInvokeList = interceptorMetaData.getAroundInvokeMethodMetadatas();
        if (aroundInvokeList != null && aroundInvokeList.size() > 1) {
            String errMsg = "There are severals @AroundInvoke in the class '" + interceptorMetaData.getClassName()
                    + "', 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() + "'.");
        }

        for (EasyBeansEjbJarMethodMetadata method : interceptorMetaData.getMethodMetadataCollection()) {
View Full Code Here

    private static void validateJMethod(final JMethod jMethod, final String desc, final String awaitedException,
            final String className) {

        // validate signature
        if (!jMethod.getDescriptor().equals(desc)) {
            throw new InterceptorsValidationException("Method '" + jMethod + "' of the class '" + className
                    + "' is not compliant with the signature '" + desc + "'. Signature found = '"
                    + jMethod.getDescriptor() + "'.");
        }

        // validate exceptions
        String[] exceptions = jMethod.getExceptions();
        if (awaitedException == null) {
            return;
        }

        boolean found = false;

        if (exceptions != null) {
            for (String exception : exceptions) {
                if (exception.equals(awaitedException)) {
                    found = true;
                }
            }
        }
        if (!found) {
            throw new InterceptorsValidationException("Method '" + jMethod + "' of the class '" + className
                    + "' is not compliant with the signature '" + desc + "' as the required exception '"
                    + awaitedException + "' is missing.");
        }
    }
View Full Code Here

            // Get meta data of the super class
            EasyBeansEjbJarClassMetadata superClassMetadata = beanclassAnnotationMetadata.getLinkedClassMetadata(superClass);

            if (superClassMetadata == null) {
                // TODO : I18n
                throw new ResolverException("The class " + beanclassAnnotationMetadata + " extends the class " + superClass
                        + "but this class seems to be outside of the ejb-jar");
            }

            // Takes method metadata of the super class and adds them to the
            // bean class
View Full Code Here

            if (superClass.equals(JAVA_LANG_OBJECT)) {
                return;
            }

            // Get meta data of the super class
            EasyBeansEjbJarClassMetadata superClassMetadata = beanclassAnnotationMetadata.getLinkedClassMetadata(superClass);

            if (superClassMetadata == null) {
                // TODO : I18n
                throw new ResolverException("The class " + beanclassAnnotationMetadata + " extends the class " + superClass
                        + "but this class seems to be outside of the ejb-jar");
            }

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

            }
            // add as visited
            visitedInterfaces.add(itf);

            // get meta data of the interface
            EasyBeansEjbJarClassMetadata itfMetadata = visitingclassAnnotationMetadata.getLinkedClassMetadata(itf);

            if (itfMetadata == null) {
                logger.warn("No class was found for interface {0}.", itf);
                continue;
            }

            // 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);
                if (beanMethod == null) {
                    // TODO: I18n
                    throw new IllegalStateException("No method was found for method " + itfMethod + " in class "
                            + beanclassAnnotationMetadata.getClassName());
                }
                beanMethod.setBusinessMethod(true);
            }

            // loop again
            if (itfMetadata.getInterfaces() != null) {
                loop(beanclassAnnotationMetadata, itfMetadata, visitedInterfaces);
            }
        }
    }
View Full Code Here

        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:
                generatedMetadata.setPostConstruct(true);
                break;
            case PRE_DESTROY:
                generatedMetadata.setPreDestroy(true);
                break;
            case PRE_PASSIVATE:
                generatedMetadata.setPrePassivate(true);
                break;
            case POST_ACTIVATE:
                generatedMetadata.setPostActivate(true);
                break;
            default:
                    throw new RuntimeException("No generated method name found for interceptorType '" + interceptorType + "'");
        }
View Full Code Here

TOP

Related Classes of org.ow2.easybeans.deployment.annotations.exceptions.InterceptorsValidationException

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.