@Test public void testLoadConverterModule() { List<ConverterModule> modules = KnownConverterModuleLoader.load(); ConverterModule converterModule = null; for (ConverterModule module : modules) { if (module instanceof DummyConverterModule) { converterModule = module; } } Assert.assertNotNull(converterModule); }
@SuppressWarnings("unchecked") public static List<ConverterModule> load() { List<ConverterModule> modules = new ArrayList<>(); ClassLoader classLoader = ClassUtils.getDefaultClassLoader(); for (String klass : knownConverterModules) { try { Class<? extends ConverterModule> module = (Class<? extends ConverterModule>) classLoader.loadClass(klass); try { modules.add(module.newInstance()); } catch (Exception e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { } catch (ClassCastException e) { } } return modules; }
KnownConverterModuleLoader { @SuppressWarnings("unchecked") public static List<ConverterModule> load() { List<ConverterModule> modules = new ArrayList<>(); ClassLoader classLoader = ClassUtils.getDefaultClassLoader(); for (String klass : knownConverterModules) { try { Class<? extends ConverterModule> module = (Class<? extends ConverterModule>) classLoader.loadClass(klass); try { modules.add(module.newInstance()); } catch (Exception e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { } catch (ClassCastException e) { } } return modules; } }
KnownConverterModuleLoader { @SuppressWarnings("unchecked") public static List<ConverterModule> load() { List<ConverterModule> modules = new ArrayList<>(); ClassLoader classLoader = ClassUtils.getDefaultClassLoader(); for (String klass : knownConverterModules) { try { Class<? extends ConverterModule> module = (Class<? extends ConverterModule>) classLoader.loadClass(klass); try { modules.add(module.newInstance()); } catch (Exception e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { } catch (ClassCastException e) { } } return modules; }  }
KnownConverterModuleLoader { @SuppressWarnings("unchecked") public static List<ConverterModule> load() { List<ConverterModule> modules = new ArrayList<>(); ClassLoader classLoader = ClassUtils.getDefaultClassLoader(); for (String klass : knownConverterModules) { try { Class<? extends ConverterModule> module = (Class<? extends ConverterModule>) classLoader.loadClass(klass); try { modules.add(module.newInstance()); } catch (Exception e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { } catch (ClassCastException e) { } } return modules; }  @SuppressWarnings("unchecked") static List<ConverterModule> load(); }
KnownConverterModuleLoader { @SuppressWarnings("unchecked") public static List<ConverterModule> load() { List<ConverterModule> modules = new ArrayList<>(); ClassLoader classLoader = ClassUtils.getDefaultClassLoader(); for (String klass : knownConverterModules) { try { Class<? extends ConverterModule> module = (Class<? extends ConverterModule>) classLoader.loadClass(klass); try { modules.add(module.newInstance()); } catch (Exception e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { } catch (ClassCastException e) { } } return modules; }  @SuppressWarnings("unchecked") static List<ConverterModule> load();  }