@Override public RegistrationStrategy<E> get() { throw new PluginException("Class " + getModuleClassName() + " is not implementing extractor for comment, issue or change history"); } }, new Function<Map.Entry<Class<? extends EntitySearchExtractor>, RegistrationStrategy<?>>, RegistrationStrategy<E>>()
@Override public ModuleDescriptor<?> createModule(final Plugin plugin, final Element module, final ModuleDescriptorFactory moduleDescriptorFactory) { if (plugin instanceof UnloadablePlugin) { throw new PluginException("cannot create modules for an UnloadablePlugin"); } return null; } }
public void removePlugin(final Plugin plugin) throws PluginException { throw new PluginException("This PluginLoader does not support removal."); } }
@Override public ModuleDescriptor<?> createModule(final Plugin plugin, final Element module, final ModuleDescriptorFactory moduleDescriptorFactory) { if (plugin instanceof XmlDynamicPlugin) { // It is possible to implement this, however this plugin type is not widely used and has no test coverage. // If a use case emerges, we can revisit. throw new PluginException("cannot create modules for an XmlDynamicPlugin"); } return null; } }
@Override protected void uninstallInternal() { throw new PluginException("Static plugins cannot be uninstalled"); } }
public void removePlugin(final Plugin plugin) throws PluginException { throw new PluginException("This PluginLoader does not support removal."); }
private void handleSpringMethodInvocationError(final InvocationTargetException e) { if (e.getCause() instanceof Error) { throw (Error) e.getCause(); } else if (e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { // Should never happen as Spring methods only throw runtime exceptions throw new PluginException("Unable to invoke createBean", e.getCause()); } }
@Override public <T> T injectBean(T bean) { try { nativeAutowireBeanMethod.invoke(nativeBeanFactory, bean, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false); } catch (final IllegalAccessException e) { // Should never happen throw new PluginException("Unable to access autowireBeanProperties method", e); } catch (final InvocationTargetException e) { handleSpringMethodInvocationError(e); } return bean; }
private PluginLoader ensurePluginAndLoaderSupportsUninstall(final Plugin plugin) { if (!plugin.isUninstallable()) { throw new PluginException("Plugin is not uninstallable: " + plugin); } final PluginLoader loader = installedPluginsToPluginLoader.get(plugin); if ((loader != null) && !loader.supportsRemoval()) { throw new PluginException("Not uninstalling plugin - loader doesn't allow removal. Plugin: " + plugin); } return loader; }
public <T> Collection<T> getBeansOfType(Class<T> interfaceClass) { try { //noinspection unchecked Map<String, T> beans = (Map<String, T>) nativeGetBeansOfTypeMethod.invoke(nativeBeanFactory, interfaceClass); return beans.values(); } catch (final IllegalAccessException e) { // Should never happen throw new PluginException("Unable to access getBeansOfType method", e); } catch (final InvocationTargetException e) { handleSpringMethodInvocationError(e); return null; } }
public void remove(final DeploymentUnit unit) throws PluginException { throw new PluginException("Cannot remove files in a file-list scanner: " + unit.getPath()); } }
@Override public <T> T getBean(final String id) { try { //noinspection unchecked return (T) nativeGetBeanMethod.invoke(nativeBeanFactory, id); } catch (final IllegalAccessException e) { // Should never happen throw new PluginException("Unable to access getBean method", e); } catch (final InvocationTargetException e) { handleSpringMethodInvocationError(e); return null; } }
private DeploymentUnit findMatchingDeploymentUnit(final Plugin plugin) throws PluginException { DeploymentUnit deploymentUnit = null; for (final Map.Entry<DeploymentUnit, Plugin> entry : plugins.entrySet()) { // no, you don't want to use entry.getValue().equals(plugin) here as it breaks upgrades where it is a new // version of the plugin but the key and version number hasn't changed, and hence, equals() will always return // true if (entry.getValue() == plugin) { deploymentUnit = entry.getKey(); break; } } if (deploymentUnit == null) { throw new PluginException("This pluginLoader has no memory of deploying the plugin you are trying remove: [" + plugin.getName() + "]"); } return deploymentUnit; }
public AddProjectHook addProjectHook() { if (Strings.isNullOrEmpty(addProjectHookClass)) { return null; } Object module = moduleFactory.createModule(addProjectHookClass, moduleDescriptor); try { return (AddProjectHook) module; } catch (ClassCastException ex) { throw new PluginException("The class '" + addProjectHookClass + "' is not an instance of AddProjectHook.", ex); } } }
public <T> T createBean(final Class<T> clazz) { try { final int autowiringMode = useLegacyWiringAutodetectionMode ? resolveAutowiringMode(clazz) : AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR; return clazz.cast(nativeCreateBeanMethod.invoke(nativeBeanFactory, clazz, autowiringMode, false)); } catch (final IllegalAccessException e) { // Should never happen throw new PluginException("Unable to access createBean method", e); } catch (final InvocationTargetException e) { handleSpringMethodInvocationError(e); return null; } }
public void addResource(String path, String name) { try { ResourceDescriptor resource = resourceDescriptorFactory.createResource(plugin, name, path, Optional.empty()); addToResources(resource); } catch (FileNotFoundException e) { throw new PluginException(String.format("File for '%s' does not exist at location: %s", name, path)); } }
private void validateRequiredPlugins() throws PluginException { final RequiredPluginValidator validator = new DefaultRequiredPluginValidator(this, new ClasspathFilePluginMetadata()); final Collection<String> errors = validator.validate(); if (errors.size() > 0) { log.error("Unable to validate required plugins or modules - plugin system shutting down"); log.error("Failures:"); for (final String error : errors) { log.error("\t{}", error); } shutdown(); throw new PluginException("Unable to validate required plugins or modules"); } }
public void enabled() { if (log.isDebugEnabled()) { log.debug(String.format("Plugin '%s' is attempting to register workflow module '%s'.", getKey(), implementationClassName)); } try { implementationClass = getPlugin().loadClass(implementationClassName, getClass()); } catch (final ClassNotFoundException ex) { throw new PluginException("Cannot load condition class '" + implementationClassName + "'. " + ex.getMessage()); } // Load the implementation class now that the OSGi bundle will be available super.enabled(); registerWorkflowTypeResolver(); }
public void unregisterComponents(final MutablePicoContainer container) { // Check that we have classloaded the interface if required. if (interfaceClazzName != null && interfaceClazz == null) { throw new PluginException("Cannot unregister component '" + interfaceClazzName + "' in plugin '" + getKey() + "' because we haven't loaded the class. This means that this plugin has not been successfully enabled."); } if (container.getComponentAdapter(interfaceClazz) != null) { container.removeComponent(interfaceClazz); } // TODO: Should this be in an else clause? It is probably harmless, but also pointless. container.removeComponent(getModuleClass()); } }
@Override public void removeDynamicModule(final Plugin maybePluginInternal, final ModuleDescriptor<?> module) { final PluginInternal plugin = checkPluginInternal(maybePluginInternal); // remove from the plugin if (!plugin.removeDynamicModuleDescriptor(module)) { throw new PluginException("cannot remove dynamic module '" + module.getKey() + "' from plugin '" + plugin + "' as it wasn't added by addDynamicModule"); } // disable it persistentStateModifier.disable(module); notifyModuleDisabled(module); // destroy it module.destroy(); }