Search in sources :

Example 1 with Pool

use of org.jboss.jca.common.api.metadata.common.Pool in project wildfly by wildfly.

the class RaOperationUtil method buildConnectionDefinitionObject.

public static ModifiableConnDef buildConnectionDefinitionObject(final OperationContext context, final ModelNode connDefModel, final String poolName, final boolean isXa, ExceptionSupplier<CredentialSource, Exception> recoveryCredentialSourceSupplier) throws OperationFailedException, ValidateException {
    Map<String, String> configProperties = new HashMap<String, String>(0);
    String className = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, CLASS_NAME);
    String jndiName = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, JNDINAME);
    boolean enabled = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, ENABLED);
    boolean connectable = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, CONNECTABLE);
    Boolean tracking = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, TRACKING);
    boolean useJavaContext = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, USE_JAVA_CONTEXT);
    boolean useCcm = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, USE_CCM);
    boolean sharable = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, SHARABLE);
    boolean enlistment = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, ENLISTMENT);
    final String mcp = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, MCP);
    final Boolean enlistmentTrace = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, ENLISTMENT_TRACE);
    int maxPoolSize = ModelNodeUtil.getIntIfSetOrGetDefault(context, connDefModel, MAX_POOL_SIZE);
    int minPoolSize = ModelNodeUtil.getIntIfSetOrGetDefault(context, connDefModel, MIN_POOL_SIZE);
    Integer initialPoolSize = ModelNodeUtil.getIntIfSetOrGetDefault(context, connDefModel, INITIAL_POOL_SIZE);
    boolean prefill = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, POOL_PREFILL);
    boolean fair = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, POOL_FAIR);
    boolean useStrictMin = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, POOL_USE_STRICT_MIN);
    String flushStrategyString = POOL_FLUSH_STRATEGY.resolveModelAttribute(context, connDefModel).asString();
    final FlushStrategy flushStrategy = FlushStrategy.forName(flushStrategyString);
    Boolean isSameRM = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, SAME_RM_OVERRIDE);
    boolean interlivng = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, INTERLEAVING);
    boolean padXid = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, PAD_XID);
    boolean wrapXaResource = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, WRAP_XA_RESOURCE);
    boolean noTxSeparatePool = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, NOTXSEPARATEPOOL);
    Integer allocationRetry = ModelNodeUtil.getIntIfSetOrGetDefault(context, connDefModel, ALLOCATION_RETRY);
    Long allocationRetryWaitMillis = ModelNodeUtil.getLongIfSetOrGetDefault(context, connDefModel, ALLOCATION_RETRY_WAIT_MILLIS);
    Long blockingTimeoutMillis = ModelNodeUtil.getLongIfSetOrGetDefault(context, connDefModel, BLOCKING_TIMEOUT_WAIT_MILLIS);
    Long idleTimeoutMinutes = ModelNodeUtil.getLongIfSetOrGetDefault(context, connDefModel, IDLETIMEOUTMINUTES);
    Integer xaResourceTimeout = ModelNodeUtil.getIntIfSetOrGetDefault(context, connDefModel, XA_RESOURCE_TIMEOUT);
    TimeOut timeOut = new TimeOutImpl(blockingTimeoutMillis, idleTimeoutMinutes, allocationRetry, allocationRetryWaitMillis, xaResourceTimeout);
    Extension incrementer = ModelNodeUtil.extractExtension(context, connDefModel, CAPACITY_INCREMENTER_CLASS, CAPACITY_INCREMENTER_PROPERTIES);
    Extension decrementer = ModelNodeUtil.extractExtension(context, connDefModel, CAPACITY_DECREMENTER_CLASS, CAPACITY_DECREMENTER_PROPERTIES);
    final Capacity capacity = new Capacity(incrementer, decrementer);
    Pool pool;
    if (isXa) {
        pool = new XaPoolImpl(minPoolSize, initialPoolSize, maxPoolSize, prefill, useStrictMin, flushStrategy, capacity, fair, isSameRM, interlivng, padXid, wrapXaResource, noTxSeparatePool);
    } else {
        pool = new PoolImpl(minPoolSize, initialPoolSize, maxPoolSize, prefill, useStrictMin, flushStrategy, capacity, fair);
    }
    String securityDomain = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, SECURITY_DOMAIN);
    String securityDomainAndApplication = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, SECURITY_DOMAIN_AND_APPLICATION);
    boolean elytronEnabled = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, ELYTRON_ENABLED);
    String authenticationContext = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, AUTHENTICATION_CONTEXT);
    String authenticationContextAndApplication = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, AUTHENTICATION_CONTEXT_AND_APPLICATION);
    boolean application = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, APPLICATION);
    Security security = null;
    if (securityDomain != null || securityDomainAndApplication != null || application) {
        security = new SecurityImpl(elytronEnabled ? authenticationContext : securityDomain, elytronEnabled ? authenticationContextAndApplication : securityDomainAndApplication, application, elytronEnabled);
    }
    Long backgroundValidationMillis = ModelNodeUtil.getLongIfSetOrGetDefault(context, connDefModel, BACKGROUNDVALIDATIONMILLIS);
    Boolean backgroundValidation = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, BACKGROUNDVALIDATION);
    boolean useFastFail = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, USE_FAST_FAIL);
    final Boolean validateOnMatch = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, VALIDATE_ON_MATCH);
    Validation validation = new ValidationImpl(validateOnMatch, backgroundValidation, backgroundValidationMillis, useFastFail);
    final String recoveryUsername = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, RECOVERY_USERNAME);
    final String recoveryPassword = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, RECOVERY_PASSWORD);
    final String recoverySecurityDomain = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, RECOVERY_SECURITY_DOMAIN);
    final boolean recoveryElytronEnabled = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, RECOVERY_ELYTRON_ENABLED);
    final String recoveryAuthenticationContext = ModelNodeUtil.getResolvedStringIfSetOrGetDefault(context, connDefModel, RECOVERY_AUTHENTICATION_CONTEXT);
    Boolean noRecovery = ModelNodeUtil.getBooleanIfSetOrGetDefault(context, connDefModel, NO_RECOVERY);
    Recovery recovery = null;
    if ((recoveryUsername != null && (recoveryPassword != null || recoveryCredentialSourceSupplier != null)) || recoverySecurityDomain != null || noRecovery != null) {
        Credential credential = null;
        if ((recoveryUsername != null && (recoveryPassword != null || recoveryCredentialSourceSupplier != null)) || recoverySecurityDomain != null)
            credential = new CredentialImpl(recoveryUsername, recoveryPassword, recoveryElytronEnabled ? recoveryAuthenticationContext : recoverySecurityDomain, recoveryElytronEnabled, recoveryCredentialSourceSupplier);
        Extension recoverPlugin = ModelNodeUtil.extractExtension(context, connDefModel, RECOVERLUGIN_CLASSNAME, RECOVERLUGIN_PROPERTIES);
        if (noRecovery == null)
            noRecovery = Boolean.FALSE;
        recovery = new Recovery(credential, recoverPlugin, noRecovery);
    }
    ModifiableConnDef connectionDefinition = new ModifiableConnDef(configProperties, className, jndiName, poolName, enabled, useJavaContext, useCcm, pool, timeOut, validation, security, recovery, sharable, enlistment, connectable, tracking, mcp, enlistmentTrace);
    return connectionDefinition;
}
Also used : Validation(org.jboss.jca.common.api.metadata.common.Validation) Credential(org.jboss.as.connector.metadata.api.common.Credential) HashMap(java.util.HashMap) TimeOut(org.jboss.jca.common.api.metadata.common.TimeOut) XaPoolImpl(org.jboss.jca.common.metadata.common.XaPoolImpl) PoolImpl(org.jboss.jca.common.metadata.common.PoolImpl) WorkManagerSecurity(org.jboss.jca.common.api.metadata.resourceadapter.WorkManagerSecurity) Security(org.jboss.jca.common.api.metadata.common.Security) Recovery(org.jboss.jca.common.api.metadata.common.Recovery) ValidationImpl(org.jboss.jca.common.metadata.common.ValidationImpl) Extension(org.jboss.jca.common.api.metadata.common.Extension) SecurityImpl(org.jboss.as.connector.metadata.common.SecurityImpl) WorkManagerSecurityImpl(org.jboss.as.connector.metadata.resourceadapter.WorkManagerSecurityImpl) CredentialImpl(org.jboss.as.connector.metadata.common.CredentialImpl) Capacity(org.jboss.jca.common.api.metadata.common.Capacity) FlushStrategy(org.jboss.jca.common.api.metadata.common.FlushStrategy) XaPoolImpl(org.jboss.jca.common.metadata.common.XaPoolImpl) Pool(org.jboss.jca.common.api.metadata.common.Pool) TimeOutImpl(org.jboss.jca.common.metadata.common.TimeOutImpl)

