}
} catch (Exception e) {
throw new PortletException(e);
}
DataSourceInfo info = new DataSourceInfo();
info.setObjectName(gbeanName);
info.setName(gbeanName.getKeyProperty("name"));
try {
info.setState(new Integer(kernel.getGBeanState(gbeanName)));
//check if user asked this connection to be tested
if ((gbeanName.toString().equals(name)) && (check)) {
info.setWorking(true);
try {
Object cf = kernel.invoke(gbeanName, "$getResource");
testConnection(cf);
info.setMessage("Connected");
} catch (Exception e) {
Throwable t = e;
String message = "Failed: ";
if (t.getMessage() != null) {
message = message + t.getMessage();
} else {
while (t.getMessage() == null) {
t = t.getCause();
if (t != null) {
message = message + t.getMessage();
} else {
message = message + "Unknown reason";
}
}
}
info.setMessage(message);
}
} else {
info.setWorking(false);
}
} catch (Exception e) {
throw new PortletException(e);
}