Search in sources :

Example 1 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class CmpKeyGeneratorSubsystem11TestCase method assertOperation.

private void assertOperation(final ModelNode operation, final String operationName, final PathElement lastElement) {
    assertEquals(operationName, operation.get(OP).asString());
    final PathAddress addr = PathAddress.pathAddress(operation.get(OP_ADDR));
    final PathElement element = addr.getLastElement();
    assertEquals(lastElement.getKey(), element.getKey());
    assertEquals(lastElement.getValue(), element.getValue());
}
Also used : PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress)

Example 2 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class JMSConnectionFactoryDefinitionInjectionSource method startedPooledConnectionFactory.

private void startedPooledConnectionFactory(ResolutionContext context, String name, ServiceBuilder<?> serviceBuilder, ServiceTarget serviceTarget, DeploymentUnit deploymentUnit, Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException, OperationFailedException {
    Map<String, String> props = new HashMap<>(properties);
    List<String> connectors = getConnectors(props);
    clearUnknownProperties(properties);
    ModelNode model = new ModelNode();
    for (String connector : connectors) {
        model.get(CONNECTORS).add(connector);
    }
    for (Map.Entry<String, String> entry : properties.entrySet()) {
        model.get(entry.getKey()).set(entry.getValue());
    }
    model.get(MIN_POOL_SIZE.getName()).set(minPoolSize);
    model.get(MAX_POOL_SIZE.getName()).set(maxPoolSize);
    if (user != null && !user.isEmpty()) {
        model.get(ConnectionFactoryAttributes.Pooled.USER.getName()).set(user);
    }
    if (password != null && !password.isEmpty()) {
        model.get(ConnectionFactoryAttributes.Pooled.PASSWORD.getName()).set(password);
    }
    if (clientId != null && !clientId.isEmpty()) {
        model.get(CommonAttributes.CLIENT_ID.getName()).set(clientId);
    }
    final String discoveryGroupName = properties.containsKey(DISCOVERY_GROUP.getName()) ? properties.get(DISCOVERY_GROUP.getName()) : null;
    if (discoveryGroupName != null) {
        model.get(DISCOVERY_GROUP.getName()).set(discoveryGroupName);
    }
    final String jgroupsChannelName = properties.containsKey(JGROUPS_CHANNEL.getName()) ? properties.get(JGROUPS_CHANNEL.getName()) : null;
    if (jgroupsChannelName != null) {
        model.get(JGROUPS_CHANNEL.getName()).set(jgroupsChannelName);
    }
    final String managedConnectionPoolClassName = properties.containsKey(MANAGED_CONNECTION_POOL.getName()) ? properties.get(MANAGED_CONNECTION_POOL.getName()) : null;
    if (managedConnectionPoolClassName != null) {
        model.get(MANAGED_CONNECTION_POOL.getName()).set(managedConnectionPoolClassName);
    }
    final Boolean enlistmentTrace = properties.containsKey(ENLISTMENT_TRACE.getName()) ? Boolean.valueOf(properties.get(ENLISTMENT_TRACE.getName())) : null;
    List<PooledConnectionFactoryConfigProperties> adapterParams = getAdapterParams(model);
    String txSupport = transactional ? XA_TX : NO_TX;
    final String serverName = getActiveMQServerName(properties);
    final String pcfName = uniqueName(context, name);
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), name);
    PooledConnectionFactoryService.installService(serviceTarget, pcfName, serverName, connectors, discoveryGroupName, jgroupsChannelName, adapterParams, bindInfo, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace, true);
    final ServiceName referenceFactoryServiceName = ConnectionFactoryReferenceFactoryService.SERVICE_NAME_BASE.append(bindInfo.getBinderServiceName());
    serviceBuilder.addDependency(referenceFactoryServiceName, ManagedReferenceFactory.class, injector);
    //create the management registration
    String managementName = managementName(context, name);
    final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
    final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
    deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
    final PathElement pcfPath = PathElement.pathElement(POOLED_CONNECTION_FACTORY, managementName);
    PathAddress registration = PathAddress.pathAddress(serverElement, pcfPath);
    MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
    PooledConnectionFactoryConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, managementName, model);
}
Also used : HashMap(java.util.HashMap) PooledConnectionFactoryConfigProperties(org.wildfly.extension.messaging.activemq.jms.PooledConnectionFactoryConfigProperties) DeploymentResourceSupport(org.jboss.as.server.deployment.DeploymentResourceSupport) PathElement(org.jboss.as.controller.PathElement) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map) HashMap(java.util.HashMap) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 3 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class JMSDestinationDefinitionInjectionSource method startQueue.

/**
     * To workaround ActiveMQ's BindingRegistry limitation in {@link WildFlyBindingRegistry}
     * that does not allow to build a BindingInfo with the ResolutionContext info, the JMS queue is created *without* any
     * JNDI bindings and handle the JNDI bindings directly by getting the service's JMS queue.
    */
