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);
}
}
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 });
}
}
}
}
Aggregations