Search in sources :

Example 56 with ResourceInfo

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

the class ConcurrentRuntimeTest method testParseContextInfo.

@Test
public void testParseContextInfo() throws Exception {
    expect(contextServiceConfig.getJndiName()).andReturn("concurrent/ctxSrv").anyTimes();
    expect(contextServiceConfig.getContextInfo()).andReturn("Classloader, JNDI, Security, WorkArea").anyTimes();
    expect(contextServiceConfig.getContextInfoEnabled()).andReturn("true");
    replay(contextServiceConfig);
    ConcurrentRuntime concurrentRuntime = new ConcurrentRuntime();
    ResourceInfo resource = new ResourceInfo("test");
    ContextServiceImpl contextService = concurrentRuntime.getContextService(resource, contextServiceConfig);
    ContextSetupProviderImpl contextSetupProvider = (ContextSetupProviderImpl) contextService.getContextSetupProvider();
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "classloading"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "naming"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "security"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "workArea"));
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ContextServiceImpl(org.glassfish.enterprise.concurrent.ContextServiceImpl) Test(org.junit.Test)

Example 57 with ResourceInfo

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

the class ManagedExecutorServiceDeployer method undeployResource.

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

Example 58 with ResourceInfo

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

the class ManagedExecutorServiceDeployer method deployResource.

@Override
public void deployResource(Object resource) throws Exception {
    ManagedExecutorService managedExecutorServiceResource = (ManagedExecutorService) resource;
    ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(managedExecutorServiceResource);
    deployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
}
Also used : ManagedExecutorService(org.glassfish.concurrent.config.ManagedExecutorService) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo)

Example 59 with ResourceInfo

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

the class ManagedExecutorServiceDeployer method deployResource.

@Override
public void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
    ManagedExecutorService managedExecutorServiceRes = (ManagedExecutorService) resource;
    if (managedExecutorServiceRes == null) {
        _logger.log(Level.WARNING, LogFacade.DEPLOY_ERROR_NULL_CONFIG, "ManagedExecutorService");
        return;
    }
    String jndiName = managedExecutorServiceRes.getJndiName();
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "ManagedExecutorServiceDeployer.deployResource() : jndi-name [" + jndiName + "], ");
    }
    ResourceInfo resourceInfo = new ResourceInfo(managedExecutorServiceRes.getJndiName(), applicationName, moduleName);
    ManagedExecutorServiceConfig config = new ManagedExecutorServiceConfig(managedExecutorServiceRes);
    javax.naming.Reference ref = new javax.naming.Reference(javax.enterprise.concurrent.ManagedExecutorService.class.getName(), "org.glassfish.concurrent.runtime.deployer.ConcurrentObjectFactory", null);
    RefAddr addr = new SerializableObjectRefAddr(ManagedExecutorServiceConfig.class.getName(), config);
    ref.add(addr);
    RefAddr resAddr = new SerializableObjectRefAddr(ResourceInfo.class.getName(), resourceInfo);
    ref.add(resAddr);
    try {
        // Publish the object ref
        namingService.publishObject(resourceInfo, ref, true);
    } catch (NamingException ex) {
        LogHelper.log(_logger, Level.SEVERE, LogFacade.UNABLE_TO_BIND_OBJECT, ex, "ManagedExecutorService", jndiName);
    }
    registerMonitorableComponent(managedExecutorServiceRes);
}
Also used : RefAddr(javax.naming.RefAddr) SerializableObjectRefAddr(org.glassfish.resources.naming.SerializableObjectRefAddr) ManagedExecutorService(org.glassfish.concurrent.config.ManagedExecutorService) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) SerializableObjectRefAddr(org.glassfish.resources.naming.SerializableObjectRefAddr) NamingException(javax.naming.NamingException)

Example 60 with ResourceInfo

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

the class ManagedScheduledExecutorServiceDeployer method undeployResource.

@Override
public void undeployResource(Object resource) throws Exception {
    ManagedScheduledExecutorService ManagedScheduledExecutorServiceResource = (ManagedScheduledExecutorService) resource;
    ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(ManagedScheduledExecutorServiceResource);
    undeployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ManagedScheduledExecutorService(org.glassfish.concurrent.config.ManagedScheduledExecutorService)

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