@Test public void load() throws Exception { Configuration conf = new Configuration(); RuntimeResourceManager manager = new RuntimeResourceManager(conf); List<RuntimeResource> loaded = manager.load(); boolean found = false; for (RuntimeResource resource : loaded) { if (resource instanceof LegacyReport.Initializer) { found = true; break; } } assertThat(found, is(true)); }
protected List<RuntimeResource> load() throws IOException { List<RuntimeResource> results = new ArrayList<>(); ClassLoader loader = configuration.getClassLoader(); try { for (RuntimeResource resource : ServiceLoader.load(RuntimeResource.class, loader)) { if (resource instanceof Configurable) { ((Configurable) resource).setConf(configuration.getConf()); } results.add(resource); } } catch (RuntimeException e) { throw new IOException(MessageFormat.format( "Failed to load resources ({0})", RuntimeResource.class.getName()), e); } return results; }
RuntimeResourceManager extends Configured { protected List<RuntimeResource> load() throws IOException { List<RuntimeResource> results = new ArrayList<>(); ClassLoader loader = configuration.getClassLoader(); try { for (RuntimeResource resource : ServiceLoader.load(RuntimeResource.class, loader)) { if (resource instanceof Configurable) { ((Configurable) resource).setConf(configuration.getConf()); } results.add(resource); } } catch (RuntimeException e) { throw new IOException(MessageFormat.format( "Failed to load resources ({0})", RuntimeResource.class.getName()), e); } return results; } }
RuntimeResourceManager extends Configured { protected List<RuntimeResource> load() throws IOException { List<RuntimeResource> results = new ArrayList<>(); ClassLoader loader = configuration.getClassLoader(); try { for (RuntimeResource resource : ServiceLoader.load(RuntimeResource.class, loader)) { if (resource instanceof Configurable) { ((Configurable) resource).setConf(configuration.getConf()); } results.add(resource); } } catch (RuntimeException e) { throw new IOException(MessageFormat.format( "Failed to load resources ({0})", RuntimeResource.class.getName()), e); } return results; } RuntimeResourceManager(Configuration configuration); }
RuntimeResourceManager extends Configured { protected List<RuntimeResource> load() throws IOException { List<RuntimeResource> results = new ArrayList<>(); ClassLoader loader = configuration.getClassLoader(); try { for (RuntimeResource resource : ServiceLoader.load(RuntimeResource.class, loader)) { if (resource instanceof Configurable) { ((Configurable) resource).setConf(configuration.getConf()); } results.add(resource); } } catch (RuntimeException e) { throw new IOException(MessageFormat.format( "Failed to load resources ({0})", RuntimeResource.class.getName()), e); } return results; } RuntimeResourceManager(Configuration configuration); void setup(); void cleanup(); }
RuntimeResourceManager extends Configured { protected List<RuntimeResource> load() throws IOException { List<RuntimeResource> results = new ArrayList<>(); ClassLoader loader = configuration.getClassLoader(); try { for (RuntimeResource resource : ServiceLoader.load(RuntimeResource.class, loader)) { if (resource instanceof Configurable) { ((Configurable) resource).setConf(configuration.getConf()); } results.add(resource); } } catch (RuntimeException e) { throw new IOException(MessageFormat.format( "Failed to load resources ({0})", RuntimeResource.class.getName()), e); } return results; } RuntimeResourceManager(Configuration configuration); void setup(); void cleanup(); static final String CONFIGURATION_FILE_NAME; static final String CONFIGURATION_FILE_PATH; }