final String connectorName = EJB3RemoteResourceDefinition.CONNECTOR_REF.resolveModelAttribute(context, model).asString();
final String threadPoolName = EJB3RemoteResourceDefinition.THREAD_POOL_NAME.resolveModelAttribute(context, model).asString();
final ServiceName remotingServerServiceName = RemotingServices.serverServiceName(connectorName);
final List<ServiceController<?>> services = new ArrayList<ServiceController<?>>();
final ServiceTarget serviceTarget = context.getServiceTarget();
// Install the client-mapping service for the remoting connector
final EJBRemotingConnectorClientMappingsEntryProviderService clientMappingEntryProviderService = new EJBRemotingConnectorClientMappingsEntryProviderService(remotingServerServiceName);
final ServiceBuilder clientMappingEntryProviderServiceBuilder = serviceTarget.addService(EJBRemotingConnectorClientMappingsEntryProviderService.SERVICE_NAME, clientMappingEntryProviderService)
.addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, clientMappingEntryProviderService.getServerEnvironmentInjector())
.addDependency(remotingServerServiceName);
if (verificationHandler != null) {
clientMappingEntryProviderServiceBuilder.addListener(verificationHandler);
}
final ServiceController clientMappingEntryProviderServiceController = clientMappingEntryProviderServiceBuilder.install();
// add it to the services to be returned
services.add(clientMappingEntryProviderServiceController);
final OptionMap channelCreationOptions = this.getChannelCreationOptions(context);
// Install the EJB remoting connector service which will listen for client connections on the remoting channel
// TODO: Externalize (expose via management API if needed) the version and the marshalling strategy
final EJBRemoteConnectorService ejbRemoteConnectorService = new EJBRemoteConnectorService((byte) 0x01, new String[]{"river"}, remotingServerServiceName, channelCreationOptions);
final ServiceBuilder<EJBRemoteConnectorService> ejbRemoteConnectorServiceBuilder = serviceTarget.addService(EJBRemoteConnectorService.SERVICE_NAME, ejbRemoteConnectorService);
// add dependency on the Remoting subsystem endpoint
ejbRemoteConnectorServiceBuilder.addDependency(RemotingServices.SUBSYSTEM_ENDPOINT, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector());
// add dependency on the remoting server (which allows remoting connector to connect to it)
ejbRemoteConnectorServiceBuilder.addDependency(remotingServerServiceName);
// add rest of the dependencies