Example 2 with Pool

use of org.jboss.jca.common.api.metadata.common.Pool in project wildfly by wildfly.

the class DirectConnectionFactoryActivatorService method start.

@Override
public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException {
    ROOT_LOGGER.debugf("started DirectConnectionFactoryActivatorService %s", context.getController().getName());
    String cfInterface = null;
    try {
        Connector cmd = mdr.getValue().getResourceAdapter(raId);
        ResourceAdapter ra = cmd.getResourceadapter();
        if (ra.getOutboundResourceadapter() != null) {
            for (ConnectionDefinition cd : ra.getOutboundResourceadapter().getConnectionDefinitions()) {
                if (cd.getConnectionFactoryInterface().getValue().equals(interfaceName))
                    cfInterface = cd.getConnectionFactoryInterface().getValue();
            }
        }
        if (cfInterface == null || !cfInterface.equals(interfaceName)) {
            throw ConnectorLogger.ROOT_LOGGER.invalidConnectionFactory(cfInterface, resourceAdapter, jndiName);
        }
        Map<String, String> raConfigProperties = new HashMap<String, String>();
        Map<String, String> mcfConfigProperties = new HashMap<String, String>();
        String securitySetting = null;
        String securitySettingDomain = null;
        boolean elytronEnabled = false;
        if (properties != null) {
            for (Map.Entry<String, String> prop : properties.entrySet()) {
                String key = prop.getKey();
                String value = prop.getValue();
                if (key.equals("ironjacamar.security")) {
                    securitySetting = value;
                } else if (key.equals("ironjacamar.security.elytron") && value.equals("true")) {
                    elytronEnabled = true;
                } else if (key.equals("ironjacamar.security.elytron-authentication-context")) {
                    securitySettingDomain = value;
                    elytronEnabled = true;
                } else if (key.equals("ironjacamar.security.domain")) {
                    securitySettingDomain = value;
                } else {
                    if (key.startsWith("ra.")) {
                        raConfigProperties.put(key.substring(3), value);
                    } else if (key.startsWith("mcf.")) {
                        mcfConfigProperties.put(key.substring(4), value);
                    } else {
                        mcfConfigProperties.put(key, value);
                    }
                }
            }
        }
        String mcfClass = null;
        if (ra.getOutboundResourceadapter() != null) {
            for (ConnectionDefinition cd : ra.getOutboundResourceadapter().getConnectionDefinitions()) {
                if (cd.getConnectionFactoryInterface().getValue().equals(cfInterface))
                    mcfClass = cd.getManagedConnectionFactoryClass().getValue();
            }
        }
        Security security = null;
        if (securitySetting != null) {
            if ("".equals(securitySetting)) {
                security = new SecurityImpl(null, null, false, false);
            } else if ("application".equals(securitySetting)) {
                security = new SecurityImpl(null, null, true, false);
            } else if ("domain".equals(securitySetting) && securitySettingDomain != null) {
                security = new SecurityImpl(securitySettingDomain, null, false, elytronEnabled);
            } else if ("domain-and-application".equals(securitySetting) && securitySettingDomain != null) {
                security = new SecurityImpl(null, securitySettingDomain, false, elytronEnabled);
            }
        }
        if (security == null) {
            SUBSYSTEM_RA_LOGGER.noSecurityDefined(jndiName);
        }
        Pool pool = null;
        Boolean isXA = Boolean.FALSE;
        if (transactionSupport == TransactionSupport.TransactionSupportLevel.XATransaction) {
            pool = new XaPoolImpl(minPoolSize < 0 ? Defaults.MIN_POOL_SIZE : minPoolSize, Defaults.INITIAL_POOL_SIZE, maxPoolSize < 0 ? Defaults.MAX_POOL_SIZE : maxPoolSize, Defaults.PREFILL, Defaults.USE_STRICT_MIN, Defaults.FLUSH_STRATEGY, null, Defaults.FAIR, Defaults.IS_SAME_RM_OVERRIDE, Defaults.INTERLEAVING, Defaults.PAD_XID, Defaults.WRAP_XA_RESOURCE, Defaults.NO_TX_SEPARATE_POOL);
            isXA = Boolean.TRUE;
        } else {
            pool = new PoolImpl(minPoolSize < 0 ? Defaults.MIN_POOL_SIZE : minPoolSize, Defaults.INITIAL_POOL_SIZE, maxPoolSize < 0 ? Defaults.MAX_POOL_SIZE : maxPoolSize, Defaults.PREFILL, Defaults.USE_STRICT_MIN, Defaults.FLUSH_STRATEGY, null, Defaults.FAIR);
        }
        TransactionSupportEnum transactionSupportValue = TransactionSupportEnum.NoTransaction;
        if (transactionSupport == TransactionSupport.TransactionSupportLevel.XATransaction) {
            transactionSupportValue = TransactionSupportEnum.XATransaction;
        } else if (transactionSupport == TransactionSupport.TransactionSupportLevel.LocalTransaction) {
            transactionSupportValue = TransactionSupportEnum.LocalTransaction;
        }
        org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition cd = new org.jboss.jca.common.metadata.resourceadapter.ConnectionDefinitionImpl(mcfConfigProperties, mcfClass, jndiName, poolName(cfInterface), Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Defaults.CONNECTABLE, Defaults.TRACKING, Defaults.MCP, Defaults.ENLISTMENT_TRACE, pool, null, null, security, null, isXA);
        Activation activation = new ActivationImpl(null, null, transactionSupportValue, Collections.singletonList(cd), Collections.<AdminObject>emptyList(), raConfigProperties, Collections.<String>emptyList(), null, null);
        String serviceName = jndiName;
        serviceName = serviceName.replace(':', '_');
        serviceName = serviceName.replace('/', '_');
        ResourceAdapterActivatorService activator = new ResourceAdapterActivatorService(cmd, activation, module.getClassLoader(), serviceName);
        activator.setCreateBinderService(false);
        activator.setBindInfo(bindInfo);
        org.jboss.msc.service.ServiceTarget serviceTarget = context.getChildTarget();
        org.jboss.msc.service.ServiceName activatorServiceName = ConnectorServices.RESOURCE_ADAPTER_ACTIVATOR_SERVICE.append(serviceName);
        org.jboss.msc.service.ServiceBuilder connectionFactoryServiceBuilder = serviceTarget.addService(activatorServiceName, activator).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, activator.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, activator.getRaRepositoryInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, activator.getManagementRepositoryInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE, ResourceAdapterDeploymentRegistry.class, activator.getRegistryInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, activator.getConfigInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, activator.getCcmInjector()).addDependency(NamingService.SERVICE_NAME).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, activator.getTxIntegrationInjector()).addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append("default"));
        if (ActivationSecurityUtil.isLegacySecurityRequired(security)) {
            connectionFactoryServiceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class, activator.getSubjectFactoryInjector()).addDependency(SimpleSecurityManagerService.SERVICE_NAME, ServerSecurityManager.class, activator.getServerSecurityManager());
        }
        connectionFactoryServiceBuilder.setInitialMode(org.jboss.msc.service.ServiceController.Mode.ACTIVE).install();
    } catch (Exception e) {
        throw new org.jboss.msc.service.StartException(e);
    }
}
Also used : Connector(org.jboss.jca.common.api.metadata.spec.Connector) ConnectionDefinition(org.jboss.jca.common.api.metadata.spec.ConnectionDefinition) SubjectFactory(org.jboss.security.SubjectFactory) HashMap(java.util.HashMap) JcaSubsystemConfiguration(org.jboss.as.connector.subsystems.jca.JcaSubsystemConfiguration) Activation(org.jboss.jca.common.api.metadata.resourceadapter.Activation) Security(org.jboss.as.connector.metadata.api.common.Security) XaPoolImpl(org.jboss.jca.common.metadata.common.XaPoolImpl) PoolImpl(org.jboss.jca.common.metadata.common.PoolImpl) SecurityImpl(org.jboss.as.connector.metadata.common.SecurityImpl) ActivationImpl(org.jboss.jca.common.metadata.resourceadapter.ActivationImpl) XaPoolImpl(org.jboss.jca.common.metadata.common.XaPoolImpl) ResourceAdapter(org.jboss.jca.common.api.metadata.spec.ResourceAdapter) Pool(org.jboss.jca.common.api.metadata.common.Pool) AS7MetadataRepository(org.jboss.as.connector.services.mdr.AS7MetadataRepository) ManagementRepository(org.jboss.jca.core.api.management.ManagementRepository) TransactionSupportEnum(org.jboss.jca.common.api.metadata.common.TransactionSupportEnum) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with Pool

