/** * Constructor. * @param spec the plugin's specification * @param coordinates the plugin's coordinates * @param loader the plugin's classloader */ public Plugin(PluginSpec spec, PluginCoordinates coordinates, PluginClassLoader loader) { setSpec(spec); setCoordinates(coordinates); setLoader(loader); }
PluginClassLoader classLoader = plugin.getLoader(); Class<?> class1 = classLoader.loadClass(classname); return (Class<T>) class1;
try { plugin = pluginRegistry.loadPlugin(coordinates); bean.setName(plugin.getName()); bean.setDescription(plugin.getDescription()); } catch (InvalidPluginException e) { throw new PluginNotFoundException(coordinates.toString(), e); List<URL> policyDefs = plugin.getPolicyDefinitions(); int createdPolicyDefCounter = 0; int updatedPolicyDefCounter = 0;
/** * Reads the plugin into an object. This method will fail if the plugin is not valid. * This could happen if the file is not a java archive, or if the plugin spec file is * missing from the archive, etc. */ protected Plugin readPluginFile(PluginCoordinates coordinates, File pluginFile) throws Exception { try { PluginClassLoader pluginClassLoader = createPluginClassLoader(pluginFile); URL specFile = pluginClassLoader.getResource(PluginUtils.PLUGIN_SPEC_PATH); if (specFile == null) { throw new Exception(Messages.i18n.format("DefaultPluginRegistry.MissingPluginSpecFile", PluginUtils.PLUGIN_SPEC_PATH)); //$NON-NLS-1$ } else { PluginSpec spec = PluginUtils.readPluginSpecFile(specFile); Plugin plugin = new Plugin(spec, coordinates, pluginClassLoader); // TODO use logger when available System.out.println("Read apiman plugin: " + spec); //$NON-NLS-1$ return plugin; } } catch (Exception e) { throw new Exception(Messages.i18n.format("DefaultPluginRegistry.InvalidPlugin", pluginFile.getAbsolutePath()), e); //$NON-NLS-1$ } }
PluginClassLoader classLoader = plugin.getLoader(); Class<?> class1 = classLoader.loadClass(classname); return (Class<T>) class1;
try { plugin = pluginRegistry.loadPlugin(coordinates); bean.setName(plugin.getName()); bean.setDescription(plugin.getDescription()); } catch (InvalidPluginException e) { throw new PluginNotFoundException(coordinates.toString(), e); List<URL> policyDefs = plugin.getPolicyDefinitions(); int createdPolicyDefCounter = 0; int updatedPolicyDefCounter = 0;
/** * Reads the plugin into an object. This method will fail if the plugin is not valid. * This could happen if the file is not a java archive, or if the plugin spec file is * missing from the archive, etc. */ protected Plugin readPluginFile(PluginCoordinates coordinates, File pluginFile) throws Exception { try { PluginClassLoader pluginClassLoader = createPluginClassLoader(pluginFile); URL specFile = pluginClassLoader.getResource(PluginUtils.PLUGIN_SPEC_PATH); if (specFile == null) { throw new Exception(Messages.i18n.format("DefaultPluginRegistry.MissingPluginSpecFile", PluginUtils.PLUGIN_SPEC_PATH)); //$NON-NLS-1$ } else { PluginSpec spec = PluginUtils.readPluginSpecFile(specFile); Plugin plugin = new Plugin(spec, coordinates, pluginClassLoader); // TODO use logger when available System.out.println("Read apiman plugin: " + spec); //$NON-NLS-1$ return plugin; } } catch (Exception e) { throw new Exception(Messages.i18n.format("DefaultPluginRegistry.InvalidPlugin", pluginFile.getAbsolutePath()), e); //$NON-NLS-1$ } }
PluginClassLoader classLoader = plugin.getLoader(); Class<?> class1 = classLoader.loadClass(classname); return (Class<T>) class1;
/** * Constructor. * @param spec the plugin's specification * @param coordinates the plugin's coordinates * @param loader the plugin's classloader */ public Plugin(PluginSpec spec, PluginCoordinates coordinates, PluginClassLoader loader) { setSpec(spec); setCoordinates(coordinates); setLoader(loader); }
PluginClassLoader classLoader = plugin.getLoader(); Class<?> class1 = classLoader.loadClass(classname); return createCustomComponent(componentType, class1, configProperties);
@Override public void handle(IAsyncResult<Plugin> result) { if (result.isSuccess()) { IPolicy rval; Plugin plugin = result.getResult(); PluginClassLoader pluginClassLoader = plugin.getLoader(); ClassLoader oldCtxLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(pluginClassLoader); Class<?> c = pluginClassLoader.loadClass(classname); rval = (IPolicy) c.newInstance(); } catch (Exception e) { handler.handle(AsyncResultImpl.<IPolicy>create(new PolicyNotFoundException(policyImpl, e))); return; } finally { Thread.currentThread().setContextClassLoader(oldCtxLoader); } policyCache.put(policyImpl, rval); handler.handle(AsyncResultImpl.create(rval)); } else { handler.handle(AsyncResultImpl.<IPolicy>create(new PolicyNotFoundException(policyImpl, result.getError()))); } } });
@Override public void handle(IAsyncResult<Plugin> result) { if (result.isSuccess()) { IPolicy rval; Plugin plugin = result.getResult(); PluginClassLoader pluginClassLoader = plugin.getLoader(); ClassLoader oldCtxLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(pluginClassLoader); Class<?> c = pluginClassLoader.loadClass(classname); rval = (IPolicy) c.newInstance(); } catch (Exception e) { handler.handle(AsyncResultImpl.<IPolicy>create(new PolicyNotFoundException(policyImpl, e))); return; } finally { Thread.currentThread().setContextClassLoader(oldCtxLoader); } policyCache.put(policyImpl, rval); handler.handle(AsyncResultImpl.create(rval)); } else { handler.handle(AsyncResultImpl.<IPolicy>create(new PolicyNotFoundException(policyImpl, result.getError()))); } } });
try { result.getResult().getLoader().close(); } catch (IOException e) {} result = AsyncResultImpl.create(pluginCache.get(coordinates)); } else {
try { result.getResult().getLoader().close(); } catch (IOException e) {} result = AsyncResultImpl.create(pluginCache.get(coordinates)); } else {
PluginClassLoader loader = plugin.getLoader(); InputStream resource = null; try {
PluginClassLoader loader = plugin.getLoader(); InputStream resource = null; try {