final ModuleIdentifier module = ModelNodes.asModuleIdentifier(CacheContainerResourceDefinition.MODULE.resolveModelAttribute(context, model));
Transport transportConfig = null;
String transportExecutor = null;
InjectedValueServiceBuilder builder = new InjectedValueServiceBuilder(target);
if (model.hasDefined(TransportResourceDefinition.PATH.getKey())) {
ModelNode transport = model.get(TransportResourceDefinition.PATH.getKeyValuePair());
if (transport.isDefined()) {
transportConfig = new Transport(TransportResourceDefinition.LOCK_TIMEOUT.resolveModelAttribute(context, transport).asLong());
String channel = ModelNodes.asString(TransportResourceDefinition.CHANNEL.resolveModelAttribute(context, transport));
transportExecutor = ModelNodes.asString(TransportResourceDefinition.EXECUTOR.resolveModelAttribute(context, transport));
if (!name.equals(channel)) {
new BinderServiceBuilder(target).build(ChannelService.createChannelBinding(name), ChannelService.getServiceName(name), Channel.class).install();
ChannelService.build(target, name).setInitialMode(ON_DEMAND).install();
if (channel == null) {
// Transport uses the default channel - we need to find its actual name to locate the appropriate ChannelFactory service
PathAddress jgroupsAddress = address.subAddress(0, address.size() - 2).append(JGroupsSubsystemResourceDefinition.PATH);
ModelNode jgroupsModel = context.readResourceFromRoot(jgroupsAddress).getModel();
channel = ModelNodes.asString(JGroupsSubsystemResourceDefinition.DEFAULT_CHANNEL.resolveModelAttribute(context, jgroupsModel));
}
new InjectedValueServiceBuilder(target).build(ChannelService.getFactoryServiceName(name), ChannelFactoryService.getServiceName(channel), ChannelFactory.class).install();
for (GroupServiceInstaller installer : ServiceLoader.load(ClusteredGroupServiceInstaller.class, ClusteredGroupServiceInstaller.class.getClassLoader())) {
log.debugf("Installing %s for cache container %s", installer.getClass().getSimpleName(), name);
Iterator<ServiceName> serviceNames = installer.getServiceNames(channel).iterator();
for (ServiceName serviceName : installer.getServiceNames(name)) {
builder.build(serviceName, serviceNames.next(), Object.class).install();
}
}
}
}
}