Search in sources :

Example 1 with RemoveMethodMetaData

use of org.jboss.metadata.ejb.spec.RemoveMethodMetaData in project wildfly by wildfly.

the class RemoveMethodMergingProcessor method handleDeploymentDescriptor.

protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final StatefulComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
    SessionBeanMetaData beanMetaData = componentConfiguration.getDescriptorData();
    if (beanMetaData == null) {
        return;
    }
    if (beanMetaData.getRemoveMethods() == null || beanMetaData.getRemoveMethods().isEmpty()) {
        return;
    }
    final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final Set<MethodIdentifier> annotationRemoveMethods = new HashSet<MethodIdentifier>();
    for (final StatefulComponentDescription.StatefulRemoveMethod method : componentConfiguration.getRemoveMethods()) {
        annotationRemoveMethods.add(method.getMethodIdentifier());
    }
    // while the method that specifies the actual parameters override this
    for (final RemoveMethodMetaData removeMethod : beanMetaData.getRemoveMethods()) {
        if (removeMethod.getBeanMethod().getMethodParams() == null) {
            final NamedMethodMetaData methodData = removeMethod.getBeanMethod();
            final Collection<Method> methods = MethodResolutionUtils.resolveMethods(methodData, componentClass, reflectionIndex);
            for (final Method method : methods) {
                final Boolean retainIfException = removeMethod.getRetainIfException();
                final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method);
                if (retainIfException == null) {
                    // if this is null we have to allow annotation values of retainIfException to take precidence
                    if (!annotationRemoveMethods.contains(methodIdentifier)) {
                        componentConfiguration.addRemoveMethod(methodIdentifier, false);
                    }
                } else {
                    componentConfiguration.addRemoveMethod(methodIdentifier, retainIfException);
                }
            }
        }
    }
    for (final RemoveMethodMetaData removeMethod : beanMetaData.getRemoveMethods()) {
        if (removeMethod.getBeanMethod().getMethodParams() != null) {
            final NamedMethodMetaData methodData = removeMethod.getBeanMethod();
            final Collection<Method> methods = MethodResolutionUtils.resolveMethods(methodData, componentClass, reflectionIndex);
            for (final Method method : methods) {
                final Boolean retainIfException = removeMethod.getRetainIfException();
                final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method);
                if (retainIfException == null) {
                    // if this is null we have to allow annotation values of retainIfException to take precidence
                    if (!annotationRemoveMethods.contains(methodIdentifier)) {
                        componentConfiguration.addRemoveMethod(methodIdentifier, false);
                    }
                } else {
                    componentConfiguration.addRemoveMethod(methodIdentifier, retainIfException);
                }
            }
        }
    }
}
Also used : StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) SessionBeanMetaData(org.jboss.metadata.ejb.spec.SessionBeanMetaData) RemoveMethodMetaData(org.jboss.metadata.ejb.spec.RemoveMethodMetaData) NamedMethodMetaData(org.jboss.metadata.ejb.spec.NamedMethodMetaData) MethodIdentifier(org.jboss.invocation.proxy.MethodIdentifier) Method(java.lang.reflect.Method) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) HashSet(java.util.HashSet)

Aggregations

Method (java.lang.reflect.Method)1 HashSet (java.util.HashSet)1 StatefulComponentDescription (org.jboss.as.ejb3.component.stateful.StatefulComponentDescription)1 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)1 MethodIdentifier (org.jboss.invocation.proxy.MethodIdentifier)1 NamedMethodMetaData (org.jboss.metadata.ejb.spec.NamedMethodMetaData)1 RemoveMethodMetaData (org.jboss.metadata.ejb.spec.RemoveMethodMetaData)1 SessionBeanMetaData (org.jboss.metadata.ejb.spec.SessionBeanMetaData)1