use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class CustomResourceDeployer method deployResource.
/**
* {@inheritDoc}
*/
@Override
public synchronized void deployResource(Object resource) throws Exception {
CustomResource customResource = (CustomResource) resource;
ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(customResource);
deployResource(customResource, resourceInfo);
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class CustomResourceDeployer method undeployResource.
/**
* {@inheritDoc}
*/
@Override
public synchronized void undeployResource(Object resource) throws Exception {
CustomResource customResource = (CustomResource) resource;
ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(customResource);
deleteResource(customResource, resourceInfo);
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class MailResourceDeployer method undeployResource.
/**
* {@inheritDoc}
*/
@Override
public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception {
MailResource mailRes = (MailResource) resource;
// converts the config data to j2ee resource
ResourceInfo resourceInfo = new ResourceInfo(mailRes.getJndiName(), applicationName, moduleName);
deleteResource(mailRes, resourceInfo);
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class MailResourceDeployer method deployResource.
/**
* {@inheritDoc}
*/
@Override
public synchronized void deployResource(Object resource) throws Exception {
MailResource mailResource = (MailResource) resource;
ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(mailResource);
deployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
}
use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.
the class JndiProxyObjectFactory method getObjectInstance.
/**
* create the object instance from the factory
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws NamingException {
// name to lookup in the external factory
String jndiLookupName = "";
String jndiFactoryClass = null;
ResourceInfo resourceInfo = null;
// get the target initial naming context and the lookup name
Reference ref = (Reference) obj;
Enumeration addrs = ref.getAll();
while (addrs.hasMoreElements()) {
RefAddr addr = (RefAddr) addrs.nextElement();
String prop = addr.getType();
if (prop.equals("resourceInfo")) {
resourceInfo = (ResourceInfo) addr.getContent();
} else if (prop.equals("jndiLookupName")) {
jndiLookupName = (String) addr.getContent();
} else if (prop.equals("jndiFactoryClass")) {
jndiFactoryClass = (String) addr.getContent();
}
}
if (resourceInfo == null) {
throw new NamingException("JndiProxyObjectFactory: no resourceInfo context info");
}
ProxyRefAddr contextAddr = (ProxyRefAddr) ref.get(resourceInfo.getName());
Hashtable env = null;
if (contextAddr == null || jndiFactoryClass == null || (env = (Hashtable) (contextAddr.getContent())) == null) {
throw new NamingException("JndiProxyObjectFactory: no info in the " + "reference about the target context; contextAddr = " + contextAddr + " " + "env = " + env + " factoryClass = " + jndiFactoryClass);
}
// Context of the external naming factory
Context context = contextMap.get(resourceInfo);
if (context == null) {
synchronized (contextMap) {
context = contextMap.get(resourceInfo);
if (context == null) {
context = loadInitialContext(jndiFactoryClass, env);
contextMap.put(resourceInfo, context);
}
}
}
// use the name to lookup in the external JNDI naming context
Object retObj = null;
try {
retObj = context.lookup(jndiLookupName);
} catch (NameNotFoundException e) {
// Fixing issue: http://java.net/jira/browse/GLASSFISH-15447
throw new ExternalNameNotFoundException(e);
} catch (javax.naming.NamingException ne) {
// Fixing issue: http://java.net/jira/browse/GLASSFISH-15447
context = loadInitialContext(jndiFactoryClass, env);
if (context == null) {
throw new NamingException("JndiProxyObjectFactory no InitialContext" + jndiFactoryClass);
} else {
contextMap.put(resourceInfo, context);
try {
retObj = context.lookup(jndiLookupName);
} catch (NameNotFoundException e) {
throw new ExternalNameNotFoundException(e);
}
}
}
return retObj;
}
Aggregations