} catch (Exception e) {
log.error("Problem getting datasource " + dsName, e);
}
Kernel kernel = KernelRegistry.getSingleKernel();
ManagementHelper helper = new KernelManagementHelper(kernel);
ResourceAdapterModule[] modules = helper.getOutboundRAModules(helper.getDomains()[0].getServerInstances()[0], "javax.sql.DataSource");
for (ResourceAdapterModule module : modules) {
org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory[] databases = helper.getOutboundFactories(module, "javax.sql.DataSource");
for (org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory db : databases) {
try {
AbstractName dbName = kernel.getAbstractNameFor(db);
String datasourceName = (String)dbName.getName().get(NameFactory.J2EE_NAME);
if(dsName.equalsIgnoreCase(datasourceName)) {
AbstractName tempDbName = helper.getNameFor(db);
return (DataSource) KernelRegistry.getSingleKernel().invoke(
tempDbName, "$getResource");
}
} catch (Exception ignored) {
}