use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class QueueAdd method performRuntime.
@Override
@SuppressWarnings("unchecked")
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
ServiceController<?> serverService = registry.getService(serviceName);
if (serverService != null) {
final String queueName = context.getCurrentAddressValue();
final CoreQueueConfiguration queueConfiguration = ConfigurationHelper.createCoreQueueConfiguration(context, queueName, model);
final ServiceName queueServiceName = MessagingServices.getQueueBaseServiceName(serviceName).append(queueName);
final ServiceBuilder sb = context.getServiceTarget().addService(queueServiceName);
sb.requires(ActiveMQActivationService.getServiceName(serviceName));
Supplier<ActiveMQServer> serverSupplier = sb.requires(serviceName);
final QueueService service = new QueueService(serverSupplier, queueConfiguration, false, true);
sb.setInitialMode(Mode.PASSIVE);
sb.setInstance(service);
sb.install();
}
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addQueueConfigs
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class EndpointPublisherImpl method doPublish.
/**
* Publish the webapp for the WS deployment unit
*
* @param target
* @param unit
* @return
* @throws Exception
*/
protected Context doPublish(ServiceTarget target, DeploymentUnit unit) throws Exception {
final Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
final List<Endpoint> endpoints = deployment.getService().getEndpoints();
// otherwise we need to explicitly wait for the endpoint services to be started before creating the webapp.
if (!runningInService) {
final ServiceRegistry registry = unit.getServiceRegistry();
final CountDownLatch latch = new CountDownLatch(endpoints.size());
final LifecycleListener listener = new LifecycleListener() {
@Override
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
if (event == LifecycleEvent.UP) {
latch.countDown();
controller.removeListener(this);
}
}
};
ServiceName serviceName;
for (Endpoint ep : endpoints) {
serviceName = EndpointService.getServiceName(unit, ep.getShortName());
registry.getRequiredService(serviceName).addListener(listener);
}
latch.await();
}
// TODO simplify and use findChild later in destroy()/stopWebApp()
deployment.addAttachment(WebDeploymentController.class, startWebApp(host, unit));
return new Context(unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY).getContextRoot(), endpoints);
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class TransactionExtension method getMBeanServer.
static MBeanServer getMBeanServer(OperationContext context) {
final ServiceRegistry serviceRegistry = context.getServiceRegistry(false);
final ServiceController<?> serviceController = serviceRegistry.getService(MBEAN_SERVER_SERVICE_NAME);
if (serviceController == null) {
throw TransactionLogger.ROOT_LOGGER.jmxSubsystemNotInstalled();
}
return (MBeanServer) serviceController.getValue();
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class ConnectionFactoryWriteAttributeHandler method applyUpdateToRuntime.
@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode newValue, final ModelNode currentValue, final HandbackHolder<Void> handbackHolder) throws OperationFailedException {
AttributeDefinition attr = getAttributeDefinition(attributeName);
if (attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
// Restart required
return true;
}
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) {
// The service isn't installed, so the work done in the Stage.MODEL part is all there is to it
return false;
} else if (service.getState() != ServiceController.State.UP) {
// No, don't barf; just let the update apply to the model and put the server in a reload-required state
return true;
} else {
if (!ActiveMQActivationService.isActiveMQServerActive(context, operation)) {
return false;
}
// Actually apply the update
applyOperationToActiveMQService(context, getName(operation), attributeName, newValue, service);
return false;
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class StackOperationExecutor method execute.
@Override
public ModelNode execute(OperationContext context, Operation<ChannelFactory> operation) throws OperationFailedException {
String stackName = context.getCurrentAddressValue();
ServiceRegistry registry = context.getServiceRegistry(false);
ServiceName serviceName = JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, stackName);
try {
ServiceController<ChannelFactory> controller = ServiceContainerHelper.getService(registry, serviceName);
ServiceController.Mode mode = controller.getMode();
controller.setMode(ServiceController.Mode.ACTIVE);
try {
return operation.execute(controller.awaitValue());
} finally {
controller.setMode(mode);
}
} catch (InterruptedException e) {
throw new OperationFailedException(e.getLocalizedMessage(), e);
}
}
Aggregations