use of javax.naming.RefAddr in project Payara by payara.
the class ManagedScheduledExecutorServiceDeployer method deployResource.
@Override
public void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
ManagedScheduledExecutorService managedScheduledExecutorServiceRes = (ManagedScheduledExecutorService) resource;
if (managedScheduledExecutorServiceRes == null) {
_logger.log(Level.WARNING, LogFacade.DEPLOY_ERROR_NULL_CONFIG, "ManagedScheduledExecutorService");
return;
}
String jndiName = managedScheduledExecutorServiceRes.getJndiName();
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "ManagedScheduledExecutorServiceDeployer.deployResource() : jndi-name [" + jndiName + "]");
}
ResourceInfo resourceInfo = new ResourceInfo(managedScheduledExecutorServiceRes.getJndiName(), applicationName, moduleName);
ManagedScheduledExecutorServiceConfig config = new ManagedScheduledExecutorServiceConfig(managedScheduledExecutorServiceRes);
javax.naming.Reference ref = new javax.naming.Reference(javax.enterprise.concurrent.ManagedScheduledExecutorService.class.getName(), "org.glassfish.concurrent.runtime.deployer.ConcurrentObjectFactory", null);
RefAddr addr = new SerializableObjectRefAddr(ManagedScheduledExecutorServiceConfig.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, "ManagedScheduledExecutorService", jndiName);
}
registerMonitorableComponent(managedScheduledExecutorServiceRes);
}
use of javax.naming.RefAddr 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);
}
}
use of javax.naming.RefAddr 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);
}
use of javax.naming.RefAddr in project tomee by apache.
the class NamingUtil method getProperty.
public static String getProperty(final Reference ref, final String name) {
final RefAddr addr = ref.get(name);
if (addr == null) {
return null;
}
final Object value = addr.getContent();
return (String) value;
}
use of javax.naming.RefAddr in project tomee by apache.
the class TomcatEjbFactory method getObjectInstance.
@SuppressWarnings("unchecked")
@Override
public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment) throws Exception {
Object beanObj = null;
final Class ejbRefClass = Class.forName("org.apache.naming.EjbRef");
if (ejbRefClass.isAssignableFrom(obj.getClass())) {
RefAddr refAddr;
String addrType;
final Properties env = new Properties();
String bean = null;
final Reference ref = (Reference) obj;
final Enumeration addresses = ref.getAll();
while (addresses.hasMoreElements()) {
refAddr = (RefAddr) addresses.nextElement();
addrType = refAddr.getType();
if (addrType.startsWith(OPENEJB_PREFIX)) {
final String value = refAddr.getContent().toString();
if (addrType.equals(OPENEJB_EJB_LINK)) {
bean = value;
continue;
}
String key = addrType.substring(OPENEJB_PREFIX_LENGTH);
key = JAVA_PREFIX + key;
env.put(key, value);
}
}
if (bean != null) {
beanObj = (new InitialContext(env)).lookup(bean);
}
}
return beanObj;
}
Aggregations