use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class PassivationStoreWriteHandler method applyModelToRuntime.
private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException {
String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
ServiceName serviceName = DistributableCacheFactoryBuilderService.getServiceName(name);
ServiceRegistry registry = context.getServiceRegistry(true);
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
DistributableCacheFactoryBuilder<?, ?> builder = (DistributableCacheFactoryBuilder<?, ?>) service.getValue();
if (builder != null) {
if (this.maxSizeAttribute.getName().equals(attributeName)) {
int maxSize = this.maxSizeAttribute.resolveModelAttribute(context, model).asInt();
builder.getConfiguration().setMaxSize(maxSize);
}
}
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class ProtocolResourceRegistrationHandler method findProtocol.
@Override
public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException {
PathAddress address = context.getCurrentAddress();
String channelName = address.getParent().getLastElement().getValue();
String protocolName = address.getLastElement().getValue();
ServiceRegistry registry = context.getServiceRegistry(false);
ServiceController<?> controller = registry.getService(JGroupsRequirement.CHANNEL.getServiceName(context, channelName));
if (controller != null) {
Channel channel = (Channel) controller.getValue();
if (channel != null) {
controller = registry.getService(JGroupsRequirement.CHANNEL_SOURCE.getServiceName(context, channelName));
ChannelFactory factory = (ChannelFactory) controller.getValue();
if (factory != null) {
ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration();
ProtocolConfiguration<? extends TP> transport = configuration.getTransport();
if (transport.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = transport.createProtocol().getClass();
return channel.getProtocolStack().findProtocol(protocolClass);
}
for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) {
if (protocol.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = protocol.createProtocol().getClass();
return channel.getProtocolStack().findProtocol(protocolClass);
}
}
}
}
}
return null;
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class ForkProtocolResourceRegistrationHandler method findProtocol.
@Override
public Protocol findProtocol(OperationContext context) throws ClassNotFoundException, ModuleLoadException {
PathAddress address = context.getCurrentAddress();
String channelName = address.getElement(address.size() - 3).getValue();
String forkName = address.getElement(address.size() - 2).getValue();
String protocolName = address.getElement(address.size() - 1).getValue();
ServiceRegistry registry = context.getServiceRegistry(false);
ServiceController<?> controller = registry.getService(JGroupsRequirement.CHANNEL.getServiceName(context, channelName));
if (controller != null) {
Channel channel = (Channel) controller.getValue();
if (channel != null) {
FORK fork = (FORK) channel.getProtocolStack().findProtocol(FORK.class);
if (fork != null) {
controller = registry.getService(JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, channelName));
if (controller != null) {
ChannelFactory factory = (ChannelFactory) controller.getValue();
if (factory != null) {
ProtocolStackConfiguration configuration = factory.getProtocolStackConfiguration();
ProtocolConfiguration<? extends TP> transport = configuration.getTransport();
if (transport.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = transport.createProtocol().getClass();
return channel.getProtocolStack().findProtocol(protocolClass);
}
for (ProtocolConfiguration<? extends Protocol> protocol : configuration.getProtocols()) {
if (protocol.getName().equals(protocolName)) {
Class<? extends Protocol> protocolClass = protocol.createProtocol().getClass();
return fork.get(forkName).getProtocolStack().findProtocol(protocolClass);
}
}
}
}
}
}
}
return null;
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class BroadcastGroupAdd 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 PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
final ServiceTarget target = context.getServiceTarget();
if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
// nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
} else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
final GroupBindingService bindingService = new GroupBindingService();
target.addService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name), bindingService).addDependency(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()), SocketBinding.class, bindingService.getBindingRef()).install();
}
}
}
use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.
the class DiscoveryGroupAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
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 ServiceTarget target = context.getServiceTarget();
if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
// nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
} else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
final GroupBindingService bindingService = new GroupBindingService();
target.addService(GroupBindingService.getDiscoveryBaseServiceName(serviceName).append(name), bindingService).addDependency(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()), SocketBinding.class, bindingService.getBindingRef()).install();
}
}
}
Aggregations