* Will log errors instead of throwing exceptions if one or more of the registrations fails.
* @param poolPropeties the complete pool properties.
* @throws org.logicalcobwebs.proxool.ProxoolException if the pool can not be found.
*/
public static void registerPool(String alias, Properties poolPropeties) throws ProxoolException {
ConnectionPoolDefinitionIF connectionPoolDefinition =
ProxoolFacade.getConnectionPoolDefinition(alias);
String[] agentIds = getAgentIds(poolPropeties);
ArrayList servers = null;
for (int i = 0; i < agentIds.length; i++) {
servers = MBeanServerFactory.findMBeanServer(agentIds[i]);
if (servers == null || servers.size() < 1) {
LOG.error("Could not register pool " + connectionPoolDefinition.getAlias() + " for JMX instrumentation"
+ " because lookup of MBeanServer using agent id " + agentIds[i] + " failed.");
} else {
MBeanServer mBeanServer = (MBeanServer) servers.get(0);
ConnectionPoolMBean poolMBean = new ConnectionPoolMBean(alias, poolPropeties);
try {
mBeanServer.registerMBean(poolMBean, getObjectName(connectionPoolDefinition.getAlias()));
LOG.info("Registered JMX MBean for pool " + connectionPoolDefinition.getAlias() + " in agent " + agentIds[i]);
} catch (Exception e) {
LOG.error("Registration of JMX MBean for pool " + connectionPoolDefinition.getAlias()
+ "in agent " + agentIds[i] + " failed.", e);
}
}
}
}