// create the client configuration from the metadata
final EJBClientConfiguration ejbClientConfiguration = this.createClientConfiguration(phaseContext.getServiceRegistry(), module.getClassLoader(), ejbClientDescriptorMetaData);
// create the service
final DescriptorBasedEJBClientContextService service = new DescriptorBasedEJBClientContextService(ejbClientConfiguration, module.getClassLoader());
// add the service
final ServiceBuilder serviceBuilder = serviceTarget.addService(ejbClientContextServiceName, service);
// add the remoting connection reference dependencies
for (final EJBClientDescriptorMetaData.RemotingReceiverConfiguration remotingReceiverConfiguration : ejbClientDescriptorMetaData.getRemotingReceiverConfigurations()) {
final String connectionRef = remotingReceiverConfiguration.getOutboundConnectionRef();
final ServiceName connectionDependencyService = AbstractOutboundConnectionService.OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionRef);
service.addRemotingConnectionDependency(serviceBuilder, connectionDependencyService);
// setup the channel creation options for each outbound connection reference
final Properties channelCreationProps = remotingReceiverConfiguration.getChannelCreationOptions();
final OptionMap channelCreationOpts;
if (channelCreationProps == null) {
channelCreationOpts = OptionMap.EMPTY;
} else {
// we don't use the deployment CL here since the XNIO project isn't necessarily added as a dep on the deployment's
// module CL
channelCreationOpts = this.getOptionMapFromProperties(channelCreationProps, this.getClass().getClassLoader());
}
logger.debug("Channel creation options for connection " + connectionRef + " are " + channelCreationOpts);
service.setChannelCreationOptions(connectionRef, channelCreationOpts);
// setup connection timeout for each outbound connection ref
service.setConnectionCreationTimeout(connectionRef, remotingReceiverConfiguration.getConnectionTimeout());
}
// if the local receiver is enabled for this context, then add a dependency on the appropriate LocalEjbReceiver
// service
if (!ejbClientDescriptorMetaData.isLocalReceiverExcluded()) {
final Boolean passByValue = ejbClientDescriptorMetaData.isLocalReceiverPassByValue();
if (passByValue != null) {
final ServiceName localEjbReceiverServiceName = passByValue == true ? LocalEjbReceiver.BY_VALUE_SERVICE_NAME : LocalEjbReceiver.BY_REFERENCE_SERVICE_NAME;
serviceBuilder.addDependency(localEjbReceiverServiceName, LocalEjbReceiver.class, service.getLocalEjbReceiverInjector());
} else {
// setup a dependency on the default local ejb receiver service configured at the subsystem level
serviceBuilder.addDependency(LocalEjbReceiver.DEFAULT_LOCAL_EJB_RECEIVER_SERVICE_NAME, LocalEjbReceiver.class, service.getLocalEjbReceiverInjector());
}
}
serviceBuilder.addDependency(TCCLEJBClientContextSelectorService.TCCL_BASED_EJB_CLIENT_CONTEXT_SELECTOR_SERVICE_NAME);
// install the service
serviceBuilder.install();
logger.debug("Deployment unit " + deploymentUnit + " will use " + ejbClientContextServiceName + " as the EJB client context service");
// attach the service name of this EJB client context to the deployment unit
phaseContext.addDeploymentDependency(ejbClientContextServiceName, EjbDeploymentAttachmentKeys.EJB_CLIENT_CONTEXT);
}