if (destinationMetaData == null) {
log.warn("Destination metadata couldn't be found, most likely something is wrong");
}
MessageProcessorGroup service;
DeploymentUnit unit = phaseContext.getDeploymentUnit();
ServiceName baseServiceName = MessagingServices.messageProcessor( unit, metaData.getName() );
log.debugf("Installing a message processor for destination '%s'", metaData.getDestinationName());
if (destinationMetaData != null && destinationMetaData.isRemote()) {
log.debug("Destination is located on a remote host");
service = new RemoteMessageProcessorGroup( phaseContext.getServiceRegistry(), baseServiceName, metaData.getDestinationName(), destinationMetaData.getRemoteHost(), destinationMetaData.getUsername(), destinationMetaData.getPassword() );
} else {
service = new MessageProcessorGroup( phaseContext.getServiceRegistry(), baseServiceName, metaData.getDestinationName() );
}
service.setConcurrency( metaData.getConcurrency() );
service.setDurable( metaData.isDurable() );
service.setClientID( metaData.getClientID() );
service.setMessageSelector( metaData.getMessageSelector() );
service.setName( metaData.getName() );
service.setXAEnabled( metaData.isXAEnabled() );
service.setSynchronous( metaData.isSynchronous() );
service.setStoppedAfterDeploy( metaData.isStopped() );
ServiceBuilder<BaseMessageProcessorGroup> builder = phaseContext.getServiceTarget().addService( baseServiceName, service )
.addDependency( MessagingServices.messageProcessorComponentResolver( unit, metaData.getName() ), ComponentResolver.class, service.getComponentResolverInjector() )
.addDependency( CoreServices.runtimePoolName( unit, "messaging" ), RubyRuntimePool.class, service.getRuntimePoolInjector() );
if (destinationMetaData == null || !destinationMetaData.isRemote()) {
builder
.addDependency( getConnectionFactoryServiceName(), ManagedReferenceFactory.class, service.getConnectionFactoryInjector() )
.addDependency( getDestinationServiceName( metaData.getDestinationName() ), ManagedReferenceFactory.class, service.getDestinationInjector() );
}
if (metaData.isSingleton()) {
builder.addDependency( HASingleton.serviceName( unit, "global" ) );
builder.setInitialMode( Mode.PASSIVE );