Search in sources :

Example 61 with PathElement

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

the class IronJacamarResourceCreator method addConnectionDefinition.

private void addConnectionDefinition(final Resource parent, ConnectionDefinition connDef) {
    final Resource connDefResource = new IronJacamarResource.IronJacamarRuntimeResource();
    final ModelNode model = connDefResource.getModel();
    setAttribute(model, Constants.JNDINAME, connDef.getJndiName());
    if (connDef.getConfigProperties() != null) {
        for (Map.Entry<String, String> config : connDef.getConfigProperties().entrySet()) {
            addConfigProperties(connDefResource, config.getKey(), config.getValue());
        }
    }
    setAttribute(model, CLASS_NAME, connDef.getClassName());
    setAttribute(model, JNDINAME, connDef.getJndiName());
    setAttribute(model, USE_JAVA_CONTEXT, connDef.isUseJavaContext());
    setAttribute(model, ENABLED, connDef.isEnabled());
    setAttribute(model, CONNECTABLE, connDef.isConnectable());
    if (connDef.isTracking() != null) {
        setAttribute(model, TRACKING, connDef.isTracking());
    }
    setAttribute(model, USE_CCM, connDef.isUseCcm());
    setAttribute(model, SHARABLE, connDef.isSharable());
    setAttribute(model, ENLISTMENT, connDef.isEnlistment());
    final Pool pool = connDef.getPool();
    if (pool != null) {
        setAttribute(model, MAX_POOL_SIZE, pool.getMaxPoolSize());
        setAttribute(model, MIN_POOL_SIZE, pool.getMinPoolSize());
        setAttribute(model, INITIAL_POOL_SIZE, pool.getInitialPoolSize());
        if (pool.getCapacity() != null) {
            if (pool.getCapacity().getIncrementer() != null) {
                setAttribute(model, CAPACITY_INCREMENTER_CLASS, pool.getCapacity().getIncrementer().getClassName());
                if (pool.getCapacity().getIncrementer().getConfigPropertiesMap() != null) {
                    for (Map.Entry<String, String> config : pool.getCapacity().getIncrementer().getConfigPropertiesMap().entrySet()) {
                        model.get(CAPACITY_INCREMENTER_PROPERTIES.getName(), config.getKey()).set(config.getValue());
                    }
                }
            }
            if (pool.getCapacity().getDecrementer() != null) {
                setAttribute(model, CAPACITY_DECREMENTER_CLASS, pool.getCapacity().getDecrementer().getClassName());
                if (pool.getCapacity().getDecrementer().getConfigPropertiesMap() != null) {
                    for (Map.Entry<String, String> config : pool.getCapacity().getDecrementer().getConfigPropertiesMap().entrySet()) {
                        model.get(CAPACITY_DECREMENTER_PROPERTIES.getName(), config.getKey()).set(config.getValue());
                    }
                }
            }
        }
        setAttribute(model, POOL_USE_STRICT_MIN, pool.isUseStrictMin());
        if (pool.getFlushStrategy() != null)
            setAttribute(model, POOL_FLUSH_STRATEGY, pool.getFlushStrategy().name());
        setAttribute(model, POOL_PREFILL, pool.isPrefill());
        setAttribute(model, POOL_FAIR, pool.isFair());
        if (connDef.isXa()) {
            assert connDef.getPool() instanceof XaPool;
            XaPool xaPool = (XaPool) connDef.getPool();
            setAttribute(model, WRAP_XA_RESOURCE, xaPool.isWrapXaResource());
            setAttribute(model, SAME_RM_OVERRIDE, xaPool.isSameRmOverride());
            setAttribute(model, PAD_XID, xaPool.isPadXid());
            setAttribute(model, INTERLEAVING, xaPool.isInterleaving());
            setAttribute(model, NOTXSEPARATEPOOL, xaPool.isNoTxSeparatePool());
        }
    }
    final Security security = (Security) connDef.getSecurity();
    if (security != null) {
        setAttribute(model, APPLICATION, security.isApplication());
        if (security.isElytronEnabled()) {
            setAttribute(model, ELYTRON_ENABLED, true);
            setAttribute(model, AUTHENTICATION_CONTEXT, security.getSecurityDomain());
            setAttribute(model, AUTHENTICATION_CONTEXT_AND_APPLICATION, security.getSecurityDomainAndApplication());
        } else {
            setAttribute(model, SECURITY_DOMAIN, security.getSecurityDomain());
            setAttribute(model, SECURITY_DOMAIN_AND_APPLICATION, security.getSecurityDomainAndApplication());
        }
    }
    final TimeOut timeOut = connDef.getTimeOut();
    if (timeOut != null) {
        setAttribute(model, ALLOCATION_RETRY, timeOut.getAllocationRetry());
        setAttribute(model, ALLOCATION_RETRY_WAIT_MILLIS, timeOut.getAllocationRetryWaitMillis());
        setAttribute(model, BLOCKING_TIMEOUT_WAIT_MILLIS, timeOut.getBlockingTimeoutMillis());
        setAttribute(model, IDLETIMEOUTMINUTES, timeOut.getIdleTimeoutMinutes());
        setAttribute(model, XA_RESOURCE_TIMEOUT, timeOut.getXaResourceTimeout());
    }
    final Validation validation = connDef.getValidation();
    if (validation != null) {
        setAttribute(model, BACKGROUNDVALIDATIONMILLIS, validation.getBackgroundValidationMillis());
        setAttribute(model, BACKGROUNDVALIDATION, validation.isBackgroundValidation());
        setAttribute(model, USE_FAST_FAIL, validation.isUseFastFail());
        setAttribute(model, VALIDATE_ON_MATCH, validation.isValidateOnMatch());
    }
    final Recovery recovery = connDef.getRecovery();
    if (recovery != null) {
        setAttribute(model, NO_RECOVERY, recovery.getNoRecovery());
        final Extension recoverPlugin = recovery.getRecoverPlugin();
        if (recoverPlugin != null) {
            setAttribute(model, RECOVERLUGIN_CLASSNAME, recoverPlugin.getClassName());
            if (recoverPlugin.getConfigPropertiesMap() != null) {
                for (Map.Entry<String, String> config : recoverPlugin.getConfigPropertiesMap().entrySet()) {
                    model.get(RECOVERLUGIN_PROPERTIES.getName(), config.getKey()).set(config.getValue());
                }
            }
        }
        final Credential recoveryCredential = (Credential) recovery.getCredential();
        if (recoveryCredential != null) {
            setAttribute(model, RECOVERY_PASSWORD, recoveryCredential.getPassword());
            if (recoveryCredential.isElytronEnabled()) {
                setAttribute(model, RECOVERY_ELYTRON_ENABLED, true);
                setAttribute(model, RECOVERY_AUTHENTICATION_CONTEXT, recoveryCredential.getSecurityDomain());
            } else {
                setAttribute(model, RECOVERY_SECURITY_DOMAIN, recoveryCredential.getSecurityDomain());
            }
            setAttribute(model, RECOVERY_USERNAME, recoveryCredential.getUserName());
        }
    }
    final Resource statsResource = new IronJacamarResource.IronJacamarRuntimeResource();
    connDefResource.registerChild(PathElement.pathElement(Constants.STATISTICS_NAME, "local"), statsResource);
    final PathElement element = PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME, connDef.getJndiName());
    parent.registerChild(element, connDefResource);
}
Also used : Validation(org.jboss.jca.common.api.metadata.common.Validation) XaPool(org.jboss.jca.common.api.metadata.common.XaPool) Credential(org.jboss.as.connector.metadata.api.common.Credential) TimeOut(org.jboss.jca.common.api.metadata.common.TimeOut) Resource(org.jboss.as.controller.registry.Resource) WorkManagerSecurity(org.jboss.as.connector.metadata.api.resourceadapter.WorkManagerSecurity) Security(org.jboss.as.connector.metadata.api.common.Security) Recovery(org.jboss.jca.common.api.metadata.common.Recovery) Extension(org.jboss.jca.common.api.metadata.common.Extension) PathElement(org.jboss.as.controller.PathElement) XaPool(org.jboss.jca.common.api.metadata.common.XaPool) Pool(org.jboss.jca.common.api.metadata.common.Pool) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map)

