*/
public MetricGroupProxyFactory(ReportingConfig config) {
if (config != null) {
Map datasourceConfigs = config.getDatasourceConfigMap();
for (Iterator it = config.getReportElementsIterator(); it.hasNext();) {
ReportElement report = (ReportElement) it.next();
if (report.getEnabled()) {
ExclusionManager.getDefaultInstance().initializeExclusions(
report.getBinding(),
report.getReportExclusion());
if (report.getGenericHandler() != null) {
GenericHandler genericHandler = report.getGenericHandler();
String className = genericHandler.getClassName();
Class handlerClass = null;
try {
handlerClass = Class.forName(className);
} catch (ClassNotFoundException e) {
LOGGER.error("failed-to-find-class", className, e);
}
try {
Constructor con = null;
try {
con = handlerClass.getConstructor(REPORT_HANDLER_ARGS);
} catch (NoSuchMethodException e) {
LOGGER.error("failed-to-create-class",
handlerClass,
e);
}
ReportHandler reportHandler = null;
try {
Object[] args = new Object[2];
args[0] = buildGenericMap(genericHandler);
args[1] = report.getBinding();
reportHandler = (ReportHandler) con.newInstance(args);
} catch (InstantiationException e) {
LOGGER.error("failed-to-load-class",
handlerClass,
e);
} catch (IllegalAccessException e) {
LOGGER.error("failed-to-load-class",
handlerClass,
e);
} catch (InvocationTargetException e) {
LOGGER.error("failed-to-load-class",
handlerClass,
e);
}
handlers.put(report.getBinding(), reportHandler);
} catch (Exception e) {
LOGGER.error("failed-to-load-class", className);
}
} else if (report.getSqlHandler() != null) {
if (existsDatasourceDefinition(
datasourceConfigs, report.getSqlHandler())) {
ConnectionStrategy connStrategy =
DatasourceManager.getInstance().createConnectionStrategy(
(DatasourceConfiguration) datasourceConfigs.get(
report.getSqlHandler().getDatasourceName()));
ReportHandler handler =
new JDBCReportHandler(connStrategy, report);
handlers.put(report.getBinding(), handler);
} else {
LOGGER.error("sql-handler-datasource-not-found",
new Object[] {report.getSqlHandler().getDatasourceName(),
report.getBinding()});
}
} else {
LOGGER.error("handler-not-found", report.getBinding());
}
}
}
}
}