@Override public void handle(IAsyncResult<Void> result) { if (result.isError()) { System.err.println("Error " + result.getError()); throw new RuntimeException(result.getError()); } }
/** Load a config class */ @SuppressWarnings("unchecked") private <T> Class<? extends T> loadConfigClass( String property, Class<T> type, IPluginRegistry pluginRegistry, Class<? extends T> defaultClass) { String componentSpec = getConfig().getString(property); if (componentSpec == null) { return defaultClass; } try { if (componentSpec.startsWith("class:")) { // $NON-NLS-1$ Class<?> c = ReflectionUtils.loadClass(componentSpec.substring("class:".length())); // $NON-NLS-1$ return (Class<T>) c; } else if (componentSpec.startsWith("plugin:")) { // $NON-NLS-1$ PluginCoordinates coordinates = PluginCoordinates.fromPolicySpec(componentSpec); if (coordinates == null) { throw new IllegalArgumentException( "Invalid plugin component spec: " + componentSpec); // $NON-NLS-1$ } int ssidx = componentSpec.indexOf('/'); if (ssidx == -1) { throw new IllegalArgumentException( "Invalid plugin component spec: " + componentSpec); // $NON-NLS-1$ } String classname = componentSpec.substring(ssidx + 1); Future<IAsyncResult<Plugin>> pluginF = pluginRegistry.loadPlugin(coordinates, null); IAsyncResult<Plugin> pluginR = pluginF.get(); if (pluginR.isError()) { throw new RuntimeException(pluginR.getError()); } Plugin plugin = pluginR.getResult(); PluginClassLoader classLoader = plugin.getLoader(); Class<?> class1 = classLoader.loadClass(classname); return (Class<T>) class1; } else { Class<?> c = ReflectionUtils.loadClass(componentSpec); return (Class<T>) c; } } catch (ClassNotFoundException | InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }