// It is possible that JPA might call this method multiple times in a single deployment,
// when there are multiple PUs eg: one PU in each of war, ejb-jar. Make sure that
// 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 appName = application.getAppName();
String dsdName = dsd.getName();
if(dsdName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)){
dsd.setResourceId(appName);
}
if(dsdName.startsWith(ConnectorConstants.JAVA_GLOBAL_SCOPE_PREFIX)
/*|| next.getName().startsWith("java:module/")*/
|| dsdName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)){
ResourceInfo resourceInfo = new ResourceInfo(dsdName, appName, null);
try {
resourceNamingService.publishObject(resourceInfo, proxy, true);
dsd.setDeployed(true);
} catch (NamingException e) {
Object params[] = new Object[]{appName, dsdName, e};
_logger.log(Level.WARNING, "dsd.registration.failed", params);
}