Search in sources :

Example 11 with ConnectorConnectionPool

use of com.sun.enterprise.connectors.ConnectorConnectionPool in project Payara by payara.

the class JdbcConnectionPoolDeployer method createConnectorConnectionPool.

public ConnectorConnectionPool createConnectorConnectionPool(JdbcConnectionPool adminPool, PoolInfo poolInfo) throws ConnectorRuntimeException {
    String moduleName = JdbcResourcesUtil.createInstance().getRANameofJdbcConnectionPool(adminPool);
    int txSupport = getTxSupport(moduleName);
    ConnectorDescriptor connDesc = runtime.getConnectorDescriptor(moduleName);
    // Create the connector Connection Pool object from the configbean object
    ConnectorConnectionPool conConnPool = new ConnectorConnectionPool(poolInfo);
    conConnPool.setTransactionSupport(txSupport);
    setConnectorConnectionPoolAttributes(conConnPool, adminPool);
    // Initially create the ConnectorDescriptor
    ConnectorDescriptorInfo connDescInfo = createConnectorDescriptorInfo(connDesc, moduleName);
    connDescInfo.setMCFConfigProperties(getMCFConfigProperties(adminPool, conConnPool, connDesc));
    // since we are deploying a 1.0 RAR, this is null
    connDescInfo.setResourceAdapterConfigProperties((Set) null);
    conConnPool.setConnectorDescriptorInfo(connDescInfo);
    return conConnPool;
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) ConnectorDescriptorInfo(com.sun.enterprise.connectors.ConnectorDescriptorInfo)

Example 12 with ConnectorConnectionPool

use of com.sun.enterprise.connectors.ConnectorConnectionPool in project Payara by payara.

the class JdbcConnectionPoolDeployer method redeployResource.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void redeployResource(Object resource) throws Exception {
    final JdbcConnectionPool adminPool = (JdbcConnectionPool) resource;
    PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(adminPool);
    if (!runtime.isConnectorConnectionPoolDeployed(poolInfo)) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("The JDBC connection pool " + poolInfo + " is not referred or not yet created in this server " + "instance and hence pool redeployment is ignored");
        }
        return;
    }
    final ConnectorConnectionPool connConnPool = createConnectorConnectionPool(adminPool, poolInfo);
    if (connConnPool == null) {
        throw new ConnectorRuntimeException("Unable to create ConnectorConnectionPool" + "from JDBC connection pool");
    }
    // now do internal book keeping
    HashSet excludes = new HashSet();
    // add MCF config props to the set that need to be excluded
    // in checking for the equality of the props with old pool
    excludes.add("TransactionIsolation");
    excludes.add("GuaranteeIsolationLevel");
    excludes.add("ValidationTableName");
    excludes.add("ConnectionValidationRequired");
    excludes.add("ValidationMethod");
    excludes.add("StatementWrapping");
    excludes.add("StatementTimeout");
    excludes.add("ValidationClassName");
    excludes.add("StatementCacheSize");
    excludes.add("StatementCacheType");
    excludes.add("StatementLeakTimeoutInSeconds");
    excludes.add("StatementLeakReclaim");
    try {
        if (_logger.isLoggable(Level.FINEST)) {
            _logger.finest("Calling reconfigure pool");
        }
        boolean requirePoolRecreation = runtime.reconfigureConnectorConnectionPool(connConnPool, excludes);
        if (requirePoolRecreation) {
            if (runtime.isServer() || runtime.isEmbedded()) {
                handlePoolRecreation(connConnPool);
            } else {
                recreatePool(connConnPool);
            }
        }
    } catch (ConnectorRuntimeException cre) {
        Object[] params = new Object[] { poolInfo, cre };
        _logger.log(Level.WARNING, "error.redeploying.jdbc.pool", params);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) HashSet(java.util.HashSet)

Example 13 with ConnectorConnectionPool

use of com.sun.enterprise.connectors.ConnectorConnectionPool in project Payara by payara.

the class JdbcAdminServiceImpl method getDefaultDatabaseName.

/**
 * Returns a databaseName that is populated in pool's default DATABASENAME
 * @param poolInfo
 * @param mcf
 * @return
 * @throws javax.naming.NamingException if poolName lookup fails
 */
private String getDefaultDatabaseName(PoolInfo poolInfo, ManagedConnectionFactory mcf) throws NamingException {
    // All this to get the default user name and principal
    String databaseName = null;
    ConnectorConnectionPool connectorConnectionPool = null;
    try {
        String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
        connectorConnectionPool = (ConnectorConnectionPool) _runtime.getResourceNamingService().lookup(poolInfo, jndiNameForPool, null);
    } catch (NamingException ne) {
        throw ne;
    }
    databaseName = ccPoolAdmService.getPropertyValue("DATABASENAME", connectorConnectionPool);
    // the databasename from MCF.
    if (databaseName == null || databaseName.trim().equals("")) {
        databaseName = ConnectionPoolObjectsUtils.getValueFromMCF("DatabaseName", poolInfo, mcf);
    }
    return databaseName;
}
Also used : ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) NamingException(javax.naming.NamingException)

Aggregations

ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)13 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)7 NamingException (javax.naming.NamingException)4 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)4 ConnectorDescriptorInfo (com.sun.enterprise.connectors.ConnectorDescriptorInfo)3 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)3 SecurityMap (org.glassfish.connectors.config.SecurityMap)2 JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)2 Property (org.jvnet.hk2.config.types.Property)2 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)1 ConnectorNamingEvent (com.sun.appserv.connectors.internal.spi.ConnectorNamingEvent)1 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)1 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)1 ResourceAdapter (com.sun.enterprise.deployment.runtime.connector.ResourceAdapter)1 SunConnector (com.sun.enterprise.deployment.runtime.connector.SunConnector)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 MissingResourceException (java.util.MissingResourceException)1 Set (java.util.Set)1 Context (javax.naming.Context)1