Search in sources :

Example 26 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class ActiveResourceAdapterImpl method createSunRAConnectionPool.

/**
 * Creates connector connection pool pertaining to sun-ra.xml. This is
 * only for 1.0 complient rars.
 *
 * @throws ConnectorRuntimeException Thrown when pool creation fails.
 */
private void createSunRAConnectionPool() throws ConnectorRuntimeException {
    String defaultPoolName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefs_[0].getConnectionFactoryIntf());
    String sunRAPoolName = defaultPoolName + ConnectorConstants.SUN_RA_POOL;
    PoolInfo poolInfo = new PoolInfo(sunRAPoolName);
    ConnectorDescriptorInfo connectorDescriptorInfo = ConnectorDDTransformUtils.getConnectorDescriptorInfo(connectionDefs_[0]);
    connectorDescriptorInfo.setRarName(moduleName_);
    connectorDescriptorInfo.setResourceAdapterClassName(desc_.getResourceAdapterClass());
    ConnectorConnectionPool connectorPoolObj = ConnectionPoolObjectsUtils.createSunRaConnectorPoolObject(poolInfo, desc_, moduleName_);
    connectorPoolObj.setConnectorDescriptorInfo(connectorDescriptorInfo);
    connectorRuntime_.createConnectorConnectionPool(connectorPoolObj);
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Created SUN-RA connection pool:", poolInfo);
    }
    String jndiName = (String) desc_.getSunDescriptor().getResourceAdapter().getValue(ResourceAdapter.JNDI_NAME);
    ResourceInfo resourceInfo = new ResourceInfo(jndiName);
    connectorRuntime_.createConnectorResource(resourceInfo, poolInfo, null);
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Created SUN-RA connector resource : ", resourceInfo);
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 27 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class ActiveResourceAdapterImpl method createDefaultConnectorResources.

/**
 * Creates default connector resource
 *
 * @throws ConnectorRuntimeException when unable to create connector resources
 */
