Search in sources :

Example 71 with ResourceInfo

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

the class ResourcesDeployer method deployResources.

public void deployResources(String applicationName, String moduleName, Collection<com.sun.enterprise.config.serverbeans.Resource> resources, boolean postDeployPhase) throws Exception {
    for (Resource resource : resources) {
        if (resource instanceof BindableResource) {
            BindableResource bindableResource = (BindableResource) resource;
            ResourceInfo resourceInfo = new ResourceInfo(bindableResource.getJndiName(), applicationName, moduleName);
            if (getResourceDeployer(bindableResource).canDeploy(postDeployPhase, resources, bindableResource)) {
                resourcesBinder.deployResource(resourceInfo, bindableResource);
            }
        } else {
            if (getResourceDeployer(resource).canDeploy(postDeployPhase, resources, resource)) {
                getResourceDeployer(resource).deployResource(resource, applicationName, moduleName);
            }
        }
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) Resource(com.sun.enterprise.config.serverbeans.Resource) Resource(org.glassfish.resources.api.Resource)

Example 72 with ResourceInfo

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

the class CustomResourceDeployer method undeployResource.

/**
 * {@inheritDoc}
 */
@Override
public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception {
    CustomResource customResource = (CustomResource) resource;
    ResourceInfo resourceInfo = new ResourceInfo(customResource.getJndiName(), applicationName, moduleName);
    deleteResource(customResource, resourceInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) CustomResource(org.glassfish.resources.config.CustomResource)

Example 73 with ResourceInfo

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

the class MailResourceDeployer method undeployResource.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void undeployResource(Object resource) throws Exception {
    MailResource mailRes = (MailResource) resource;
    // converts the config data to j2ee resource
    ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(mailRes);
    deleteResource(mailRes, resourceInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) MailResource(org.glassfish.resources.javamail.config.MailResource)

Example 74 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, String applicationName, String moduleName) throws Exception {
    MailResource mailRes = (MailResource) resource;
    if (mailRes == null) {
        _logger.log(Level.INFO, "Error in resource deploy.");
    } else {
        ResourceInfo resourceInfo = new ResourceInfo(mailRes.getJndiName(), applicationName, moduleName);
        // registers the jsr77 object for the mail resource deployed
        /* TODO Not needed any more ?
            /*ManagementObjectManager mgr =
                getAppServerSwitchObject().getManagementObjectManager();
            mgr.registerJavaMailResource(mailRes.getJndiName());*/
        installResource(mailRes, resourceInfo);
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) MailResource(org.glassfish.resources.javamail.config.MailResource)

Example 75 with ResourceInfo

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

the class ApplicationScopedResourcesManager method deployResources.

/**
 * deploy resources
 * @param resources list
 */
public void deployResources(Collection<Resource> resources) {
    if (resources != null) {
        String applicationName = null;
        String moduleName = null;
        for (Resource resource : resources) {
            Object parentObject = resource.getParent().getParent();
            if (parentObject instanceof Application) {
                applicationName = ((Application) parentObject).getName();
            } else if (parentObject instanceof Module) {
                moduleName = ((Module) parentObject).getName();
                applicationName = ((Application) ((Module) parentObject).getParent()).getName();
            }
            if (resource instanceof BindableResource) {
                BindableResource bindableResource = (BindableResource) resource;
                ResourceInfo resourceInfo = new ResourceInfo(bindableResource.getJndiName(), applicationName, moduleName);
                resourcesBinder.deployResource(resourceInfo, resource);
            } else if (resource instanceof ResourcePool) {
            // ignore, as they are loaded lazily
            } else {
                // only other resources left are RAC, CWSM
                try {
                    getResourceDeployer(resource).deployResource(resource, applicationName, moduleName);
                } catch (Exception e) {
                    Object[] params = { ResourceUtil.getGenericResourceInfo(resource), e };
                    _logger.log(Level.WARNING, "resources.resource-manager.deploy-resource-failed", params);
                }
            }
        }
        addListenerToResources(resources);
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo)

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