Search in sources :

Example 1 with ServiceRegistry

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);
            }
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) DistributableCacheFactoryBuilder(org.jboss.as.ejb3.cache.distributable.DistributableCacheFactoryBuilder)

Example 2 with ServiceRegistry

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;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Channel(org.jgroups.Channel) ProtocolStackConfiguration(org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory)

Example 3 with ServiceRegistry

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;
}
Also used : FORK(org.jgroups.protocols.FORK) PathAddress(org.jboss.as.controller.PathAddress) Channel(org.jgroups.Channel) ProtocolStackConfiguration(org.wildfly.clustering.jgroups.spi.ProtocolStackConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory)

Example 4 with ServiceRegistry

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();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 5 with ServiceRegistry

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();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Aggregations

ServiceRegistry (org.jboss.msc.service.ServiceRegistry)74 ServiceName (org.jboss.msc.service.ServiceName)51 ModelNode (org.jboss.dmr.ModelNode)22 PathAddress (org.jboss.as.controller.PathAddress)15 ServiceTarget (org.jboss.msc.service.ServiceTarget)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)13 ServiceController (org.jboss.msc.service.ServiceController)12 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)8 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)8 OperationContext (org.jboss.as.controller.OperationContext)6 Resource (org.jboss.as.controller.registry.Resource)6 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)5 Activation (org.jboss.jca.common.api.metadata.resourceadapter.Activation)5 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)4 PathElement (org.jboss.as.controller.PathElement)4 DefaultAccessTimeoutService (org.jboss.as.ejb3.component.DefaultAccessTimeoutService)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 ArrayList (java.util.ArrayList)2 BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)2 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)2