Properties activationProps = null;
ActivationSpecModel activationSpecModel = inboundConnectionModel.getActivationSpec();
if (activationSpecModel != null) {
activationProps = activationSpecModel.getProperties();
}
InboundInteractionModel inboundInteractionModel = jcaconfig.getInboundInteraction();
if (inboundInteractionModel == null) {
throw JCAMessages.MESSAGES.noInboundInteractionConfigured();
}
String listener = null;
ListenerModel listenerModel = inboundInteractionModel.getListener();
if (listenerModel != null) {
listener = listenerModel.getClassName();
}
Class<?> listenerType = null;
try {
listenerType = _appClassLoader.loadClass(listener != null ? listener : JCAConstants.DEFAULT_LISTENER_CLASS);
} catch (Exception e) {
throw JCAMessages.MESSAGES.noListenerClassFound(listener, e);
}
EndpointModel endpointModel = inboundInteractionModel.getEndpoint();
if (endpointModel == null) {
throw JCAMessages.MESSAGES.noEndpointConfigured();
}
String endpointClassName = endpointModel.getEndpointClassName();
Properties endpointProps = endpointModel.getProperties();
ActivationSpec activationSpec = null;
ResourceAdapter resourceAdapter = null;
MessageListener listenerContainer = null;
try {
List<MessageListener> listeners = _raRepository.getMessageListeners(raid);
for (MessageListener l : listeners) {
if (listenerType.equals(l.getType())) {
listenerContainer = l;
}
}
if (listenerContainer == null) {
throw JCAMessages.MESSAGES.listenerTypeIsNotSupportedByResourceAdapter(listenerType.getName(), raName);
}
Activation activation = listenerContainer.getActivation();
activationSpec = activation.createInstance();
if (activationProps != null && !activationProps.isEmpty()) {
PropertyEditors.mapJavaBeanProperties(activationSpec, activationProps);
}
resourceAdapter = _raRepository.getResourceAdapter(raid);
if (!raProps.isEmpty()) {
PropertyEditors.mapJavaBeanProperties(resourceAdapter, raProps);
}
} catch (Exception e) {
throw JCAMessages.MESSAGES.couldnTAcquireTheResourceAdapter(raName, e);
}
AbstractInflowEndpoint endpoint = null;
Class<?> endpointClass = null;
try {
endpointClass = (Class<?>)_appClassLoader.loadClass(endpointClassName);
endpoint = (AbstractInflowEndpoint) endpointClass.newInstance();
if (!endpointProps.isEmpty()) {
PropertyEditors.mapJavaBeanProperties(endpoint, endpointProps);
}
} catch (Exception e) {
throw JCAMessages.MESSAGES.endpointClass(endpointClassName, e);
}
boolean transacted = inboundInteractionModel.isTransacted();
endpoint.setApplicationClassLoader(_appClassLoader)
.setServiceDomain(getServiceDomain())
.setServiceQName(name)
.setDeliveryTransacted(transacted)
.setJCABindingModel(jcaconfig);
JCAInflowDeploymentMetaData inflowMetaData = new JCAInflowDeploymentMetaData()
.setActivationSpec(activationSpec)
.setApplicationClassLoader(_appClassLoader)
.setListenerInterface(listenerType)
.setMessageEndpoint(endpoint)
.setResourceAdapter(resourceAdapter)
.setTransactionManager(_transactionManager)
.setDeliveryTransacted(transacted);
BatchCommitModel batchCommit = inboundInteractionModel.getBatchCommit();
if (transacted && batchCommit != null) {
inflowMetaData.setUseBatchCommit(true);
inflowMetaData.setBatchTimeout(batchCommit.getBatchTimeout());
inflowMetaData.setBatchSize(batchCommit.getBatchSize());
}