Examples of JClassInterceptor


Examples of org.ow2.util.ee.metadata.ejbjar.impl.JClassInterceptor

            // Bean managed or container managed ?
            if (beanTxManaged.equals(BEAN)) {
                // BMT
                if (bean.isStateful()) {
                    interceptors.add(new JClassInterceptor(BMT_STATEFUL_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                } else if (bean.isStateless()) {
                    interceptors.add(new JClassInterceptor(BMT_STATELESS_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                } else {
                    interceptors.add(new JClassInterceptor(BMT_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                }
            } else {
                // CMT
                TransactionAttributeType methodTx = method.getTransactionAttributeType();

                // Set method tx attribute to the class tx attribute if none was
                // set.
                if (methodTx == null) {
                    if (!method.isInherited()) {
                        methodTx = beanTxType;
                    } else {
                        // inherited method, take value of the original class
                        methodTx = method.getOriginalClassMetadata().getTransactionAttributeType();
                    }
                }

                // Apply MDB interceptors and performs checks for authorized modes
                if (bean.isMdb()) {
                    switch (methodTx) {
                    case REQUIRED:
                    case NOT_SUPPORTED:
                        break;
                    case MANDATORY:
                    case NEVER:
                    case REQUIRES_NEW:
                    case SUPPORTS:
                    default:
                        logger.error("For MDB, the TX attribute '" + methodTx
                                + "' is not a valid attribute (only Required or Not supported is available). "
                                + "The error is on the method '" + method.getMethodName() + "' of class '"
                                + method.getClassMetadata().getClassName() + "' for the bean '"
                                + method.getClassMetadata().getLinkedBean() + "'. Sets to the default REQUIRED mode.");
                        methodTx = TransactionAttributeType.REQUIRED;
                        break;
                    }

                    if (TransactionAttributeType.NOT_SUPPORTED == methodTx) {
                        interceptors.add(new JClassInterceptor(CMT_NOT_SUPPORTED_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                    } else if (TransactionAttributeType.REQUIRED == methodTx) {
                        method.setTransacted(true);
                        interceptors.add(new JClassInterceptor(MDB_CMT_REQUIRED_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                    } else {
                        // invalid case
                        throw new IllegalStateException(
                                "Shouldn't be in another mode. Expected NOT_Supported/Required and got '" + methodTx
                                        + "' for the method '" + method.getMethodName() + "' of class '"
                                        + method.getClassMetadata().getClassName() + "' for the bean '"
                                        + method.getClassMetadata().getLinkedBean() + "'. Sets to the default REQUIRED mode.");
                    }


                } else {

                switch (methodTx) {
                    case MANDATORY:
                        method.setTransacted(true);
                        interceptors.add(new JClassInterceptor(CMT_MANDATORY_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                        break;
                    case NEVER:
                        interceptors.add(new JClassInterceptor(CMT_NEVER_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                        break;
                    case NOT_SUPPORTED:
                        interceptors.add(new JClassInterceptor(CMT_NOT_SUPPORTED_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                        break;
                    case REQUIRED:
                        method.setTransacted(true);
                        interceptors.add(new JClassInterceptor(CMT_REQUIRED_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                        break;
                    case REQUIRES_NEW:
                        method.setTransacted(true);
                        interceptors.add(new JClassInterceptor(CMT_REQUIRES_NEW_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                        break;
                    case SUPPORTS:
                        method.setTransacted(true);
                        interceptors.add(new JClassInterceptor(CMT_SUPPORTS_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                        break;
                    default:
                        throw new IllegalStateException("Invalid tx attribute on method '" + method.getMethodName()
                                + "', value = '" + methodTx + "'.");
                }

                }

                // Add listener interceptor for stateul bean only if the bean implements SessionSynchronization interface
                if (addSynchro) {
                    interceptors.add(new JClassInterceptor(LISTENER_SESSION_SYNCHRO_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
                }
                // End CMT
            }

View Full Code Here

Examples of org.ow2.util.ee.metadata.ejbjar.impl.JClassInterceptor

                }
            }

            // runAs ?
            if (runAs != null) {
                interceptors.add(new JClassInterceptor(RUNAS_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
            }

            if (denyAll) {
                interceptors.add(new JClassInterceptor(DENYALL_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
            } else if (!permitAll && rolesAllowed != null) {
                // only if permitAll is not set as no interceptor is added in this case
                interceptors.add(new JClassInterceptor(ROLEBASED_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
            }
            method.setInterceptors(interceptors);
        }
    }
View Full Code Here

Examples of org.ow2.util.ee.metadata.ejbjar.impl.JClassInterceptor

        }

        // Set list of global interceptors (applied on all business methods)
        List<JClassInterceptor> easyBeansGlobalInterceptors = new ArrayList<JClassInterceptor>();
        for (String easyBeansInterceptor : easyBeansInterceptorsClasses) {
            easyBeansGlobalInterceptors.add(new JClassInterceptor(easyBeansInterceptor, EASYBEANS_INTERCEPTOR));
        }
        classAnnotationMetadata.setGlobalEasyBeansInterceptors(easyBeansGlobalInterceptors);


        // Default interceptors (only once as it is stored in the ejb metadata)
        EjbJarArchiveMetadata ejbJarDeployableMetadata = classAnnotationMetadata.getEjbJarDeployableMetadata();

        IJInterceptors defaultInterceptorsClasses = ejbJarDeployableMetadata.getDefaultInterceptorsClasses();
        Map<InterceptorType, List<? extends IJClassInterceptor>> mapDefaultInterceptors =
            ejbJarDeployableMetadata.getDefaultInterceptors();
        if (mapDefaultInterceptors == null && defaultInterceptorsClasses != null && defaultInterceptorsClasses.size() > 0) {
            Map<InterceptorType, List<? extends IJClassInterceptor>> defaultInterceptors =
                new HashMap<InterceptorType, List<? extends IJClassInterceptor>>();
            defaultInterceptors.putAll(getInterceptors(classAnnotationMetadata.getClassName(), classAnnotationMetadata,
                    defaultInterceptorsClasses.getClasses()));
            ejbJarDeployableMetadata.setDefaultInterceptors(defaultInterceptors);
        }


        // And then, set the user interceptors (found in external class)
        List<String> externalInterceptorsClasses = new ArrayList<String>();

        // Interceptors from other classes (will be analyzed after)
        // See 3.5.3 of simplified EJB 3.0 spec : multiple interceptors
        // Add interceptor classes found on super classes (if any)


        // Invert list of the inheritance on the current class
        LinkedList<EasyBeansEjbJarClassMetadata> invertedInheritanceClassesList =
            getInvertedSuperClassesMetadata(classAnnotationMetadata);
        // Add interceptors found on these classes (order is super super class
        // before super class, ie : top level first)
        for (EasyBeansEjbJarClassMetadata superMetaData : invertedInheritanceClassesList) {
            IJInterceptors classIinterceptors = superMetaData.getAnnotationInterceptors();
            if (classIinterceptors != null) {
                for (String cls : classIinterceptors.getClasses()) {
                    externalInterceptorsClasses.add(cls);
                }
            }
        }

        // Get the interceptors defined by the user on external classes
        Map<InterceptorType, List<? extends IJClassInterceptor>> externalMapClassInterceptors = new HashMap<InterceptorType, List<? extends IJClassInterceptor>>();
        externalMapClassInterceptors.putAll(getInterceptors(classAnnotationMetadata.getClassName(), classAnnotationMetadata,
                externalInterceptorsClasses));
        classAnnotationMetadata.setExternalUserInterceptors(externalMapClassInterceptors);


        // interceptor in the bean class ? (LifeCycle event interceptors are not in the bean
        // because they don't take an InvocationContext as parameter, this is the intercepted method
        List<String> internalInterceptorsClasses = new ArrayList<String>();

        if (classAnnotationMetadata.isAroundInvokeMethodMetadata()) {
            internalInterceptorsClasses.add(classAnnotationMetadata.getClassName());
        }
        // Get the interceptors defined by the user on the class
        Map<InterceptorType, List<? extends IJClassInterceptor>> internalMapClassInterceptors =
            new HashMap<InterceptorType, List<? extends IJClassInterceptor>>();
        internalMapClassInterceptors.putAll(getInterceptors(classAnnotationMetadata.getClassName(), classAnnotationMetadata,
                internalInterceptorsClasses));
        classAnnotationMetadata.setInternalUserInterceptors(internalMapClassInterceptors);

        // Now, analyze each interceptors found on methods.
        for (EasyBeansEjbJarMethodMetadata methodAnnotationMetaData
                : classAnnotationMetadata.getMethodMetadataCollection()) {

            // Set global interceptors for a given method (ie : Remove)
            Remove remove = methodAnnotationMetaData.getJRemove();
            if (remove != null) {
                List<JClassInterceptor> easyBeansMethodGlobalInterceptors = new ArrayList<JClassInterceptor>();
                String classType = null;
                // choose right interceptor class
                if (remove.retainIfException()) {
                    classType = Type.getInternalName(RemoveOnlyWithoutExceptionInterceptor.class);
                } else {
                    classType = Type.getInternalName(RemoveAlwaysInterceptor.class);
                }
                easyBeansMethodGlobalInterceptors.add(new JClassInterceptor(classType, EASYBEANS_INTERCEPTOR));

                // set list
                methodAnnotationMetaData.setGlobalEasyBeansInterceptors(easyBeansMethodGlobalInterceptors);
            }
View Full Code Here

Examples of org.ow2.util.ee.metadata.ejbjar.impl.JClassInterceptor

                for (EasyBeansEjbJarMethodMetadata method : currentMetaData.getMethodMetadataCollection()) {
                    // Don't look inherited methods.
                    if (method.isInherited()) {
                        continue;
                    }
                    JClassInterceptor jInterceptor = new JClassInterceptor(className, method.getJMethod(),
                            interceptorClassAnalyzed);

                    // If the method is overriden, take care of using the
                    // annotation of the lower class in the inheritance classes.
                    // As the method is only add once for a single interceptor
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.