public boolean processResource(AnnotatedApp annotatedApp,
Resource annotation,
Class cls,
Method method,
Field field) throws DeploymentException {
String resourceName = getResourceName(annotation, method, field);
String resourceType = getResourceType(annotation, method, field);
if (resourceType.equals("javax.ejb.SessionContext")) return true;
if (resourceType.equals("javax.ejb.MessageDrivenContext")) return true;
if (resourceType.equals("javax.ejb.EntityContext")) return true;
if (resourceType.equals("javax.ejb.TimerService")) return true;
//If it already exists in xml as a message-destination-ref or resource-env-ref, we are done.
MessageDestinationRefType[] messageDestinationRefs = annotatedApp.getMessageDestinationRefArray();
for (MessageDestinationRefType messageDestinationRef : messageDestinationRefs) {
if (messageDestinationRef.getMessageDestinationRefName().getStringValue().trim().equals(resourceName)) {
if (method != null || field != null) {
InjectionTargetType[] targets = messageDestinationRef.getInjectionTargetArray();
if (!hasTarget(method, field, targets)) {
configureInjectionTarget(messageDestinationRef.addNewInjectionTarget(), method, field);
}
}
return true;
}
}
ResourceEnvRefType[] ResourceEnvRefs = annotatedApp.getResourceEnvRefArray();
for (ResourceEnvRefType resourceEnvRefType : ResourceEnvRefs) {
if (resourceEnvRefType.getResourceEnvRefName().getStringValue().trim().equals(resourceName)) {
if (method != null || field != null) {
InjectionTargetType[] targets = resourceEnvRefType.getInjectionTargetArray();
if (!hasTarget(method, field, targets)) {
configureInjectionTarget(resourceEnvRefType.addNewInjectionTarget(), method, field);
}
}
return true;
}
}
//if it maps to a message-destination in the geronimo plan, it's a message-destination.
GerMessageDestinationType gerMessageDestinationType = null;
if (messageDestinations != null) {
gerMessageDestinationType = getMessageDestination(resourceName, messageDestinations);
}
if (gerMessageDestinationType != null) {
addMethodDestinationRef(annotatedApp, resourceName, resourceType, method, field, annotation);
return true;
} else {
//if it maps to a resource-env-ref in the geronimo plan, it's a resource-ref
GerResourceEnvRefType resourceEnvRefType = null;
if (refMap != null) {
resourceEnvRefType = refMap.get(resourceName);
}
if (resourceEnvRefType != null || resourceType.equals("javax.transaction.UserTransaction")) {
//mapped resource-env-ref
addResourceEnvRef(annotatedApp, resourceName, resourceType, method, field, annotation);
return true;
} else {
if (earContext != null) {
// look for an JCAAdminObject gbean with the right name
AbstractNameQuery containerId = buildAbstractNameQuery(null, null, resourceName,
NameFactory.JCA_ADMIN_OBJECT, NameFactory.RESOURCE_ADAPTER_MODULE);
try {
earContext.findGBean(containerId);
} catch (GBeanNotFoundException e) {
// not identifiable as an admin object ref
return false;
}
} else {
if (!("javax.jms.Queue".equals(resourceType) || "javax.jms.Topic".equals(resourceType)
|| "javax.jms.Destination".equals(resourceType))) {
// not identifiable as an admin object ref
return false;
}
}
addResourceEnvRef(annotatedApp, resourceName, resourceType, method, field, annotation);
return true;
}
}
}
|