Example 62 with PathElement

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

the class IronJacamarResourceCreator method execute.

public void execute(Resource parentResource, AS7MetadataRepository mdr, String name) {
    // Get the iron-jacamar resource
    final IronJacamarResource ironJacamarResource = new IronJacamarResource();
    // Replace the current model with an updated one
    final Resource storeModel = getIronJacamarResource(mdr, name);
    ironJacamarResource.update(storeModel);
    PathElement ijPe = PathElement.pathElement(Constants.IRONJACAMAR_NAME, Constants.IRONJACAMAR_NAME);
    if (parentResource.getChild(ijPe) == null) {
        parentResource.registerChild(ijPe, ironJacamarResource);
    }
}
Also used : PathElement(org.jboss.as.controller.PathElement) Resource(org.jboss.as.controller.registry.Resource)

Example 63 with PathElement

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

the class AbstractXMLDataSourceRuntimeHandler method getDataSourceConfig.

private T getDataSourceConfig(final PathAddress operationAddress) throws OperationFailedException {
    final List<PathElement> relativeAddress = new ArrayList<PathElement>();
    for (int i = operationAddress.size() - 1; i >= 0; i--) {
        PathElement pe = operationAddress.getElement(i);
        relativeAddress.add(0, pe);
        if (ModelDescriptionConstants.DEPLOYMENT.equals(pe.getKey())) {
            break;
        }
    }
    final PathAddress pa = PathAddress.pathAddress(relativeAddress);
    final T config;
    if (operationAddress.getLastElement().getKey().equals(CONNECTION_PROPERTIES) || operationAddress.getLastElement().getKey().equals(XA_DATASOURCE_PROPERTIES)) {
        config = dataSourceConfigs.get(pa.subAddress(0, pa.size() - 1));
    } else {
        config = dataSourceConfigs.get(pa);
    }
    if (config == null) {
        String exceptionMessage = ConnectorLogger.ROOT_LOGGER.noDataSourceRegisteredForAddress(operationAddress);
        throw new OperationFailedException(exceptionMessage);
    }
    return config;
}
Also used : PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 64 with PathElement

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

