use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class ConnectionFactoryWriteAttributeHandler method revertUpdateToRuntime.
@Override
protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode valueToRestore, final ModelNode valueToRevert, final Void handback) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
applyOperationToActiveMQService(context, getName(operation), attributeName, valueToRestore, service);
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class FederationDependencyProcessor method getFederationService.
private ServiceName getFederationService(DeploymentPhaseContext phaseContext) {
DeploymentUnit deployment = phaseContext.getDeploymentUnit();
ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
// We assume the mgmt ops that trigger IdentityProviderAddHandler or ServiceProviderAddHandler
// run before the OperationStepHandler that triggers deploy. If not, that's a user mistake.
// Since those handlers run first, we can count on MSC having services *registered* even
// though we cannot count on them being *started*.
ServiceController<?> service = serviceRegistry.getService(IdentityProviderService.createServiceName(deployment.getName()));
if (service == null) {
service = serviceRegistry.getService(ServiceProviderService.createServiceName(deployment.getName()));
} else {
IdentityProviderService identityProviderService = (IdentityProviderService) service.getService();
IDPConfiguration idpType = identityProviderService.getValue().getConfiguration();
if (idpType.isExternal()) {
return null;
}
}
if (service == null) {
return null;
}
return service.getName();
}
use of org.jboss.msc.service.ServiceRegistry in project eap-additional-testsuite by jboss-set.
the class CurrentTopologyBean method getClusterMembers.
@Override
public Set<String> getClusterMembers(String cluster) {
try {
ServiceRegistry registry = currentServiceContainer();
ServiceController<?> controller = registry.getService(ServiceName.JBOSS.append("infinispan", cluster));
if (controller == null) {
throw new IllegalStateException(String.format("Failed to locate service for cluster '%s'", cluster));
}
EmbeddedCacheManager manager = ServiceContainerHelper.getValue(controller, EmbeddedCacheManager.class);
return this.getMembers(manager);
} catch (StartException e) {
throw new IllegalStateException(e);
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly-camel by wildfly-extras.
the class CamelContextRegistryService method start.
@Override
public void start(StartContext startContext) throws StartException {
ContextCreateHandlerRegistry handlerRegistry = injectedHandlerRegistry.getValue();
ServiceRegistry serviceRegistry = startContext.getController().getServiceContainer();
contextRegistry = new CamelContextRegistryImpl(handlerRegistry, serviceRegistry, startContext.getChildTarget());
// Register the service with gravia
Runtime runtime = injectedRuntime.getValue();
ModuleContext syscontext = runtime.getModuleContext();
registration = syscontext.registerService(CamelContextRegistry.class, contextRegistry, null);
for (final String name : subsystemState.getContextDefinitionNames()) {
createCamelContext(name, subsystemState.getContextDefinition(name));
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class EEJndiViewExtension method execute.
public void execute(final JndiViewExtensionContext context) throws OperationFailedException {
final ModelNode applicationsNode = context.getResult().get("applications");
final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false);
final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT);
for (final Resource.ResourceEntry entry : deploymentResource) {
final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName()));
if (deploymentUnitServiceController != null) {
final ModelNode deploymentNode = applicationsNode.get(entry.getName());
final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue());
final String appName = cleanName(deploymentUnit.getName());
final ServiceName appContextName = ContextNames.contextServiceNameOfApplication(appName);
final ServiceController<?> appContextController = serviceRegistry.getService(appContextName);
if (appContextController != null) {
final NamingStore appStore = NamingStore.class.cast(appContextController.getValue());
try {
context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null));
} catch (NamingException e) {
throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:app", appName)));
}
}
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS);
if (roots != null)
for (ResourceRoot root : roots) {
if (SubDeploymentMarker.isSubDeployment(root)) {
final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot());
final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath);
final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName);
if (subDeploymentController != null) {
final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue());
handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
}
}
}
} else {
handleModule(context, deploymentUnit, deploymentNode.get("modules"), serviceRegistry);
}
}
}
}
Aggregations