// 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()){
DataSourceDefinitionProxy proxy = habitat.getComponent(DataSourceDefinitionProxy.class);
ResourceNamingService resourceNamingService = habitat.getComponent(ResourceNamingService.class);
proxy.setDescriptor(dsd);
//String appName = application.getAppName();
String moduleName = null;
if(dsd.getName().startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)){
dsd.setResourceId(appName);
}
if(dsd.getName().startsWith(ConnectorConstants.JAVA_GLOBAL_SCOPE_PREFIX)
/*|| next.getName().startsWith("java:module/")*/
|| dsd.getName().startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)){
ResourceInfo resourceInfo = new ResourceInfo(dsd.getName(), appName, moduleName);
try {
resourceNamingService.publishObject(resourceInfo, proxy, true);
dsd.setDeployed(true);
} catch (NamingException e) {
Object params[] = new Object[]{appName, dsd.getName(), e};
_logger.log(Level.WARNING, "dsd.registration.failed", params);
}