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);
}
}
}
}
}
Aggregations