use of org.jboss.jca.common.api.metadata.common.Pool in project wildfly by wildfly.

the class PooledConnectionFactoryService method createConnDef.

private static ConnectionDefinition createConnDef(TransactionSupportEnum transactionSupport, String jndiName, int minPoolSize, int maxPoolSize, String managedConnectionPoolClassName, Boolean enlistmentTrace) throws ValidateException {
    Integer minSize = (minPoolSize == -1) ? null : minPoolSize;
    Integer maxSize = (maxPoolSize == -1) ? null : maxPoolSize;
    boolean prefill = false;
    boolean useStrictMin = false;
    FlushStrategy flushStrategy = FlushStrategy.FAILING_CONNECTION_ONLY;
    Boolean isXA = Boolean.FALSE;
    final Pool pool;
    if (transactionSupport == TransactionSupportEnum.XATransaction) {
        pool = new XaPoolImpl(minSize, Defaults.INITIAL_POOL_SIZE, maxSize, prefill, useStrictMin, flushStrategy, null, Defaults.FAIR, Defaults.IS_SAME_RM_OVERRIDE, Defaults.INTERLEAVING, Defaults.PAD_XID, Defaults.WRAP_XA_RESOURCE, Defaults.NO_TX_SEPARATE_POOL);
        isXA = Boolean.TRUE;
    } else {
        pool = new PoolImpl(minSize, Defaults.INITIAL_POOL_SIZE, maxSize, prefill, useStrictMin, flushStrategy, null, Defaults.FAIR);
    }
    TimeOut timeOut = new TimeOutImpl(null, null, null, null, null) {
    };
    // <security>
    //   <application />
    // </security>
    // => PoolStrategy.POOL_BY_CRI
    Security security = new SecurityImpl(null, null, true, false);
    // register the XA Connection *without* recovery. ActiveMQ already takes care of the registration with the correct credentials
    // when its ResourceAdapter is started
    Recovery recovery = new Recovery(new CredentialImpl(null, null, null, false, null), null, Boolean.TRUE);
    Validation validation = new ValidationImpl(Defaults.VALIDATE_ON_MATCH, null, null, false);
    // do no track
    return new ConnectionDefinitionImpl(Collections.<String, String>emptyMap(), RAMANAGED_CONN_FACTORY, jndiName, ACTIVEMQ_CONN_DEF, true, true, true, Defaults.SHARABLE, Defaults.ENLISTMENT, Defaults.CONNECTABLE, false, managedConnectionPoolClassName, enlistmentTrace, pool, timeOut, validation, security, recovery, isXA);
}
Also used : Validation(org.jboss.jca.common.api.metadata.common.Validation) TimeOut(org.jboss.jca.common.api.metadata.common.TimeOut) XaPoolImpl(org.jboss.jca.common.metadata.common.XaPoolImpl) PoolImpl(org.jboss.jca.common.metadata.common.PoolImpl) Security(org.jboss.jca.common.api.metadata.common.Security) Recovery(org.jboss.jca.common.api.metadata.common.Recovery) ValidationImpl(org.jboss.jca.common.metadata.common.ValidationImpl) SecurityImpl(org.jboss.as.connector.metadata.common.SecurityImpl) CredentialImpl(org.jboss.as.connector.metadata.common.CredentialImpl) FlushStrategy(org.jboss.jca.common.api.metadata.common.FlushStrategy) ConnectionDefinitionImpl(org.jboss.jca.common.metadata.resourceadapter.ConnectionDefinitionImpl) XaPoolImpl(org.jboss.jca.common.metadata.common.XaPoolImpl) Pool(org.jboss.jca.common.api.metadata.common.Pool) TimeOutImpl(org.jboss.jca.common.metadata.common.TimeOutImpl)

