Search in sources :

Example 26 with JdbcConnectionPool

use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.

the class JdbcConnectionPoolDeployer method deployResource.

/**
 * {@inheritDoc}
 */
@Override
public void deployResource(Object resource) throws Exception {
    JdbcConnectionPool jcp = (JdbcConnectionPool) resource;
    PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(jcp);
    actualDeployResource(resource, poolInfo);
}
Also used : JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 27 with JdbcConnectionPool

use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.

the class JDBCConnectionPoolManager method createConfigBean.

private JdbcConnectionPool createConfigBean(Resources param, Properties properties) throws PropertyVetoException, TransactionFailure {
    JdbcConnectionPool newResource = param.createChild(JdbcConnectionPool.class);
    newResource.setWrapJdbcObjects(wrapJDBCObjects);
    if (validationtable != null)
        newResource.setValidationTableName(validationtable);
    newResource.setValidateAtmostOncePeriodInSeconds(validateAtmostOncePeriod);
    if (isolationlevel != null) {
        newResource.setTransactionIsolationLevel(isolationlevel);
    }
    newResource.setSteadyPoolSize(steadypoolsize);
    if (statementTimeout != null) {
        newResource.setStatementTimeoutInSeconds(statementTimeout);
    }
    if (restype != null) {
        newResource.setResType(restype);
    }
    newResource.setPoolResizeQuantity(poolresize);
    newResource.setNonTransactionalConnections(nontransactionalconnections);
    newResource.setMaxWaitTimeInMillis(maxwait);
    newResource.setMaxPoolSize(maxpoolsize);
    if (maxConnectionUsageCount != null) {
        newResource.setMaxConnectionUsageCount(maxConnectionUsageCount);
    }
    if (matchConnections != null) {
        newResource.setMatchConnections(matchConnections);
    }
    if (lazyConnectionEnlistment != null) {
        newResource.setLazyConnectionEnlistment(lazyConnectionEnlistment);
    }
    if (lazyConnectionAssociation != null) {
        newResource.setLazyConnectionAssociation(lazyConnectionAssociation);
    }
    newResource.setIsIsolationLevelGuaranteed(isisolationguaranteed);
    newResource.setIsConnectionValidationRequired(isconnectvalidatereq);
    newResource.setIdleTimeoutInSeconds(idletimeout);
    newResource.setFailAllConnections(failconnection);
    if (datasourceclassname != null) {
        newResource.setDatasourceClassname(datasourceclassname);
    }
    newResource.setConnectionValidationMethod(validationmethod);
    if (connectionLeakTimeout != null) {
        newResource.setConnectionLeakTimeoutInSeconds(connectionLeakTimeout);
    }
    if (connectionLeakReclaim != null) {
        newResource.setConnectionLeakReclaim(connectionLeakReclaim);
    }
    if (connectionCreationRetryInterval != null) {
        newResource.setConnectionCreationRetryIntervalInSeconds(connectionCreationRetryInterval);
    }
    if (connectionCreationRetryAttempts != null) {
        newResource.setConnectionCreationRetryAttempts(connectionCreationRetryAttempts);
    }
    if (associateWithThread != null) {
        newResource.setAssociateWithThread(associateWithThread);
    }
    if (allownoncomponentcallers != null) {
        newResource.setAllowNonComponentCallers(allownoncomponentcallers);
    }
    if (statementcachesize != null) {
        newResource.setStatementCacheSize(statementcachesize);
    }
    if (validationclassname != null) {
        newResource.setValidationClassname(validationclassname);
    }
    if (initsql != null) {
        newResource.setInitSql(initsql);
    }
    if (sqltracelisteners != null) {
        newResource.setSqlTraceListeners(sqltracelisteners);
    }
    if (pooling != null) {
        newResource.setPooling(pooling);
    }
    if (ping != null) {
        newResource.setPing(ping);
    }
    if (logJDBCCalls != null) {
        newResource.setLogJdbcCalls(logJDBCCalls);
    }
    if (driverclassname != null) {
        newResource.setDriverClassname(driverclassname);
    }
    if (description != null) {
        newResource.setDescription(description);
    }
    newResource.setName(jdbcconnectionpoolid);
    if (properties != null) {
        for (Map.Entry e : properties.entrySet()) {
            Property prop = newResource.createChild(Property.class);
            prop.setName((String) e.getKey());
            prop.setValue((String) e.getValue());
            newResource.getProperty().add(prop);
        }
    }
    return newResource;
}
Also used : JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.jvnet.hk2.config.types.Property)

Example 28 with JdbcConnectionPool

use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.

the class ListJdbcConnectionPools method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    try {
        Collection<JdbcConnectionPool> connPools = domain.getResources().getResources(JdbcConnectionPool.class);
        for (JdbcConnectionPool pool : connPools) {
            final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
            part.setMessage(pool.getName());
        }
    } catch (Exception e) {
        report.setMessage(localStrings.getLocalString("list.jdbc.connection.pools.failed", "List JDBC connection pools failed"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) ActionReport(org.glassfish.api.ActionReport)

Example 29 with JdbcConnectionPool

use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.

the class ManagedConnectionImpl method getJdbcConnectionPool.

private static JdbcConnectionPool getJdbcConnectionPool(javax.resource.spi.ManagedConnectionFactory mcf) {
    if (Globals.getDefaultHabitat().getService(ProcessEnvironment.class).getProcessType() != ProcessEnvironment.ProcessType.Server) {
        // otherwise we bave no domain to draw upon
        return null;
    }
    ManagedConnectionFactoryImpl spiMCF = (ManagedConnectionFactoryImpl) mcf;
    Resources resources = Globals.getDefaultHabitat().getService(Domain.class).getResources();
    ResourcePool pool = (ResourcePool) ConnectorsUtil.getResourceByName(resources, ResourcePool.class, spiMCF.getPoolName());
    if (pool instanceof JdbcConnectionPool) {
        return (JdbcConnectionPool) pool;
    }
    return null;
}
Also used : JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) Resources(com.sun.enterprise.config.serverbeans.Resources) Domain(com.sun.enterprise.config.serverbeans.Domain)

Example 30 with JdbcConnectionPool

use of org.glassfish.jdbc.config.JdbcConnectionPool in project Payara by payara.

the class JdbcConnectionPoolValidatorTest method uninitialized.

@Test
public void uninitialized() {
    final JdbcConnectionPool pool = createMock();
    assertTrue("everything OK", this.validator.isValid(pool, null));
}
Also used : JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) Test(org.junit.Test)

Aggregations

JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)32 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)10 JdbcResource (org.glassfish.jdbc.config.JdbcResource)7 Test (org.junit.Test)7 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)5 Resources (com.sun.enterprise.config.serverbeans.Resources)4 Resource (com.sun.enterprise.config.serverbeans.Resource)3 ActionReport (org.glassfish.api.ActionReport)3 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)3 Domain (com.sun.enterprise.config.serverbeans.Domain)2 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)2 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)2 DataSourceDefinitionDescriptor (com.sun.enterprise.deployment.DataSourceDefinitionDescriptor)2 ArrayList (java.util.ArrayList)2 ConnectionPoolDataSource (javax.sql.ConnectionPoolDataSource)2 DataSource (javax.sql.DataSource)2 XADataSource (javax.sql.XADataSource)2 ConnectorConnectionPool (org.glassfish.connectors.config.ConnectorConnectionPool)2 ResourceConflictException (org.glassfish.resourcebase.resources.api.ResourceConflictException)2 Property (org.jvnet.hk2.config.types.Property)2