use of javax.resource.spi.Connector in project Payara by payara.
the class ConnectorValidator method accept.
public void accept(ConnectorDescriptor descriptor) {
// make sure that the ActivationSpec class implement ActivationSpec interface.
validateActivationSpec(descriptor);
// validate & process annotations if a valid connector annotation is not already processed
if (!descriptor.getValidConnectorAnnotationProcessed()) {
Set<AnnotationInfo> annotations = descriptor.getConnectorAnnotations();
String raClass = descriptor.getResourceAdapterClass();
if (annotations.size() == 0) {
return;
}
// only one annotation is present
if (annotations.size() == 1) {
Iterator<AnnotationInfo> it = annotations.iterator();
AnnotationInfo annotationInfo = it.next();
Class claz = (Class) annotationInfo.getAnnotatedElement();
Connector connector = (Connector) annotationInfo.getAnnotation();
ConnectorAnnotationHandler.processDescriptor(claz, connector, descriptor);
Collection<AnnotationInfo> configProperties = descriptor.getConfigPropertyAnnotations(claz.getName());
if (configProperties != null) {
for (AnnotationInfo ai : configProperties) {
ConfigPropertyHandler handler = new ConfigPropertyHandler();
try {
handler.processAnnotation(ai);
} catch (AnnotationProcessorException e) {
RuntimeException re = new RuntimeException("Unable to process ConfigProperty " + "annotation in class [" + claz.getName() + "] : " + e.getMessage());
re.initCause(e);
throw re;
}
}
}
} else {
// are present, ignore them.
if (raClass == null || raClass.equals("")) {
// all the cases below are unacceptable, fail deployment
if (annotations.size() > 1) {
throw new RuntimeException("cannot determine appropriate @Connector annotation as multiple " + "annotations are present");
}
}
}
}
// check whether outbound is defined, if so, atleast one connection-definition must be present
if (descriptor.getOutBoundDefined()) {
Set connectionDefinitions = descriptor.getOutboundResourceAdapter().getConnectionDefs();
if (connectionDefinitions.size() == 0) {
throw new RuntimeException("Invalid connector descriptor for RAR [ " + descriptor.getName() + " ], when " + "outbound-resource-adapter is specified," + "atleast one connection-definition must be specified either via annotation or via descriptor");
}
}
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, descriptor.toString());
}
processConfigProperties(descriptor);
// processed all annotations, clear from book-keeping
descriptor.getConnectorAnnotations().clear();
descriptor.getAllConfigPropertyAnnotations().clear();
descriptor.getConfigPropertyProcessedClasses().clear();
}
use of javax.resource.spi.Connector in project Payara by payara.
the class ConnectorAnnotationHandler method processAnnotation.
public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
Connector connector = (Connector) element.getAnnotation();
List<Class<? extends Annotation>> list = new ArrayList<Class<? extends Annotation>>();
list.add(getAnnotationType());
if (aeHandler instanceof RarBundleContext) {
RarBundleContext rarContext = (RarBundleContext) aeHandler;
ConnectorDescriptor desc = rarContext.getDescriptor();
Class annotatedClass = (Class) element.getAnnotatedElement();
if (desc.getResourceAdapterClass().equals("")) {
desc.addConnectorAnnotation(element);
return getSuccessfulProcessedResult(list);
} else if (!isResourceAdapterClass(annotatedClass)) {
desc.addConnectorAnnotation(element);
return getSuccessfulProcessedResult(list);
} else if (!desc.getResourceAdapterClass().equals(annotatedClass.getName())) {
desc.addConnectorAnnotation(element);
return getSuccessfulProcessedResult(list);
} else {
processDescriptor(annotatedClass, connector, desc);
desc.setValidConnectorAnnotationProcessed(true);
}
} else {
String logMessage = "Not a rar bundle context";
return getFailureResult(element, logMessage, true);
}
return getSuccessfulProcessedResult(list);
}
Aggregations