use of org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData in project wildfly by wildfly.
the class WSRefDDProcessor method processWSFeatures.
private static void processWSFeatures(final DeploymentUnit unit, final Set<ResourceInjectionTargetMetaData> injectionTargets, final UnifiedServiceRefMetaData serviceRefUMDM) throws DeploymentUnitProcessingException {
if (injectionTargets == null || injectionTargets.size() == 0)
return;
if (injectionTargets.size() > 1) {
// TODO: We should validate all the injection targets whether they're compatible.
// This means all the injection targets must be assignable or equivalent.
// If there are @Addressing, @RespectBinding or @MTOM annotations present on injection targets,
// these annotations must be equivalent for all the injection targets.
}
final Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
final DeploymentReflectionIndex deploymentReflectionIndex = unit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
final ResourceInjectionTargetMetaData injectionTarget = injectionTargets.iterator().next();
final String injectionTargetClassName = injectionTarget.getInjectionTargetClass();
final String injectionTargetName = injectionTarget.getInjectionTargetName();
final AccessibleObject fieldOrMethod = getInjectionTarget(injectionTargetClassName, injectionTargetName, module.getClassLoader(), deploymentReflectionIndex);
processAnnotatedElement(fieldOrMethod, serviceRefUMDM);
}
use of org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData in project wildfly by wildfly.
the class AbstractDeploymentDescriptorBindingsProcessor method processInjectionTargets.
/**
* Processes the injection targets of a resource binding
*
*
* @param injectionSource The injection source for the injection target
* @param classLoader The module class loader
* @param deploymentReflectionIndex The deployment reflection index
* @param entry The resource with injection targets
* @param classType The expected type of the injection point, may be null if this is to be inferred from the injection target
* @return The actual class type of the injection point
* @throws DeploymentUnitProcessingException
* If the injection points could not be resolved
*/
protected Class<?> processInjectionTargets(final ResourceInjectionTarget resourceInjectionTarget, InjectionSource injectionSource, ClassLoader classLoader, DeploymentReflectionIndex deploymentReflectionIndex, ResourceInjectionMetaData entry, Class<?> classType) throws DeploymentUnitProcessingException {
if (entry.getInjectionTargets() != null) {
for (ResourceInjectionTargetMetaData injectionTarget : entry.getInjectionTargets()) {
final String injectionTargetClassName = injectionTarget.getInjectionTargetClass();
final String injectionTargetName = injectionTarget.getInjectionTargetName();
final AccessibleObject fieldOrMethod = getInjectionTarget(injectionTargetClassName, injectionTargetName, classLoader, deploymentReflectionIndex);
final Class<?> injectionTargetType = fieldOrMethod instanceof Field ? ((Field) fieldOrMethod).getType() : ((Method) fieldOrMethod).getParameterTypes()[0];
final String memberName = fieldOrMethod instanceof Field ? ((Field) fieldOrMethod).getName() : ((Method) fieldOrMethod).getName();
if (classType != null) {
if (!injectionTargetType.isAssignableFrom(classType)) {
boolean ok = false;
if (classType.isPrimitive()) {
if (BOXED_TYPES.get(classType).equals(injectionTargetType)) {
ok = true;
}
} else if (injectionTargetType.isPrimitive()) {
if (BOXED_TYPES.get(injectionTargetType).equals(classType)) {
ok = true;
}
}
if (!ok) {
throw EeLogger.ROOT_LOGGER.invalidInjectionTarget(injectionTarget.getInjectionTargetName(), injectionTarget.getInjectionTargetClass(), classType);
}
classType = injectionTargetType;
}
} else {
classType = injectionTargetType;
}
final InjectionTarget injectionTargetDescription = fieldOrMethod instanceof Field ? new FieldInjectionTarget(injectionTargetClassName, memberName, classType.getName()) : new MethodInjectionTarget(injectionTargetClassName, memberName, classType.getName());
final ResourceInjectionConfiguration injectionConfiguration = new ResourceInjectionConfiguration(injectionTargetDescription, injectionSource);
resourceInjectionTarget.addResourceInjection(injectionConfiguration);
}
}
return classType;
}
Aggregations