the class LogStoreProbeHandler method addTransactions.

private void addTransactions(final Resource parent, Set<ObjectInstance> transactions, MBeanServer mbs) throws IntrospectionException, InstanceNotFoundException, IOException, ReflectionException, MalformedObjectNameException {
    for (ObjectInstance oi : transactions) {
        String transactionId = oi.getObjectName().getCanonicalName();
        if (!transactionId.contains("puid") && transactionId.contains("itype")) {
            final Resource transaction = new LogStoreResource.LogStoreRuntimeResource(oi.getObjectName());
            final ModelNode model = transaction.getModel();
            Map<String, String> tAttributes = getMBeanValues(mbs, oi.getObjectName(), LogStoreConstants.TXN_JMX_NAMES);
            String txnId = tAttributes.get("Id");
            addAttributes(model, LogStoreConstants.MODEL_TO_JMX_TXN_NAMES, tAttributes);
            // model.get(LogStoreConstants.JMX_ON_ATTRIBUTE).set(transactionId);
            String participantQuery = transactionId + ",puid=*";
            Set<ObjectInstance> participants = mbs.queryMBeans(new ObjectName(participantQuery), null);
            addParticipants(transaction, participants, mbs);
            final PathElement element = PathElement.pathElement(LogStoreConstants.TRANSACTIONS, txnId);
            parent.registerChild(element, transaction);
        }
    }
}
Also used : PathElement(org.jboss.as.controller.PathElement) ObjectInstance(javax.management.ObjectInstance) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode) ObjectName(javax.management.ObjectName)

Example 65 with PathElement

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

the class BackupsResourceDefinition method buildTransformation.

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    PathAddressTransformer addressTransformer = new PathAddressTransformer() {

        @Override
        public PathAddress transform(PathElement current, Builder builder) {
            return builder.next();
        }
    };
    ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, addressTransformer) : parent.addChildResource(PATH);
    BackupResourceDefinition.buildTransformation(version, builder);
}
Also used : PathElement(org.jboss.as.controller.PathElement) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) PathAddressTransformer(org.jboss.as.controller.transform.PathAddressTransformer)

Aggregations

PathElement (org.jboss.as.controller.PathElement)70 PathAddress (org.jboss.as.controller.PathAddress)35 ModelNode (org.jboss.dmr.ModelNode)32 Resource (org.jboss.as.controller.registry.Resource)24 OperationFailedException (org.jboss.as.controller.OperationFailedException)10 ServiceName (org.jboss.msc.service.ServiceName)10 Map (java.util.Map)9 ServiceTarget (org.jboss.msc.service.ServiceTarget)9 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)8 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)7 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)5 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)5 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 StatisticsResourceDefinition (org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition)4 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)4 OperationContext (org.jboss.as.controller.OperationContext)4 StandardResourceDescriptionResolver (org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver)4 StatisticsPlugin (org.jboss.jca.core.spi.statistics.StatisticsPlugin)4