log.info("Reading connector annotations");
if (raClass != null/*and not metadata complete */) {
javax.resource.spi.Connector ra = raClass.getAnnotation(javax.resource.spi.Connector.class);
if (ra != null) {
OutboundResourceAdapter outboundResourceAdapter = resourceAdapter.getOutboundResourceAdapter();
if (outboundResourceAdapter == null) {
outboundResourceAdapter = new OutboundResourceAdapter();
resourceAdapter.setOutboundResourceAdapter(outboundResourceAdapter);
}
if (outboundResourceAdapter.isReauthenticationSupport() == null) {
outboundResourceAdapter.setReauthenticationSupport(ra.reauthenticationSupport());
}
if (outboundResourceAdapter.getTransactionSupport() == null) {
outboundResourceAdapter.setTransactionSupport(TransactionSupportType.fromValue(ra.transactionSupport().toString()));
}
connector.getRequiredWorkContext().addAll(toString(ra.requiredWorkContexts()));
setConfigProperties(resourceAdapter.getConfigProperty(), raClass);
}
}
//inbound
log.info("connector of type: " + connector);
InboundResourceadapter inboundResource = resourceAdapter.getInboundResourceAdapter();
if (inboundResource == null) {
inboundResource = new InboundResourceadapter();
inboundResource.setMessageAdapter(new MessageAdapter());
}
MessageAdapter messageAdapter = inboundResource.getMessageAdapter();
List<Class<?>> activationSpecClasses = classFinder.findAnnotatedClasses(Activation.class);
for (Class<?> asClass : activationSpecClasses) {
Activation activation = asClass.getAnnotation(Activation.class);
for (Class messageListenerClass : activation.messageListeners()) {
ActivationSpec activationSpec = getActivationSpec(messageAdapter, messageListenerClass);
if (activationSpec.getActivationSpecClass() == null) {
activationSpec.setActivationSpecClass(asClass.getName());
}
if (asClass.getName().equals(activationSpec.getActivationSpecClass())) {
setConfigProperties(activationSpec.getConfigProperty(), asClass);
}
//TODO set required config properties from @NotNull annotations
}
}
if (resourceAdapter.getInboundResourceAdapter() == null && inboundResource.getMessageAdapter().getMessageListener().size() > 0) {
resourceAdapter.setInboundResourceAdapter(inboundResource);
}
//admin objects
for (Class adminObjectClass : classFinder.findAnnotatedClasses(AdministeredObject.class)) {
AdministeredObject administeredObject = (AdministeredObject) adminObjectClass.getAnnotation(AdministeredObject.class);
Class[] interfaces = administeredObject.adminObjectInterfaces();
if (interfaces == null || interfaces.length == 0) {
List<Class> allInterfaces = new ArrayList<Class>(Arrays.asList(adminObjectClass.getInterfaces()));
allInterfaces.remove(Serializable.class);
allInterfaces.remove(Externalizable.class);
//TODO check if specified in ra.xml
if (allInterfaces.size() != 1) {
throw new DeploymentException("Interface for admin object not specified properly: " + allInterfaces);
}
interfaces = allInterfaces.toArray(new Class[1]);
}
for (Class aoInterface : interfaces) {
AdminObject adminObject = getAdminObject(resourceAdapter, aoInterface);
if (adminObject.getAdminObjectClass() == null) {
adminObject.setAdminObjectClass(adminObjectClass.getName());
}
if (adminObjectClass.getName().equals(adminObject.getAdminObjectClass())) {
setConfigProperties(adminObject.getConfigProperty(), adminObjectClass);
}
}
}
OutboundResourceAdapter outboundResourceAdapter = resourceAdapter.getOutboundResourceAdapter();
if (outboundResourceAdapter == null) {
outboundResourceAdapter = new OutboundResourceAdapter();
}
//outbound
for (Class<?> mcfClass : classFinder.findAnnotatedClasses(javax.resource.spi.ConnectionDefinition.class)) {
javax.resource.spi.ConnectionDefinition connectionDefinitionAnnotation = mcfClass.getAnnotation(javax.resource.spi.ConnectionDefinition.class);
buildConnectionDefinition(mcfClass.asSubclass(ManagedConnectionFactory.class), connectionDefinitionAnnotation, outboundResourceAdapter);
}
for (Class<?> mcfClass : classFinder.findAnnotatedClasses(ConnectionDefinitions.class)) {
ConnectionDefinitions connectionDefinitionAnnotations = mcfClass.getAnnotation(ConnectionDefinitions.class);
for (javax.resource.spi.ConnectionDefinition connectionDefinitionAnnotation : connectionDefinitionAnnotations.value()) {
buildConnectionDefinition(mcfClass.asSubclass(ManagedConnectionFactory.class), connectionDefinitionAnnotation, outboundResourceAdapter);
}
}
if (outboundResourceAdapter.getConnectionDefinition().size() > 0) {
resourceAdapter.setOutboundResourceAdapter(outboundResourceAdapter);
}
}
return connector;
}