Search in sources :

Example 6 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class BroadcastGroupDefinition method getAvailableConnectors.

private static Set<String> getAvailableConnectors(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    PathAddress hornetqServer = context.getCurrentAddress().getParent();
    Resource hornetQServerResource = context.readResourceFromRoot(hornetqServer);
    Set<String> availableConnectors = new HashSet<String>();
    availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.HTTP_CONNECTOR));
    availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.IN_VM_CONNECTOR));
    availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.REMOTE_CONNECTOR));
    availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.CONNECTOR));
    return availableConnectors;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) HashSet(java.util.HashSet)

Example 7 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class PooledConnectionFactoryAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    ModelNode model = resource.getModel();
    PathAddress address = context.getCurrentAddress();
    final String name = context.getCurrentAddressValue();
    final ModelNode resolvedModel = model.clone();
    for (final AttributeDefinition attribute : getDefinitions(PooledConnectionFactoryDefinition.ATTRIBUTES)) {
        resolvedModel.get(attribute.getName()).set(attribute.resolveModelAttribute(context, resolvedModel));
    }
    // We validated that jndiName part of the model in populateModel
    final List<String> jndiNames = new ArrayList<String>();
    for (ModelNode node : resolvedModel.get(Common.ENTRIES.getName()).asList()) {
        jndiNames.add(node.asString());
    }
    String managedConnectionPoolClassName = null;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName())) {
        managedConnectionPoolClassName = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName()).asString();
    }
    final int minPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE.getName()).asInt();
    final int maxPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE.getName()).asInt();
    Boolean enlistmentTrace = null;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName())) {
        enlistmentTrace = resolvedModel.get(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName()).asBoolean();
    }
    final String txSupport;
    if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName())) {
        String txType = resolvedModel.get(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName()).asString();
        if (LOCAL.equals(txType)) {
            txSupport = LOCAL_TX;
        } else if (NONE.equals(txType)) {
            txSupport = NO_TX;
        } else {
            txSupport = XA_TX;
        }
    } else {
        txSupport = XA_TX;
    }
    ServiceTarget serviceTarget = context.getServiceTarget();
    List<String> connectors = Common.CONNECTORS.unwrap(context, model);
    String discoveryGroupName = getDiscoveryGroup(resolvedModel);
    String jgroupsChannelName = null;
    if (discoveryGroupName != null) {
        Resource dgResource = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address).append(CommonAttributes.DISCOVERY_GROUP, discoveryGroupName));
        ModelNode dgModel = dgResource.getModel();
        jgroupsChannelName = JGROUPS_CHANNEL.resolveModelAttribute(context, dgModel).asString();
    }
    List<PooledConnectionFactoryConfigProperties> adapterParams = getAdapterParams(resolvedModel, context);
    final PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
    PooledConnectionFactoryService.installService(serviceTarget, name, serverAddress.getLastElement().getValue(), connectors, discoveryGroupName, jgroupsChannelName, adapterParams, jndiNames, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
    boolean statsEnabled = ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
    if (statsEnabled) {
        installStatistics(context, name);
    }
}
Also used : ServiceTarget(org.jboss.msc.service.ServiceTarget) ArrayList(java.util.ArrayList) Resource(org.jboss.as.controller.registry.Resource) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode)

Example 8 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class MessagingXmlInstallDeploymentUnitProcessor method getOrCreate.

static Resource getOrCreate(final Resource parent, final PathAddress address) {
    Resource current = parent;
    for (final PathElement element : address) {
        synchronized (current) {
            if (current.hasChild(element)) {
                current = current.requireChild(element);
            } else {
                final Resource resource = Resource.Factory.create();
                current.registerChild(element, resource);
                current = resource;
            }
        }
    }
    return current;
}
Also used : PathElement(org.jboss.as.controller.PathElement) Resource(org.jboss.as.controller.registry.Resource)

Example 9 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class SecurityRoleAttributeHandler method applyUpdateToRuntime.

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Set<Role>> handbackHolder) throws OperationFailedException {
    final ActiveMQServer server = getActiveMQServer(context, operation);
    if (server != null) {
        final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
        final String match = address.getElement(address.size() - 2).getValue();
        final String roleName = address.getLastElement().getValue();
        final Set<Role> newRoles = new HashSet<Role>();
        final Set<Role> roles = server.getSecurityRepository().getMatch(match);
        handbackHolder.setHandback(roles);
        for (final Role role : roles) {
            if (!roleName.equals(role.getName())) {
                newRoles.add(role);
            }
        }
        final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
        final ModelNode subModel = resource.getModel();
        final Role updatedRole = SecurityRoleDefinition.transform(context, roleName, subModel);
        newRoles.add(updatedRole);
        server.getSecurityRepository().addMatch(match, newRoles);
    }
    return false;
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) ActiveMQActivationService.getActiveMQServer(org.wildfly.extension.messaging.activemq.ActiveMQActivationService.getActiveMQServer) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode) HashSet(java.util.HashSet)

Example 10 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class NotEmptyResourceValidationStepHandler method validateChildren.

protected void validateChildren(OperationContext context, ModelNode operation) throws OperationFailedException {
    Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
    PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
    if (resource.getChildTypes().isEmpty()) {
        throw ROOT_LOGGER.emptyResource(pathAddress.getLastElement().toString());
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource)

Aggregations

Resource (org.jboss.as.controller.registry.Resource)93 PathAddress (org.jboss.as.controller.PathAddress)52 ModelNode (org.jboss.dmr.ModelNode)52 PathElement (org.jboss.as.controller.PathElement)25 OperationFailedException (org.jboss.as.controller.OperationFailedException)24 OperationContext (org.jboss.as.controller.OperationContext)15 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)12 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)11 Map (java.util.Map)10 ServiceName (org.jboss.msc.service.ServiceName)10 ServiceTarget (org.jboss.msc.service.ServiceTarget)10 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)9 ResourceTransformationContext (org.jboss.as.controller.transform.ResourceTransformationContext)6 ResourceTransformer (org.jboss.as.controller.transform.ResourceTransformer)6 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)6 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)6 ObjectName (javax.management.ObjectName)5 Activation (org.jboss.jca.common.api.metadata.resourceadapter.Activation)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5 ArrayList (java.util.ArrayList)4