Search in sources :

Example 46 with ResourceInfo

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

the class ConnectorResourceDeployer method deployResource.

/**
 * {@inheritDoc}
 */
public synchronized void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
    // deployResource is not synchronized as there is only one caller
    // ResourceProxy which is synchronized
    ConnectorResource domainResource = (ConnectorResource) resource;
    ResourceInfo resourceInfo = new ResourceInfo(domainResource.getJndiName(), applicationName, moduleName);
    PoolInfo poolInfo = new PoolInfo(domainResource.getPoolName(), applicationName, moduleName);
    createConnectorResource(domainResource, resourceInfo, poolInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ConnectorResource(org.glassfish.connectors.config.ConnectorResource)

Example 47 with ResourceInfo

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

the class ConnectorResourceDeployer method checkAndDeletePool.

/**
 * Checks if no more resource-refs to resources exists for the
 * connector connection pool and then deletes the pool
 *
 * @param cr ConnectorResource
 * @throws Exception (ConfigException / undeploy exception)
 * @since 8.1 pe/se/ee
 */
private void checkAndDeletePool(ConnectorResource cr) throws Exception {
    String poolName = cr.getPoolName();
    ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(cr);
    PoolInfo poolInfo = new PoolInfo(poolName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
    Resources resources = (Resources) cr.getParent();
    // Its possible that the ConnectorResource here is a ConnectorResourceeDefinition. Ignore optimization.
    if (resources != null) {
        try {
            boolean poolReferred = ResourcesUtil.createInstance().isPoolReferredInServerInstance(poolInfo);
            if (!poolReferred) {
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("Deleting connector connection pool [" + poolName + "] as there are no more " + "resource-refs to the pool in this server instance");
                }
                ConnectorConnectionPool ccp = (ConnectorConnectionPool) ConnectorsUtil.getResourceByName(resources, ConnectorConnectionPool.class, poolName);
                // Delete/Undeploy Pool
                runtime.getResourceDeployer(ccp).undeployResource(ccp);
            }
        } catch (Exception ce) {
            _logger.warning(ce.getMessage());
            if (_logger.isLoggable(Level.FINE)) {
                _logger.fine("Exception while deleting pool [ " + poolName + " ] : " + ce);
            }
            throw ce;
        }
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) Resources(com.sun.enterprise.config.serverbeans.Resources) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 48 with ResourceInfo

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

the class ConnectorResourceDeployer method createConnectorResource.

private void createConnectorResource(ConnectorResource connectorResource, ResourceInfo resourceInfo, PoolInfo poolInfo) throws ConnectorRuntimeException {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Calling backend to add connector resource", resourceInfo);
    }
    runtime.createConnectorResource(resourceInfo, poolInfo, null);
    String jndiName = resourceInfo.getName();
    // In-case the resource is explicitly created with a suffix (__nontx or __PM), no need to create one
    if (ConnectorsUtil.getValidSuffix(jndiName) == null) {
        ResourceInfo pmResourceInfo = new ResourceInfo(ConnectorsUtil.getPMJndiName(jndiName), resourceInfo.getApplicationName(), resourceInfo.getModuleName());
        runtime.createConnectorResource(pmResourceInfo, poolInfo, null);
    }
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Added connector resource in backend", resourceInfo);
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo)

Example 49 with ResourceInfo

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

the class ConnectorsRecoveryResourceHandler method loadAllConnectorResources.

/**
 * does a lookup of resources so that they are loaded for sure.
 */
private void loadAllConnectorResources() {
    try {
        Collection<ConnectorResource> connResources = getAllConnectorResources();
        InitialContext ic = new InitialContext();
        for (ConnectorResource connResource : connResources) {
            if (getResourcesUtil().isEnabled(connResource)) {
                try {
                    ic.lookup(connResource.getJndiName());
                // } catch (NameNotFoundException ne) {
                } catch (NamingException ne) {
                    // So we need to explicitly load that rar and create the resources
                    try {
                        ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(connResource);
                        ConnectorConnectionPool connConnectionPool = ResourcesUtil.createInstance().getConnectorConnectionPoolOfResource(resourceInfo);
                        if (connConnectionPool != null) {
                            // TODO V3 ideally this should not happen if connector modules (and embedded rars)
                            // TODO  are loaded before recovery
                            createActiveResourceAdapter(connConnectionPool.getResourceAdapterName());
                            getConnectorResourceDeployer().deployResource(connResource);
                        }
                    } catch (Exception ex) {
                        _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
                        if (_logger.isLoggable(Level.FINE)) {
                            _logger.log(Level.FINE, ne.toString(), ne);
                        }
                        _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
                        if (_logger.isLoggable(Level.FINE)) {
                            _logger.log(Level.FINE, ex.toString(), ex);
                        }
                    }
                } catch (Exception ex) {
                    _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", connResource.getJndiName());
                    if (_logger.isLoggable(Level.FINE)) {
                        _logger.log(Level.FINE, ex.toString(), ex);
                    }
                }
            }
        }
    } catch (NamingException ne) {
        _logger.log(Level.SEVERE, "error.loading.connector.resources.during.recovery", ne.getMessage());
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, ne.toString(), ne);
        }
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) NamingException(javax.naming.NamingException) ConnectorResource(org.glassfish.connectors.config.ConnectorResource) InitialContext(javax.naming.InitialContext) ResourceException(javax.resource.ResourceException) NamingException(javax.naming.NamingException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 50 with ResourceInfo

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

the class ContextServiceDeployer method undeployResource.

@Override
public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception {
    ContextService contextServiceRes = (ContextService) resource;
    ResourceInfo resourceInfo = new ResourceInfo(contextServiceRes.getJndiName(), applicationName, moduleName);
    namingService.unpublishObject(resourceInfo, contextServiceRes.getJndiName());
    // stop the runtime object
    concurrentRuntime.shutdownContextService(contextServiceRes.getJndiName());
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ContextService(org.glassfish.concurrent.config.ContextService)

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