private void startQueue(final String queueName, final ServiceTarget serviceTarget, final ServiceName serverServiceName, final ServiceBuilder<?> serviceBuilder, final DeploymentUnit deploymentUnit, final Injector<ManagedReferenceFactory> injector) {
    final String selector = properties.containsKey(SELECTOR.getName()) ? properties.get(SELECTOR.getName()) : null;
    final boolean durable = properties.containsKey(DURABLE.getName()) ? Boolean.valueOf(properties.get(DURABLE.getName())) : DURABLE.getDefaultValue().asBoolean();
    ModelNode destination = new ModelNode();
    destination.get(NAME).set(queueName);
    destination.get(DURABLE.getName()).set(durable);
    if (selector != null) {
        destination.get(SELECTOR.getName()).set(selector);
    }
    destination.get(ENTRIES).add(jndiName);
    Service<Queue> queueService = JMSQueueService.installService(queueName, serviceTarget, serverServiceName, selector, durable, new String[0]);
    inject(serviceBuilder, injector, queueService);
    //create the management registration
    String serverName = getActiveMQServerName(properties);
    final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
    final PathElement dest = PathElement.pathElement(JMS_QUEUE, queueName);
    final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
    deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
    PathAddress registration = PathAddress.pathAddress(serverElement, dest);
    MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
    JMSQueueConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, queueName, destination);
}
Also used : DeploymentResourceSupport(org.jboss.as.server.deployment.DeploymentResourceSupport) PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) Queue(javax.jms.Queue)

Example 4 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class SecuritySubsystemParser_3_0 method parseElytronRealm.

protected void parseElytronRealm(final XMLExtendedStreamReader reader, final List<ModelNode> operations, final PathAddress subsystemPath) throws XMLStreamException {
    final ModelNode elytronRealmAddOperation = Util.createAddOperation();
    PathElement elytronRealmPath = null;
    final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.LEGACY_JAAS_CONFIG);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch(attribute) {
            case NAME:
                {
                    if (value == null || value.length() == 0) {
                        throw invalidAttributeValue(reader, i);
                    }
                    elytronRealmPath = PathElement.pathElement(ELYTRON_REALM, value);
                    break;
                }
            case LEGACY_JAAS_CONFIG:
                {
                    LEGACY_JAAS_CONFIG.parseAndSetParameter(value, elytronRealmAddOperation, reader);
                    break;
                }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }
    elytronRealmAddOperation.get(OP_ADDR).set(subsystemPath.append(elytronRealmPath).toModelNode());
    operations.add(elytronRealmAddOperation);
    requireNoContent(reader);
}
Also used : PathElement(org.jboss.as.controller.PathElement) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ModelNode(org.jboss.dmr.ModelNode)

Example 5 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class SecuritySubsystemParser_3_0 method parseTLSEntity.

protected void parseTLSEntity(final XMLExtendedStreamReader reader, final List<ModelNode> operations, final PathAddress subsystemPath, final String tlsEntityName) throws XMLStreamException {
    final ModelNode elytronTLSEntityAddOperation = Util.createAddOperation();
    PathElement elytronTLSEntityPath = null;
    final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.LEGACY_JSSE_CONFIG);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch(attribute) {
            case NAME:
                {
                    if (value == null || value.length() == 0) {
                        throw invalidAttributeValue(reader, i);
                    }
                    elytronTLSEntityPath = PathElement.pathElement(tlsEntityName, value);
                    break;
                }
            case LEGACY_JSSE_CONFIG:
                {
                    LEGACY_JSSE_CONFIG.parseAndSetParameter(value, elytronTLSEntityAddOperation, reader);
                    break;
                }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    if (required.size() > 0) {
        throw missingRequired(reader, required);
    }
    elytronTLSEntityAddOperation.get(OP_ADDR).set(subsystemPath.append(elytronTLSEntityPath).toModelNode());
    operations.add(elytronTLSEntityAddOperation);
    requireNoContent(reader);
}
Also used : PathElement(org.jboss.as.controller.PathElement) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

PathElement (org.jboss.as.controller.PathElement)82 PathAddress (org.jboss.as.controller.PathAddress)45 ModelNode (org.jboss.dmr.ModelNode)45 Resource (org.jboss.as.controller.registry.Resource)24 ServiceName (org.jboss.msc.service.ServiceName)12 OperationFailedException (org.jboss.as.controller.OperationFailedException)11 Test (org.junit.Test)10 Map (java.util.Map)9 ArrayList (java.util.ArrayList)8 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)8 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)7 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)7 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)7 DeploymentResourceSupport (org.jboss.as.server.deployment.DeploymentResourceSupport)7 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)7 ServiceTarget (org.jboss.msc.service.ServiceTarget)6 StatisticsResourceDefinition (org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition)4 OperationContext (org.jboss.as.controller.OperationContext)4 StandardResourceDescriptionResolver (org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver)4 AliasEntry (org.jboss.as.controller.registry.AliasEntry)4