use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class JMSBridgeRemove method recoverServices.
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String bridgeName = address.getLastElement().getValue();
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName jmsBridgeServiceName = MessagingServices.getJMSBridgeServiceName(bridgeName);
final ServiceController<?> jmsBridgeServiceController = registry.getService(jmsBridgeServiceName);
if (jmsBridgeServiceController != null && jmsBridgeServiceController.getState() == ServiceController.State.UP) {
JMSBridgeService jmsBridgeService = (JMSBridgeService) jmsBridgeServiceController.getService();
try {
jmsBridgeService.startBridge();
} catch (Exception e) {
throw MessagingLogger.ROOT_LOGGER.failedToRecover(e, bridgeName);
}
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class AbstractPojoPhase method startInternal.
protected void startInternal(StartContext context) throws StartException {
try {
executeInstalls();
// only after describe do we have a bean
if (getLifecycleState().isAfter(BeanState.DESCRIBED)) {
addCallbacks(true);
addCallbacks(false);
ServiceRegistry registry = context.getController().getServiceContainer();
InstancesService.addInstance(registry, context.getChildTarget(), getLifecycleState(), getBean());
}
// do we have a next phase
final AbstractPojoPhase nextPhase = createNextPhase();
if (nextPhase != null) {
final BeanState state = getLifecycleState();
final BeanState next = state.next();
final BeanMetaDataConfig beanConfig = getBeanConfig();
final ServiceName name = BeanMetaDataConfig.toBeanName(beanConfig.getName(), next);
final ServiceTarget serviceTarget = context.getChildTarget();
final ServiceBuilder serviceBuilder = serviceTarget.addService(name, nextPhase);
registerAliases(serviceBuilder, next);
final ConfigVisitor visitor = new DefaultConfigVisitor(serviceBuilder, state, getModule(), getIndex(), getBeanInfo());
beanConfig.visit(visitor);
nextPhase.setModule(getModule());
nextPhase.setBeanConfig(getBeanConfig());
nextPhase.setIndex(getIndex());
nextPhase.setBeanInfo(getBeanInfo());
nextPhase.setBean(getBean());
serviceBuilder.install();
}
} catch (Throwable t) {
throw new StartException(t);
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class ActiveMQServerControlWriteHandler 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 {
AttributeDefinition attr = getAttributeDefinition(attributeName);
if (attr.equals(CREDENTIAL_REFERENCE)) {
rollbackCredentialStoreUpdate(attr, context, valueToRevert);
}
if (!attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
applyOperationToActiveMQService(operation, attributeName, valueToRestore, service);
}
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class ActiveMQServerControlWriteHandler 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.equals(CREDENTIAL_REFERENCE)) {
return applyCredentialReferenceUpdateToRuntime(context, operation, newValue, currentValue, attributeName);
}
if (attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
// Restart required
return true;
} else {
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(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;
}
applyOperationToActiveMQService(operation, attributeName, newValue, service);
return false;
}
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class BridgeRemove method recoverServices.
@Override
protected void recoverServices(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
final ServiceController<?> service = registry.getService(serviceName);
if (service != null && service.getState() == ServiceController.State.UP) {
final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
final BridgeConfiguration bridgeConfiguration = BridgeAdd.createBridgeConfiguration(context, name, model);
ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
BridgeAdd.createBridge(bridgeConfiguration, server);
}
}
Aggregations