Example 4 with Pool

use of org.jboss.jca.common.api.metadata.common.Pool in project wildfly by wildfly.

the class XMLDataSourceRuntimeHandler method handleDatasourceAttribute.

private void handleDatasourceAttribute(final String attributeName, final OperationContext context, final DataSource dataSource) {
    if (attributeName.equals(Constants.CONNECTION_URL.getName())) {
        setStringIfNotNull(context, dataSource.getConnectionUrl());
    } else if (attributeName.equals(Constants.CONNECTION_PROPERTIES.getName())) {
        final Map<String, String> propertiesMap = dataSource.getConnectionProperties();
        if (propertiesMap == null) {
            return;
        }
        for (final Map.Entry<String, String> entry : propertiesMap.entrySet()) {
            context.getResult().asPropertyList().add(new ModelNode().set(entry.getKey(), entry.getValue()).asProperty());
        }
    } else if (attributeName.equals(Constants.DRIVER_CLASS.getName())) {
        setStringIfNotNull(context, dataSource.getDriverClass());
    } else if (attributeName.equals(Constants.DATASOURCE_CLASS.getName())) {
        setStringIfNotNull(context, dataSource.getDataSourceClass());
    } else if (attributeName.equals(Constants.JNDI_NAME.getName())) {
        setStringIfNotNull(context, dataSource.getJndiName());
    } else if (attributeName.equals(Constants.DATASOURCE_DRIVER.getName())) {
        setStringIfNotNull(context, dataSource.getDriver());
    } else if (attributeName.equals(Constants.NEW_CONNECTION_SQL.getName())) {
        setStringIfNotNull(context, dataSource.getNewConnectionSql());
    } else if (attributeName.equals(Constants.URL_DELIMITER.getName())) {
        setStringIfNotNull(context, dataSource.getUrlDelimiter());
    } else if (attributeName.equals(Constants.URL_SELECTOR_STRATEGY_CLASS_NAME.getName())) {
        setStringIfNotNull(context, dataSource.getUrlSelectorStrategyClassName());
    } else if (attributeName.equals(Constants.USE_JAVA_CONTEXT.getName())) {
        setBooleanIfNotNull(context, dataSource.isUseJavaContext());
    } else if (attributeName.equals(Constants.JTA.getName())) {
        setBooleanIfNotNull(context, dataSource.isJTA());
    } else if (attributeName.equals(Constants.ENABLED.getName())) {
        setBooleanIfNotNull(context, dataSource.isEnabled());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.MAX_POOL_SIZE.getName())) {
        if (dataSource.getPool() == null) {
            return;
        }
        setIntIfNotNull(context, dataSource.getPool().getMaxPoolSize());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE.getName())) {
        if (dataSource.getPool() == null) {
            return;
        }
        setIntIfNotNull(context, dataSource.getPool().getInitialPoolSize());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.MIN_POOL_SIZE.getName())) {
        if (dataSource.getPool() == null) {
            return;
        }
        setIntIfNotNull(context, dataSource.getPool().getMinPoolSize());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.POOL_PREFILL.getName())) {
        if (dataSource.getPool() == null) {
            return;
        }
        setBooleanIfNotNull(context, dataSource.getPool().isPrefill());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.POOL_FAIR.getName())) {
        if (dataSource.getPool() == null) {
            return;
        }
        setBooleanIfNotNull(context, dataSource.getPool().isFair());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.POOL_USE_STRICT_MIN.getName())) {
        if (dataSource.getPool() == null) {
            return;
        }
        setBooleanIfNotNull(context, dataSource.getPool().isUseStrictMin());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS.getName())) {
        if (dataSource.getPool() == null || dataSource.getPool().getCapacity() == null || dataSource.getPool().getCapacity().getIncrementer() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getPool().getCapacity().getIncrementer().getClassName());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS.getName())) {
        if (dataSource.getPool() == null || dataSource.getPool().getCapacity() == null || dataSource.getPool().getCapacity().getDecrementer() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getPool().getCapacity().getDecrementer().getClassName());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES.getName())) {
        Pool pool = dataSource.getPool();
        if (pool == null || ((DsPool) pool).getCapacity() == null || ((DsPool) pool).getCapacity().getIncrementer() == null)
            return;
        final Map<String, String> propertiesMap = ((DsPool) pool).getCapacity().getIncrementer().getConfigPropertiesMap();
        if (propertiesMap == null) {
            return;
        }
        for (final Map.Entry<String, String> entry : propertiesMap.entrySet()) {
            context.getResult().asPropertyList().add(new ModelNode().set(entry.getKey(), entry.getValue()).asProperty());
        }
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES.getName())) {
        Pool pool = dataSource.getPool();
        if (pool == null || ((DsPool) pool).getCapacity() == null || ((DsPool) pool).getCapacity().getDecrementer() == null)
            return;
        final Map<String, String> propertiesMap = ((DsPool) pool).getCapacity().getDecrementer().getConfigPropertiesMap();
        if (propertiesMap == null) {
            return;
        }
        for (final Map.Entry<String, String> entry : propertiesMap.entrySet()) {
            context.getResult().asPropertyList().add(new ModelNode().set(entry.getKey(), entry.getValue()).asProperty());
        }
    } else if (attributeName.equals(Constants.USERNAME.getName())) {
        if (dataSource.getSecurity() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getSecurity().getUserName());
    } else if (attributeName.equals(Constants.PASSWORD.getName())) {
    //don't give out the password
    } else if (attributeName.equals(Constants.CREDENTIAL_REFERENCE.getName())) {
    //don't give out the credential-reference
    } else if (attributeName.equals(Constants.SECURITY_DOMAIN.getName())) {
        if (dataSource.getSecurity() == null) {
            return;
        }
        if (((DsSecurity) dataSource.getSecurity()).isElytronEnabled()) {
            return;
        }
        setStringIfNotNull(context, dataSource.getSecurity().getSecurityDomain());
    } else if (attributeName.equals(Constants.ELYTRON_ENABLED.getName())) {
        if (dataSource.getSecurity() == null) {
            return;
        }
        if (!((DsSecurity) dataSource.getSecurity()).isElytronEnabled()) {
            return;
        }
        setBooleanIfNotNull(context, ((DsSecurity) dataSource.getSecurity()).isElytronEnabled());
    } else if (attributeName.equals(Constants.AUTHENTICATION_CONTEXT.getName())) {
        if (dataSource.getSecurity() == null) {
            return;
        }
        if (!((DsSecurity) dataSource.getSecurity()).isElytronEnabled()) {
            return;
        }
        setStringIfNotNull(context, dataSource.getSecurity().getSecurityDomain());
    } else if (attributeName.equals(Constants.REAUTH_PLUGIN_CLASSNAME.getName())) {
        if (dataSource.getSecurity() == null) {
            return;
        }
        if (dataSource.getSecurity().getReauthPlugin() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getSecurity().getReauthPlugin().getClassName());
    } else if (attributeName.equals(Constants.REAUTHPLUGIN_PROPERTIES.getName())) {
        if (dataSource.getSecurity() == null) {
            return;
        }
        if (dataSource.getSecurity().getReauthPlugin() == null) {
            return;
        }
        final Map<String, String> propertiesMap = dataSource.getSecurity().getReauthPlugin().getConfigPropertiesMap();
        if (propertiesMap == null) {
            return;
        }
        for (final Map.Entry<String, String> entry : propertiesMap.entrySet()) {
            context.getResult().asPropertyList().add(new ModelNode().set(entry.getKey(), entry.getValue()).asProperty());
        }
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.POOL_FLUSH_STRATEGY.getName())) {
        if (dataSource.getPool() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getPool().getFlushStrategy().getName());
    } else if (attributeName.equals(Constants.PREPARED_STATEMENTS_CACHE_SIZE.getName())) {
        if (dataSource.getStatement() == null) {
            return;
        }
        setLongIfNotNull(context, dataSource.getStatement().getPreparedStatementsCacheSize());
    } else if (attributeName.equals(Constants.SHARE_PREPARED_STATEMENTS.getName())) {
        if (dataSource.getStatement() == null) {
            return;
        }
        setBooleanIfNotNull(context, dataSource.getStatement().isSharePreparedStatements());
    } else if (attributeName.equals(Constants.TRACK_STATEMENTS.getName())) {
        if (dataSource.getStatement() == null) {
            return;
        }
        if (dataSource.getStatement().getTrackStatements() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getStatement().getTrackStatements().name());
    } else if (attributeName.equals(Constants.ALLOCATION_RETRY.getName())) {
        if (dataSource.getTimeOut() == null) {
            return;
        }
        setIntIfNotNull(context, dataSource.getTimeOut().getAllocationRetry());
    } else if (attributeName.equals(Constants.ALLOCATION_RETRY_WAIT_MILLIS.getName())) {
        if (dataSource.getTimeOut() == null) {
            return;
        }
        setLongIfNotNull(context, dataSource.getTimeOut().getAllocationRetryWaitMillis());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.BLOCKING_TIMEOUT_WAIT_MILLIS.getName())) {
        if (dataSource.getTimeOut() == null) {
            return;
        }
        setLongIfNotNull(context, dataSource.getTimeOut().getBlockingTimeoutMillis());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.IDLETIMEOUTMINUTES.getName())) {
        if (dataSource.getTimeOut() == null) {
            return;
        }
        setLongIfNotNull(context, dataSource.getTimeOut().getIdleTimeoutMinutes());
    } else if (attributeName.equals(Constants.QUERY_TIMEOUT.getName())) {
        if (dataSource.getTimeOut() == null) {
            return;
        }
        setLongIfNotNull(context, dataSource.getTimeOut().getQueryTimeout());
    } else if (attributeName.equals(Constants.USE_TRY_LOCK.getName())) {
        if (dataSource.getTimeOut() == null) {
            return;
        }
        setLongIfNotNull(context, dataSource.getTimeOut().getUseTryLock());
    } else if (attributeName.equals(Constants.SET_TX_QUERY_TIMEOUT.getName())) {
        if (dataSource.getTimeOut() == null) {
            return;
        }
        setBooleanIfNotNull(context, dataSource.getTimeOut().isSetTxQueryTimeout());
    } else if (attributeName.equals(Constants.TRANSACTION_ISOLATION.getName())) {
        if (dataSource.getTransactionIsolation() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getTransactionIsolation().name());
    } else if (attributeName.equals(Constants.CHECK_VALID_CONNECTION_SQL.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getValidation().getCheckValidConnectionSql());
    } else if (attributeName.equals(Constants.EXCEPTION_SORTER_CLASSNAME.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        if (dataSource.getValidation().getExceptionSorter() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getValidation().getExceptionSorter().getClassName());
    } else if (attributeName.equals(Constants.EXCEPTION_SORTER_PROPERTIES.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        if (dataSource.getValidation().getExceptionSorter() == null) {
            return;
        }
        final Map<String, String> propertiesMap = dataSource.getValidation().getExceptionSorter().getConfigPropertiesMap();
        if (propertiesMap == null) {
            return;
        }
        for (final Map.Entry<String, String> entry : propertiesMap.entrySet()) {
            context.getResult().asPropertyList().add(new ModelNode().set(entry.getKey(), entry.getValue()).asProperty());
        }
    } else if (attributeName.equals(Constants.STALE_CONNECTION_CHECKER_CLASSNAME.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        if (dataSource.getValidation().getStaleConnectionChecker() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getValidation().getStaleConnectionChecker().getClassName());
    } else if (attributeName.equals(Constants.STALE_CONNECTION_CHECKER_PROPERTIES.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        if (dataSource.getValidation().getStaleConnectionChecker() == null) {
            return;
        }
        final Map<String, String> propertiesMap = dataSource.getValidation().getStaleConnectionChecker().getConfigPropertiesMap();
        if (propertiesMap == null) {
            return;
        }
        for (final Map.Entry<String, String> entry : propertiesMap.entrySet()) {
            context.getResult().asPropertyList().add(new ModelNode().set(entry.getKey(), entry.getValue()).asProperty());
        }
    } else if (attributeName.equals(Constants.VALID_CONNECTION_CHECKER_CLASSNAME.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        if (dataSource.getValidation().getValidConnectionChecker() == null) {
            return;
        }
        setStringIfNotNull(context, dataSource.getValidation().getValidConnectionChecker().getClassName());
    } else if (attributeName.equals(Constants.VALID_CONNECTION_CHECKER_PROPERTIES.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        if (dataSource.getValidation().getValidConnectionChecker() == null) {
            return;
        }
        final Map<String, String> propertiesMap = dataSource.getValidation().getValidConnectionChecker().getConfigPropertiesMap();
        if (propertiesMap == null) {
            return;
        }
        for (final Map.Entry<String, String> entry : propertiesMap.entrySet()) {
            context.getResult().asPropertyList().add(new ModelNode().set(entry.getKey(), entry.getValue()).asProperty());
        }
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.BACKGROUNDVALIDATIONMILLIS.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        setLongIfNotNull(context, dataSource.getValidation().getBackgroundValidationMillis());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.BACKGROUNDVALIDATION.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        setBooleanIfNotNull(context, dataSource.getValidation().isBackgroundValidation());
    } else if (attributeName.equals(org.jboss.as.connector.subsystems.common.pool.Constants.USE_FAST_FAIL.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        setBooleanIfNotNull(context, dataSource.getValidation().isUseFastFail());
    } else if (attributeName.equals(Constants.VALIDATE_ON_MATCH.getName())) {
        if (dataSource.getValidation() == null) {
            return;
        }
        setBooleanIfNotNull(context, dataSource.getValidation().isValidateOnMatch());
    } else if (attributeName.equals(Constants.SPY.getName())) {
        setBooleanIfNotNull(context, dataSource.isSpy());
    } else if (attributeName.equals(Constants.USE_CCM.getName())) {
        setBooleanIfNotNull(context, dataSource.isUseCcm());
    } else if (attributeName.equals(Constants.ALLOW_MULTIPLE_USERS.getName())) {
        Pool pool = dataSource.getPool();
        if (!(pool instanceof DsPool)) {
            return;
        }
        setBooleanIfNotNull(context, ((DsPool) pool).isAllowMultipleUsers());
    } else if (attributeName.equals(Constants.CONNECTION_LISTENER_CLASS.getName())) {
        Pool pool = dataSource.getPool();
        if (!(pool instanceof DsPool) || ((DsPool) pool).getConnectionListener() == null) {
            return;
        }
        setStringIfNotNull(context, ((DsPool) pool).getConnectionListener().getClassName());
    } else if (attributeName.equals(Constants.CONNECTION_LISTENER_PROPERTIES.getName())) {
        Pool pool = dataSource.getPool();
        if (!(pool instanceof DsPool) || ((DsPool) pool).getConnectionListener() == null) {
            return;
        }
        final Map<String, String> propertiesMap = ((DsPool) pool).getConnectionListener().getConfigPropertiesMap();
        if (propertiesMap == null) {
            return;
        }
        for (final Map.Entry<String, String> entry : propertiesMap.entrySet()) {
            context.getResult().asPropertyList().add(new ModelNode().set(entry.getKey(), entry.getValue()).asProperty());
        }
    } else if (attributeName.equals(Constants.CONNECTABLE.getName())) {
        //Just set to false
        context.getResult().set(false);
    } else if (attributeName.equals(Constants.STATISTICS_ENABLED.getName())) {
        //Just set to false
        context.getResult().set(false);
    } else if (attributeName.equals(Constants.TRACKING.getName())) {
        //Just return w/o setting a result
        return;
    } else if (attributeName.equals(Constants.MCP.getName())) {
        //Just return w/o setting a result
        return;
    } else if (attributeName.equals(Constants.ENLISTMENT_TRACE.getName())) {
        //Just return w/o setting a result
        return;
    } else {
        throw ConnectorLogger.ROOT_LOGGER.unknownAttribute(attributeName);
    }
}
Also used : DsSecurity(org.jboss.as.connector.metadata.api.ds.DsSecurity) Pool(org.jboss.jca.common.api.metadata.common.Pool) DsPool(org.jboss.jca.common.api.metadata.ds.DsPool) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map) DsPool(org.jboss.jca.common.api.metadata.ds.DsPool)

Example 5 with Pool

use of org.jboss.jca.common.api.metadata.common.Pool 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)

Aggregations

Pool (org.jboss.jca.common.api.metadata.common.Pool)5 Map (java.util.Map)3 SecurityImpl (org.jboss.as.connector.metadata.common.SecurityImpl)3 Recovery (org.jboss.jca.common.api.metadata.common.Recovery)3 TimeOut (org.jboss.jca.common.api.metadata.common.TimeOut)3 Validation (org.jboss.jca.common.api.metadata.common.Validation)3 PoolImpl (org.jboss.jca.common.metadata.common.PoolImpl)3 XaPoolImpl (org.jboss.jca.common.metadata.common.XaPoolImpl)3 HashMap (java.util.HashMap)2 Credential (org.jboss.as.connector.metadata.api.common.Credential)2 Security (org.jboss.as.connector.metadata.api.common.Security)2 CredentialImpl (org.jboss.as.connector.metadata.common.CredentialImpl)2 ModelNode (org.jboss.dmr.ModelNode)2 Extension (org.jboss.jca.common.api.metadata.common.Extension)2 FlushStrategy (org.jboss.jca.common.api.metadata.common.FlushStrategy)2 Security (org.jboss.jca.common.api.metadata.common.Security)2 TimeOutImpl (org.jboss.jca.common.metadata.common.TimeOutImpl)2 ValidationImpl (org.jboss.jca.common.metadata.common.ValidationImpl)2 DsSecurity (org.jboss.as.connector.metadata.api.ds.DsSecurity)1 WorkManagerSecurity (org.jboss.as.connector.metadata.api.resourceadapter.WorkManagerSecurity)1