Search in sources :

Example 16 with ResourceInfo

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);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) CustomResource(org.glassfish.resources.config.CustomResource)

Example 17 with 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);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) CustomResource(org.glassfish.resources.config.CustomResource)

Example 18 with 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);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) MailResource(org.glassfish.resources.javamail.config.MailResource)

Example 19 with 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());
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) MailResource(org.glassfish.resources.javamail.config.MailResource)

Example 20 with ResourceInfo

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;
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) Enumeration(java.util.Enumeration) Hashtable(java.util.Hashtable) javax.naming(javax.naming)

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