Search in sources :

Example 36 with ResourceInfo

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

the class MailSessionDeployer method registerMSDReferredByApplication.

private void registerMSDReferredByApplication(String appName, MailSessionDescriptor msd) {
    if (!msd.isDeployed()) {
        CommonResourceProxy proxy = mailSessionProxyProvider.get();
        org.glassfish.resourcebase.resources.naming.ResourceNamingService resourceNamingService = resourceNamingServiceProvider.get();
        proxy.setDescriptor(msd);
        if (msd.getName().startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) {
            msd.setResourceId(appName);
        }
        if (msd.getName().startsWith(ConnectorConstants.JAVA_GLOBAL_SCOPE_PREFIX) || msd.getName().startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) {
            ResourceInfo resourceInfo = new ResourceInfo(msd.getName(), appName);
            try {
                resourceNamingService.publishObject(resourceInfo, proxy, true);
                msd.setDeployed(true);
            } catch (NamingException e) {
                Object[] params = new Object[] { appName, msd.getName(), e };
                _logger.log(Level.WARNING, "exception while registering mail-session ", params);
            }
        }
    }
}
Also used : CommonResourceProxy(org.glassfish.javaee.services.CommonResourceProxy) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) NamingException(javax.naming.NamingException)

Example 37 with ResourceInfo

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

the class JdbcResourceDeployer method deployResource.

/**
 * {@inheritDoc}
 */
@Override
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
    JdbcResource jdbcRes = (JdbcResource) resource;
    String jndiName = jdbcRes.getJndiName();
    String poolName = jdbcRes.getPoolName();
    PoolInfo poolInfo = new PoolInfo(poolName, applicationName, moduleName);
    ResourceInfo resourceInfo = new ResourceInfo(jndiName, applicationName, moduleName);
    runtime.createConnectorResource(resourceInfo, poolInfo, null);
    // 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.FINEST)) {
        _logger.finest("deployed resource " + jndiName);
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) JdbcResource(org.glassfish.jdbc.config.JdbcResource) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 38 with ResourceInfo

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

the class JdbcResourceDeployer method deleteResource.

private void deleteResource(JdbcResource jdbcResource, ResourceInfo resourceInfo) throws Exception {
    runtime.deleteConnectorResource(resourceInfo);
    ConnectorRegistry.getInstance().removeResourceFactories(resourceInfo);
    // In-case the resource is explicitly created with a suffix (__nontx or __PM), no need to delete one
    if (ConnectorsUtil.getValidSuffix(resourceInfo.getName()) == null) {
        String pmJndiName = ConnectorsUtil.getPMJndiName(resourceInfo.getName());
        ResourceInfo pmResourceInfo = new ResourceInfo(pmJndiName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
        runtime.deleteConnectorResource(pmResourceInfo);
        ConnectorRegistry.getInstance().removeResourceFactories(pmResourceInfo);
    }
    // Since 8.1 PE/SE/EE - if no more resource-ref to the pool
    // of this resource in this server instance, remove pool from connector
    // runtime
    checkAndDeletePool(jdbcResource);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo)

Example 39 with ResourceInfo

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

the class JdbcResourceDeployer method deployResource.

/**
 * {@inheritDoc}
 */
@Override
public void deployResource(Object resource) throws Exception {
    JdbcResource jdbcRes = (JdbcResource) resource;
    ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(jdbcRes);
    deployResource(jdbcRes, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) JdbcResource(org.glassfish.jdbc.config.JdbcResource)

Example 40 with ResourceInfo

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

the class ConnectionPoolHealthCheck method doCheck.

@Override
public HealthCheckResult doCheck() {
    HealthCheckResult result = new HealthCheckResult();
    Collection<JdbcResource> allJdbcResources = getAllJdbcResources();
    for (JdbcResource resource : allJdbcResources) {
        ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(resource);
        JdbcConnectionPool pool = JdbcResourcesUtil.createInstance().getJdbcConnectionPoolOfResource(resourceInfo);
        PoolInfo poolInfo = ResourceUtil.getPoolInfo(pool);
        if (getOptions().getPoolName() != null) {
            if (getOptions().getPoolName().equals(poolInfo.getName())) {
                evaluatePoolUsage(result, poolInfo);
            }
        } else {
            evaluatePoolUsage(result, poolInfo);
        }
    }
    return result;
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) JdbcResource(org.glassfish.jdbc.config.JdbcResource) JdbcConnectionPool(org.glassfish.jdbc.config.JdbcConnectionPool) HealthCheckResult(fish.payara.nucleus.healthcheck.HealthCheckResult) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

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