use of org.jboss.as.connector.services.resourceadapters.statistics.AdminObjectStatisticsService in project wildfly by wildfly.
the class AdminObjectAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, final Resource resource) throws OperationFailedException {
final ModelNode address = operation.require(OP_ADDR);
PathAddress path = PathAddress.pathAddress(address);
final String raName = context.getCurrentAddress().getParent().getLastElement().getValue();
final String archiveOrModuleName;
ModelNode raModel = context.readResourceFromRoot(path.subAddress(0, path.size() - 1)).getModel();
final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, raModel).asBoolean();
if (!raModel.hasDefined(ARCHIVE.getName()) && !raModel.hasDefined(MODULE.getName())) {
throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired();
}
if (raModel.get(ARCHIVE.getName()).isDefined()) {
archiveOrModuleName = ARCHIVE.resolveModelAttribute(context, raModel).asString();
} else {
archiveOrModuleName = MODULE.resolveModelAttribute(context, raModel).asString();
}
final String poolName = PathAddress.pathAddress(address).getLastElement().getValue();
final ModifiableAdminObject adminObjectValue;
try {
adminObjectValue = RaOperationUtil.buildAdminObjects(context, operation, poolName);
} catch (ValidateException e) {
throw new OperationFailedException(e, new ModelNode().set(ConnectorLogger.ROOT_LOGGER.failedToCreate("AdminObject", operation, e.getLocalizedMessage())));
}
ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName, poolName);
ServiceName raServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName);
final ServiceTarget serviceTarget = context.getServiceTarget();
final AdminObjectService service = new AdminObjectService(adminObjectValue);
serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(raServiceName, ModifiableResourceAdapter.class, service.getRaInjector()).install();
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, raName));
Activation raxml = (Activation) RaxmlController.getValue();
ServiceName deploymentServiceName = ConnectorServices.getDeploymentServiceName(archiveOrModuleName, raName);
String bootStrapCtxName = DEFAULT_NAME;
if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().equals("undefined")) {
bootStrapCtxName = raxml.getBootstrapContext();
}
AdminObjectStatisticsService adminObjectStatisticsService = new AdminObjectStatisticsService(context.getResourceRegistrationForUpdate(), poolName, statsEnabled);
ServiceBuilder statsServiceBuilder = serviceTarget.addService(serviceName.append(ConnectorServices.STATISTICS_SUFFIX), adminObjectStatisticsService);
statsServiceBuilder.addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootStrapCtxName), adminObjectStatisticsService.getBootstrapContextInjector()).addDependency(deploymentServiceName, adminObjectStatisticsService.getResourceAdapterDeploymentInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
PathElement peAO = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
final Resource aoResource = new IronJacamarResource.IronJacamarRuntimeResource();
resource.registerChild(peAO, aoResource);
}
Aggregations