protected void createDefaultConnectorResources() throws ConnectorRuntimeException {
    for (ConnectionDefDescriptor descriptor : connectionDefs_) {
        String connectionDefName = descriptor.getConnectionFactoryIntf();
        String resourceName = connectorRuntime_.getDefaultResourceName(moduleName_, connectionDefName);
        String poolName = connectorRuntime_.getDefaultPoolName(moduleName_, connectionDefName);
        PoolInfo poolInfo = new PoolInfo(poolName);
        ResourceInfo resourceInfo = new ResourceInfo(resourceName);
        connectorRuntime_.createConnectorResource(resourceInfo, poolInfo, null);
        desc_.addDefaultResourceName(resourceName);
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Created default connector resource [ " + resourceName + " ] ");
        }
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectionDefDescriptor(com.sun.enterprise.deployment.ConnectionDefDescriptor) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 28 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class ConnectorResourceAdminServiceImpl method createConnectorResource.

/**
 * Creates the connector resource on a given connection pool
 *
 * @param resourceInfo     JNDI name of the resource to be created
 * @param poolInfo     PoolName to which the connector resource belongs.
 * @param resourceType Resource type Unused.
 * @throws ConnectorRuntimeException If the resouce creation fails.
 */
public void createConnectorResource(ResourceInfo resourceInfo, PoolInfo poolInfo, String resourceType) throws ConnectorRuntimeException {
    try {
        ConnectorConnectionPool ccp = null;
        String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo);
        try {
            ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
        } catch (NamingException ne) {
            // Probably the pool is not yet initialized (lazy-loading), try doing a lookup
            try {
                checkAndLoadPool(poolInfo);
                ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
            } catch (NamingException e) {
                Object[] params = new Object[] { poolInfo, e };
                _logger.log(Level.SEVERE, "unable.to.lookup.pool", params);
            }
        }
        if (ccp == null) {
            ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool);
        }
        ConnectorDescriptorInfo cdi = ccp.getConnectorDescriptorInfo();
        javax.naming.Reference ref = new javax.naming.Reference(cdi.getConnectionFactoryClass(), "com.sun.enterprise.resource.naming.ConnectorObjectFactory", null);
        RefAddr addr = new SerializableObjectRefAddr(PoolInfo.class.getName(), poolInfo);
        ref.add(addr);
        addr = new StringRefAddr("rarName", cdi.getRarName());
        ref.add(addr);
        RefAddr resAddr = new SerializableObjectRefAddr(ResourceInfo.class.getName(), resourceInfo);
        ref.add(resAddr);
        try {
            namingService.publishObject(resourceInfo, ref, true);
            _registry.addResourceInfo(resourceInfo);
        } catch (NamingException ne) {
            ConnectorRuntimeException cre = new ConnectorRuntimeException(ne.getMessage());
            cre.initCause(ne);
            Object[] params = new Object[] { resourceInfo, cre };
            _logger.log(Level.SEVERE, "rardeployment.resource_jndi_bind_failure", params);
            throw cre;
        }
        /*

            ConnectorObjectFactory cof = new ConnectorObjectFactory(jndiName, ccp.getConnectorDescriptorInfo().
                    getConnectionFactoryClass(), cdi.getRarName(), poolName);

            _runtime.getNamingManager().publishObject(jndiName, cof, true);
*/
        // To notify that a connector resource rebind has happened.
        ConnectorResourceNamingEventNotifier.getInstance().notifyListeners(new ConnectorNamingEvent(resourceInfo.toString(), ConnectorNamingEvent.EVENT_OBJECT_REBIND));
    } catch (NamingException ne) {
        ConnectorRuntimeException cre = new ConnectorRuntimeException(ne.getMessage());
        cre.initCause(ne);
        Object[] params = new Object[] { resourceInfo, cre };
        _logger.log(Level.SEVERE, "rardeployment.jndi_lookup_failed", params);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectorConnectionPool(com.sun.enterprise.connectors.ConnectorConnectionPool) SerializableObjectRefAddr(org.glassfish.resources.naming.SerializableObjectRefAddr) ConnectorNamingEvent(com.sun.appserv.connectors.internal.spi.ConnectorNamingEvent) RefAddr(javax.naming.RefAddr) SerializableObjectRefAddr(org.glassfish.resources.naming.SerializableObjectRefAddr) StringRefAddr(javax.naming.StringRefAddr) StringRefAddr(javax.naming.StringRefAddr) ConnectorDescriptorInfo(com.sun.enterprise.connectors.ConnectorDescriptorInfo) NamingException(javax.naming.NamingException) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 29 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class AdminObjectResourceDeployer method deployResource.

/**
 * {@inheritDoc}
 */
public synchronized void deployResource(Object resource) throws Exception {
    final AdminObjectResource aor = (AdminObjectResource) resource;
    ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(aor);
    createAdminObjectResource(aor, resourceInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource)

Example 30 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class AdminObjectResourceDeployer method deployResource.

/**
 * {@inheritDoc}
 */
public synchronized void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
    final AdminObjectResource aor = (AdminObjectResource) resource;
    String jndiName = aor.getJndiName();
    ResourceInfo resourceInfo = new ResourceInfo(jndiName, applicationName, moduleName);
    createAdminObjectResource(aor, resourceInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource)

Aggregations

ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)81 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)15 NamingException (javax.naming.NamingException)14 JdbcResource (org.glassfish.jdbc.config.JdbcResource)9 Test (org.junit.Test)9 ContextServiceImpl (org.glassfish.enterprise.concurrent.ContextServiceImpl)8 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)7 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)6 RefAddr (javax.naming.RefAddr)5 SerializableObjectRefAddr (org.glassfish.resources.naming.SerializableObjectRefAddr)5 Resources (com.sun.enterprise.config.serverbeans.Resources)4 ResourceException (javax.resource.ResourceException)4 ContextService (org.glassfish.concurrent.config.ContextService)4 ManagedThreadFactory (org.glassfish.concurrent.config.ManagedThreadFactory)4 AdminObjectResource (org.glassfish.connectors.config.AdminObjectResource)4 CustomResource (org.glassfish.resources.config.CustomResource)4 MailResource (org.glassfish.resources.javamail.config.MailResource)4 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)3 ManagedExecutorService (org.glassfish.concurrent.config.ManagedExecutorService)3 ManagedScheduledExecutorService (org.glassfish.concurrent.config.ManagedScheduledExecutorService)3