Search in sources :

Example 6 with ManagedThreadFactory

use of org.glassfish.concurrent.config.ManagedThreadFactory in project Payara by payara.

the class ManagedThreadFactoryManager method createConfigBean.

private ManagedThreadFactory createConfigBean(Resources param, Properties properties) throws PropertyVetoException, TransactionFailure {
    ManagedThreadFactory managedThreadFactory = param.createChild(ManagedThreadFactory.class);
    managedThreadFactory.setJndiName(jndiName);
    if (description != null) {
        managedThreadFactory.setDescription(description);
    }
    managedThreadFactory.setContextInfoEnabled(contextInfoEnabled);
    managedThreadFactory.setContextInfo(contextInfo);
    managedThreadFactory.setThreadPriority(threadPriority);
    managedThreadFactory.setEnabled(enabled);
    if (properties != null) {
        for (Map.Entry e : properties.entrySet()) {
            Property prop = managedThreadFactory.createChild(Property.class);
            prop.setName((String) e.getKey());
            prop.setValue((String) e.getValue());
            managedThreadFactory.getProperty().add(prop);
        }
    }
    return managedThreadFactory;
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) Property(org.jvnet.hk2.config.types.Property) ManagedThreadFactory(org.glassfish.concurrent.config.ManagedThreadFactory)

Example 7 with ManagedThreadFactory

use of org.glassfish.concurrent.config.ManagedThreadFactory in project Payara by payara.

the class ManagedThreadFactoryDeployer method deployResource.

@Override
public void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
    ManagedThreadFactory ManagedThreadFactoryRes = (ManagedThreadFactory) resource;
    if (ManagedThreadFactoryRes == null) {
        _logger.log(Level.WARNING, LogFacade.DEPLOY_ERROR_NULL_CONFIG, "ManagedThreadFactory");
        return;
    }
    String jndiName = ManagedThreadFactoryRes.getJndiName();
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "ManagedThreadFactoryDeployer.deployResource() : jndi-name [" + jndiName + "]");
    }
    ResourceInfo resourceInfo = new ResourceInfo(ManagedThreadFactoryRes.getJndiName(), applicationName, moduleName);
    ManagedThreadFactoryConfig config = new ManagedThreadFactoryConfig(ManagedThreadFactoryRes);
    javax.naming.Reference ref = new javax.naming.Reference(javax.enterprise.concurrent.ManagedThreadFactory.class.getName(), "org.glassfish.concurrent.runtime.deployer.ConcurrentObjectFactory", null);
    RefAddr addr = new SerializableObjectRefAddr(ManagedThreadFactoryConfig.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, "ManagedThreadFactory", jndiName);
    }
}
Also used : RefAddr(javax.naming.RefAddr) SerializableObjectRefAddr(org.glassfish.resources.naming.SerializableObjectRefAddr) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) SerializableObjectRefAddr(org.glassfish.resources.naming.SerializableObjectRefAddr) NamingException(javax.naming.NamingException) ManagedThreadFactory(org.glassfish.concurrent.config.ManagedThreadFactory)

Example 8 with ManagedThreadFactory

use of org.glassfish.concurrent.config.ManagedThreadFactory in project Payara by payara.

the class ManagedThreadFactoryDeployer method undeployResource.

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

Aggregations

ManagedThreadFactory (org.glassfish.concurrent.config.ManagedThreadFactory)8 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)4 Resource (com.sun.enterprise.config.serverbeans.Resource)1 Resources (com.sun.enterprise.config.serverbeans.Resources)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 NamingException (javax.naming.NamingException)1 RefAddr (javax.naming.RefAddr)1 ActionReport (org.glassfish.api.ActionReport)1 DefaultResourceProxy (org.glassfish.api.naming.DefaultResourceProxy)1 DefaultManagedThreadFactory (org.glassfish.concurrent.runtime.deployer.DefaultManagedThreadFactory)1 ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)1 SerializableObjectRefAddr (org.glassfish.resources.naming.SerializableObjectRefAddr)1 SingleConfigCode (org.jvnet.hk2.config.SingleConfigCode)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1 Property (org.jvnet.hk2.config.types.Property)1