final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
//get the server config object from the ServerConfigService (service installed and not started yet, but the object is fine for our needs here)
final ServerConfig serverConfig = ASHelper.getMSCService(WSServices.CONFIG_SERVICE, ServerConfig.class, context);
final ServiceName serviceName = getClientConfigServiceName(name);
final ConfigService clientConfigService = new ConfigService(serverConfig, name, true);
final ServiceTarget target = context.getServiceTarget();
final ServiceBuilder<?> clientServiceBuilder = target.addService(serviceName, clientConfigService);
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PROPERTY)) {
clientServiceBuilder.addDependency(sn, PropertyService.class, clientConfigService.getPropertiesInjector()); //get a new injector instance each time
}
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PRE_HANDLER_CHAIN)) {
clientServiceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, clientConfigService.getPreHandlerChainsInjector()); //get a new injector instance each time
}
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.POST_HANDLER_CHAIN)) {
clientServiceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, clientConfigService.getPostHandlerChainsInjector()); //get a new injector instance each time
}
ServiceController<?> controller = clientServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
if (newControllers != null) {
newControllers.add(controller);
}