add findDataSourceByName method

This commit is contained in:
wenshao
2012-08-23 16:00:32 +08:00
parent 2b34673487
commit 204d642587
5 changed files with 706 additions and 15 deletions
@@ -28,6 +28,21 @@ public class DruidDataSourceUtils {
return null;
}
}
public static String getName(Object druidDatasource) {
if (druidDatasource.getClass() == DruidDataSource.class) {
return ((DruidDataSource) druidDatasource).getName();
}
try {
Method method = druidDatasource.getClass().getMethod("getName");
Object obj = method.invoke(druidDatasource);
return (String) obj;
} catch (Exception e) {
LOG.error("getUrl error", e);
return null;
}
}
public static ObjectName getObjectName(Object druidDatasource) {
if (druidDatasource.getClass() == DruidDataSource.class) {