Search in sources :

Example 1 with ResourceNamingService

use of org.glassfish.resourcebase.resources.naming.ResourceNamingService in project Payara by payara.

the class DataSourceDefinitionDeployer method unregisterDSDReferredByApplication.

private void unregisterDSDReferredByApplication(String appName, DataSourceDefinitionDescriptor dsd) {
    try {
        if (dsd.isDeployed()) {
            undeployResource(dsd);
            // unbind from JNDI
            ResourceNamingService resourceNamingService = resourceNamingServiceProvider.get();
            String dsdName = dsd.getName();
            if (dsdName.startsWith(JAVA_GLOBAL_SCOPE_PREFIX) || dsdName.startsWith(JAVA_APP_SCOPE_PREFIX)) {
                ResourceInfo resourceInfo = new ResourceInfo(dsdName, appName, null);
                try {
                    resourceNamingService.unpublishObject(resourceInfo, dsdName);
                    dsd.setDeployed(false);
                } catch (NamingException e) {
                    _logger.log(WARNING, "dsd.unregistration.failed", new Object[] { appName, dsdName, e });
                }
            }
        }
    } catch (Exception e) {
        _logger.log(WARNING, "exception while unregistering DSD [ " + dsd.getName() + " ]", e);
    }
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ResourceNamingService(org.glassfish.resourcebase.resources.naming.ResourceNamingService) NamingException(javax.naming.NamingException) NamingException(javax.naming.NamingException) PropertyVetoException(java.beans.PropertyVetoException) ResourceConflictException(org.glassfish.resourcebase.resources.api.ResourceConflictException)

Example 2 with ResourceNamingService

use of org.glassfish.resourcebase.resources.naming.ResourceNamingService in project Payara by payara.

the class DataSourceDefinitionDeployer method registerDSDReferredByApplication.

private void registerDSDReferredByApplication(String appName, DataSourceDefinitionDescriptor dsd) {
    // DSD is bound to JNDI only when it is not already deployed.
    if (!dsd.isDeployed()) {
        CommonResourceProxy proxy = dataSourceDefinitionProxyProvider.get();
        ResourceNamingService resourceNamingService = resourceNamingServiceProvider.get();
        proxy.setDescriptor(dsd);
        String dsdName = dsd.getName();
        if (dsdName.startsWith(JAVA_APP_SCOPE_PREFIX)) {
            dsd.setResourceId(appName);
        }
        if (dsdName.startsWith(JAVA_GLOBAL_SCOPE_PREFIX) || dsdName.startsWith(JAVA_APP_SCOPE_PREFIX)) {
            ResourceInfo resourceInfo = new ResourceInfo(dsdName, appName, null);
            try {
                resourceNamingService.publishObject(resourceInfo, proxy, true);
                dsd.setDeployed(true);
            } catch (NamingException e) {
                _logger.log(Level.WARNING, "dsd.registration.failed", new Object[] { appName, dsdName, e });
            }
        }
    }
}
Also used : CommonResourceProxy(org.glassfish.javaee.services.CommonResourceProxy) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ResourceNamingService(org.glassfish.resourcebase.resources.naming.ResourceNamingService) NamingException(javax.naming.NamingException)

Aggregations

NamingException (javax.naming.NamingException)2 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)2 ResourceNamingService (org.glassfish.resourcebase.resources.naming.ResourceNamingService)2 PropertyVetoException (java.beans.PropertyVetoException)1 CommonResourceProxy (org.glassfish.javaee.services.CommonResourceProxy)1 ResourceConflictException (org.glassfish.resourcebase.resources.api.ResourceConflictException)1