use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class SocketBroadcastGroupAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
context.reloadRequired();
} else {
final String name = context.getCurrentAddressValue();
final ServiceTarget target = context.getServiceTarget();
ServiceBuilder builder = target.addService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name));
builder.setInstance(new GroupBindingService(builder.requires(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()))));
builder.install();
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class GetInstalledDriverOperationHandler method execute.
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
validator.validate(operation);
final String name = operation.require(DRIVER_NAME.getName()).asString();
if (context.isNormalServer()) {
context.addStep(new OperationStepHandler() {
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
DriverRegistry driverRegistry = (DriverRegistry) registry.getRequiredService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE).getValue();
ServiceModuleLoader serviceModuleLoader = (ServiceModuleLoader) registry.getRequiredService(Services.JBOSS_SERVICE_MODULE_LOADER).getValue();
ModelNode result = new ModelNode();
InstalledDriver driver = driverRegistry.getInstalledDriver(name);
ModelNode driverNode = new ModelNode();
driverNode.get(DRIVER_NAME.getName()).set(driver.getDriverName());
if (driver.isFromDeployment()) {
driverNode.get(DEPLOYMENT_NAME.getName()).set(driver.getDriverName());
driverNode.get(DRIVER_MODULE_NAME.getName());
driverNode.get(MODULE_SLOT.getName());
driverNode.get(DRIVER_DATASOURCE_CLASS_NAME.getName());
driverNode.get(DRIVER_XA_DATASOURCE_CLASS_NAME.getName());
} else {
driverNode.get(DEPLOYMENT_NAME.getName());
driverNode.get(DRIVER_MODULE_NAME.getName()).set(driver.getModuleName().getName());
driverNode.get(MODULE_SLOT.getName()).set(driver.getModuleName() != null ? driver.getModuleName().getSlot() : "");
driverNode.get(DRIVER_DATASOURCE_CLASS_NAME.getName()).set(driver.getDataSourceClassName() != null ? driver.getDataSourceClassName() : "");
driverNode.get(DRIVER_XA_DATASOURCE_CLASS_NAME.getName()).set(driver.getXaDataSourceClassName() != null ? driver.getXaDataSourceClassName() : "");
}
driverNode.get(DATASOURCE_CLASS_INFO.getName()).set(dsClsInfoNode(serviceModuleLoader, driver.getModuleName(), driver.getDataSourceClassName(), driver.getXaDataSourceClassName()));
driverNode.get(DRIVER_CLASS_NAME.getName()).set(driver.getDriverClassName());
driverNode.get(DRIVER_MAJOR_VERSION.getName()).set(driver.getMajorVersion());
driverNode.get(DRIVER_MINOR_VERSION.getName()).set(driver.getMinorVersion());
driverNode.get(JDBC_COMPLIANT.getName()).set(driver.isJdbcCompliant());
result.add(driverNode);
context.getResult().set(result);
}
}, OperationContext.Stage.RUNTIME);
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class GlobalDirectoryDependencyProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ServiceName depUnitServiceName = deploymentUnit.getServiceName();
final DeploymentUnit parent = deploymentUnit.getParent();
final DeploymentUnit topLevelDeployment = parent == null ? deploymentUnit : parent;
final ExternalModule externalModuleService = topLevelDeployment.getAttachment(Attachments.EXTERNAL_MODULE_SERVICE);
final ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final CapabilityServiceSupport capabilitySupport = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
final ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
final ServiceTarget target = phaseContext.getServiceTarget();
final ServiceTarget externalServiceTarget = deploymentUnit.getAttachment(Attachments.EXTERNAL_SERVICE_TARGET);
final ServiceName allDirReadyServiceName = depUnitServiceName.append("directory-services-ready");
final ServiceBuilder<?> allDirReadyServiceBuilder = target.addService(allDirReadyServiceName);
final List<Supplier<GlobalDirectoryResourceDefinition.GlobalDirectory>> allDirReadySuppliers = new ArrayList<>();
final ServiceName csName = capabilitySupport.getCapabilityServiceName(EE_GLOBAL_DIRECTORY_CAPABILITY_NAME);
List<ServiceName> serviceNames = serviceRegistry.getServiceNames();
for (ServiceName serviceName : serviceNames) {
if (csName.isParentOf(serviceName)) {
Supplier<GlobalDirectoryResourceDefinition.GlobalDirectory> pathRequirement = allDirReadyServiceBuilder.requires(serviceName);
allDirReadySuppliers.add(pathRequirement);
}
}
if (!allDirReadySuppliers.isEmpty()) {
GlobalDirectoryDeploymentService globalDirDepService = new GlobalDirectoryDeploymentService(allDirReadySuppliers, externalModuleService, moduleSpecification, moduleLoader, serviceRegistry, externalServiceTarget);
allDirReadyServiceBuilder.requires(phaseContext.getPhaseServiceName());
allDirReadyServiceBuilder.setInstance(globalDirDepService).install();
phaseContext.requires(allDirReadyServiceName, new DelegatingSupplier());
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class AbstractDataSourceOperations method getDataSource.
// --- //
private static AgroalDataSource getDataSource(OperationContext context) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
String dataSourceName = context.getCurrentAddressValue();
switch(context.getCurrentAddress().getLastElement().getKey()) {
case DataSourceOperations.DATASOURCE_SERVICE_NAME:
ServiceController<?> controller = registry.getRequiredService(AbstractDataSourceDefinition.DATA_SOURCE_CAPABILITY.getCapabilityServiceName(dataSourceName));
return ((AgroalDataSource) controller.getValue());
case XADataSourceOperations.XADATASOURCE_SERVICE_NAME:
ServiceController<?> xaController = registry.getRequiredService(AbstractDataSourceDefinition.DATA_SOURCE_CAPABILITY.getCapabilityServiceName(dataSourceName));
return ((AgroalDataSource) xaController.getValue());
default:
throw AgroalLogger.SERVICE_LOGGER.unknownDatasourceServiceType(context.getCurrentAddress().getLastElement().getKey());
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class RaOperationUtil method restartIfPresent.
public static ServiceName restartIfPresent(OperationContext context, final String raName, final String id) throws OperationFailedException {
final ServiceName raDeploymentServiceName = ConnectorServices.getDeploymentServiceName(raName, id);
final ServiceRegistry registry = context.getServiceRegistry(true);
ServiceController raServiceController = registry.getService(raDeploymentServiceName);
if (raServiceController != null) {
final org.jboss.msc.service.ServiceController.Mode originalMode = raServiceController.getMode();
final UninterruptibleCountDownLatch latch = new UninterruptibleCountDownLatch(1);
raServiceController.addListener(new LifecycleListener() {
@Override
public void handleEvent(ServiceController controller, LifecycleEvent event) {
latch.awaitUninterruptibly();
if (event == LifecycleEvent.DOWN) {
try {
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, id));
Activation raxml = (Activation) RaxmlController.getValue();
((ResourceAdapterXmlDeploymentService) controller.getService()).setRaxml(raxml);
controller.compareAndSetMode(ServiceController.Mode.NEVER, originalMode);
} finally {
controller.removeListener(this);
}
}
}
});
try {
raServiceController.setMode(ServiceController.Mode.NEVER);
} finally {
latch.countDown();
}
return raDeploymentServiceName;
} else {
return null;
}
}
Aggregations