public void scan(Configuration configuration) { List<ScannedItemHandler> handlers = new ArrayList<ScannedItemHandler>(); for (Factory factory : factories.values()) { try { Class<?> clazz = TypeUtil.forName(factory.getClassName()); Method method = clazz.getMethod("getScannedItemHandler"); if ((Modifier.STATIC & method.getModifiers()) != 0 && method.getParameterTypes().length == 0) { ScannedItemHandler handler = (ScannedItemHandler)method.invoke(null); handlers.add(handler); } else log.warn("Factory class %s contains an unexpected signature for method: %s", factory.getClassName(), method); } catch (NoSuchMethodException e) { // ignore } catch (ClassNotFoundException e) { log.error(e, "Could not load factory class: %s", factory.getClassName()); } catch (Exception e) { log.error(e, "Error while calling %s.getScannedItemHandler() method", factory.getClassName()); } } scanConfig(configuration != null ? configuration.getFlexServicesConfigProperties() : null, handlers); }
public void scan(Configuration configuration) { List<ScannedItemHandler> handlers = new ArrayList<ScannedItemHandler>(); for (Factory factory : factories.values()) { try { Class<?> clazz = TypeUtil.forName(factory.getClassName()); Method method = clazz.getMethod("getScannedItemHandler"); if ((Modifier.STATIC & method.getModifiers()) != 0 && method.getParameterTypes().length == 0) { ScannedItemHandler handler = (ScannedItemHandler)method.invoke(null); handlers.add(handler); } else log.warn("Factory class %s contains an unexpected signature for method: %s", factory.getClassName(), method); } catch (NoSuchMethodException e) { // ignore } catch (ClassNotFoundException e) { log.error(e, "Could not load factory class: %s", factory.getClassName()); } catch (Exception e) { log.error(e, "Error while calling %s.getScannedItemHandler() method", factory.getClassName()); } } scanConfig(configuration != null ? configuration.getFlexServicesConfigProperties() : null, handlers); }