@@ -180,7 +180,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
} | |||
@Override | |||
public String loadPlugin(Path pluginPath) throws PluginException { | |||
public String loadPlugin(Path pluginPath) { | |||
if ((pluginPath == null) || Files.notExists(pluginPath)) { | |||
throw new IllegalArgumentException(String.format("Specified plugin %s does not exist!", pluginPath)); | |||
} | |||
@@ -222,7 +222,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
for (Path pluginPath : pluginPaths) { | |||
try { | |||
loadPluginFromPath(pluginPath); | |||
} catch (PluginException e) { | |||
} catch (PluginRuntimeException e) { | |||
log.error(e.getMessage(), e); | |||
} | |||
} | |||
@@ -230,7 +230,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
// resolve plugins | |||
try { | |||
resolvePlugins(); | |||
} catch (PluginException e) { | |||
} catch (PluginRuntimeException e) { | |||
log.error(e.getMessage(), e); | |||
} | |||
} | |||
@@ -239,11 +239,11 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
* Unload the specified plugin and it's dependents. | |||
*/ | |||
@Override | |||
public boolean unloadPlugin(String pluginId) throws PluginException { | |||
public boolean unloadPlugin(String pluginId) { | |||
return unloadPlugin(pluginId, true); | |||
} | |||
private boolean unloadPlugin(String pluginId, boolean unloadDependents) throws PluginException { | |||
private boolean unloadPlugin(String pluginId, boolean unloadDependents) { | |||
try { | |||
if (unloadDependents) { | |||
List<String> dependents = dependencyResolver.getDependents(pluginId); | |||
@@ -276,7 +276,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
try { | |||
((Closeable) classLoader).close(); | |||
} catch (IOException e) { | |||
throw new PluginException("Cannot close classloader", e); | |||
throw new PluginRuntimeException(e, "Cannot close classloader"); | |||
} | |||
} | |||
} | |||
@@ -290,7 +290,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
} | |||
@Override | |||
public boolean deletePlugin(String pluginId) throws PluginException { | |||
public boolean deletePlugin(String pluginId) { | |||
checkPluginId(pluginId); | |||
PluginWrapper pluginWrapper = getPlugin(pluginId); | |||
@@ -344,7 +344,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
* Start the specified plugin and its dependencies. | |||
*/ | |||
@Override | |||
public PluginState startPlugin(String pluginId) throws PluginException { | |||
public PluginState startPlugin(String pluginId) { | |||
checkPluginId(pluginId); | |||
PluginWrapper pluginWrapper = getPlugin(pluginId); | |||
@@ -400,7 +400,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
itr.remove(); | |||
firePluginStateEvent(new PluginStateEvent(this, pluginWrapper, pluginState)); | |||
} catch (PluginException e) { | |||
} catch (PluginRuntimeException e) { | |||
log.error(e.getMessage(), e); | |||
} | |||
} | |||
@@ -411,11 +411,11 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
* Stop the specified plugin and it's dependents. | |||
*/ | |||
@Override | |||
public PluginState stopPlugin(String pluginId) throws PluginException { | |||
public PluginState stopPlugin(String pluginId) { | |||
return stopPlugin(pluginId, true); | |||
} | |||
private PluginState stopPlugin(String pluginId, boolean stopDependents) throws PluginException { | |||
private PluginState stopPlugin(String pluginId, boolean stopDependents) { | |||
checkPluginId(pluginId); | |||
PluginWrapper pluginWrapper = getPlugin(pluginId); | |||
@@ -458,7 +458,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
} | |||
@Override | |||
public boolean disablePlugin(String pluginId) throws PluginException { | |||
public boolean disablePlugin(String pluginId) { | |||
checkPluginId(pluginId); | |||
PluginWrapper pluginWrapper = getPlugin(pluginId); | |||
@@ -484,7 +484,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
} | |||
@Override | |||
public boolean enablePlugin(String pluginId) throws PluginException { | |||
public boolean enablePlugin(String pluginId) { | |||
checkPluginId(pluginId); | |||
PluginWrapper pluginWrapper = getPlugin(pluginId); | |||
@@ -560,7 +560,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
for (ExtensionWrapper extensionWrapper : extensionsWrapper) { | |||
try { | |||
extensions.add(extensionWrapper.getExtension()); | |||
} catch (PluginException e) { | |||
} catch (PluginRuntimeException e) { | |||
log.error("Cannot retrieve extension", e); | |||
} | |||
} | |||
@@ -732,7 +732,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
return pluginStatusProvider.isPluginDisabled(pluginId); | |||
} | |||
protected void resolvePlugins() throws PluginException { | |||
protected void resolvePlugins() { | |||
// retrieves the plugins descriptors | |||
List<PluginDescriptor> descriptors = new ArrayList<>(); | |||
for (PluginWrapper plugin : plugins.values()) { | |||
@@ -781,7 +781,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
} | |||
} | |||
protected PluginWrapper loadPluginFromPath(Path pluginPath) throws PluginException { | |||
protected PluginWrapper loadPluginFromPath(Path pluginPath) { | |||
// Test for plugin path duplication | |||
String pluginId = idForPath(pluginPath); | |||
if (pluginId != null) { | |||
@@ -799,7 +799,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
pluginId = pluginDescriptor.getPluginId(); | |||
if (plugins.containsKey(pluginId)) { | |||
PluginWrapper loadedPlugin = getPlugin(pluginId); | |||
throw new PluginException("There is an already loaded plugin ({}) " | |||
throw new PluginRuntimeException("There is an already loaded plugin ({}) " | |||
+ "with the same id ({}) as the plugin at path '{}'. Simultaneous loading " | |||
+ "of plugins with the same PluginId is not currently supported.\n" | |||
+ "As a workaround you may include PluginVersion and PluginProvider " | |||
@@ -867,15 +867,15 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
* Override this to change the validation criteria. | |||
* | |||
* @param descriptor the plugin descriptor to validate | |||
* @throws PluginException if validation fails | |||
* @throws PluginRuntimeException if validation fails | |||
*/ | |||
protected void validatePluginDescriptor(PluginDescriptor descriptor) throws PluginException { | |||
protected void validatePluginDescriptor(PluginDescriptor descriptor) { | |||
if (StringUtils.isNullOrEmpty(descriptor.getPluginId())) { | |||
throw new PluginException("Field 'id' cannot be empty"); | |||
throw new PluginRuntimeException("Field 'id' cannot be empty"); | |||
} | |||
if (descriptor.getVersion() == null) { | |||
throw new PluginException("Field 'version' cannot be empty"); | |||
throw new PluginRuntimeException("Field 'version' cannot be empty"); | |||
} | |||
} | |||
@@ -925,7 +925,7 @@ public abstract class AbstractPluginManager implements PluginManager { | |||
for (ExtensionWrapper<T> extensionWrapper : extensionsWrapper) { | |||
try { | |||
extensions.add(extensionWrapper.getExtension()); | |||
} catch (PluginException e) { | |||
} catch (PluginRuntimeException e) { | |||
log.error("Cannot retrieve extension", e); | |||
} | |||
} |
@@ -86,7 +86,7 @@ public class BasePluginRepository implements PluginRepository { | |||
} | |||
@Override | |||
public boolean deletePluginPath(Path pluginPath) throws PluginException { | |||
public boolean deletePluginPath(Path pluginPath) { | |||
if (!filter.accept(pluginPath.toFile())) { | |||
return false; | |||
} | |||
@@ -97,7 +97,7 @@ public class BasePluginRepository implements PluginRepository { | |||
} catch (NoSuchFileException e) { | |||
return false; // Return false on not found to be compatible with previous API (#135) | |||
} catch (IOException e) { | |||
throw new PluginException(e); | |||
throw new PluginRuntimeException(e); | |||
} | |||
} | |||
@@ -57,7 +57,7 @@ public class CompoundPluginDescriptorFinder implements PluginDescriptorFinder { | |||
} | |||
@Override | |||
public PluginDescriptor find(Path pluginPath) throws PluginException { | |||
public PluginDescriptor find(Path pluginPath) { | |||
for (PluginDescriptorFinder finder : finders) { | |||
if (finder.isApplicable(pluginPath)) { | |||
log.debug("'{}' is applicable for plugin '{}'", finder, pluginPath); | |||
@@ -81,7 +81,7 @@ public class CompoundPluginDescriptorFinder implements PluginDescriptorFinder { | |||
} | |||
} | |||
throw new PluginException("No PluginDescriptorFinder for plugin '{}'", pluginPath); | |||
throw new PluginRuntimeException("No PluginDescriptorFinder for plugin '{}'", pluginPath); | |||
} | |||
} |
@@ -66,7 +66,7 @@ public class CompoundPluginRepository implements PluginRepository { | |||
} | |||
@Override | |||
public boolean deletePluginPath(Path pluginPath) throws PluginException { | |||
public boolean deletePluginPath(Path pluginPath) { | |||
for (PluginRepository repository : repositories) { | |||
if (repository.deletePluginPath(pluginPath)) { | |||
return true; |
@@ -32,12 +32,12 @@ public class DefaultExtensionFactory implements ExtensionFactory { | |||
* Creates an extension instance. | |||
*/ | |||
@Override | |||
public <T> T create(Class<T> extensionClass) throws PluginException { | |||
public <T> T create(Class<T> extensionClass) { | |||
log.debug("Create instance for extension '{}'", extensionClass.getName()); | |||
try { | |||
return extensionClass.newInstance(); | |||
} catch (Exception e) { | |||
throw new PluginException(e); | |||
throw new PluginRuntimeException(e); | |||
} | |||
} | |||
@@ -111,13 +111,14 @@ public class DefaultPluginManager extends AbstractPluginManager { | |||
} | |||
/** | |||
* Load a plugin from disk. If the path is a zip file, first unpack | |||
* Load a plugin from disk. If the path is a zip file, first unpack. | |||
* | |||
* @param pluginPath plugin location on disk | |||
* @return PluginWrapper for the loaded plugin or null if not loaded | |||
* @throws PluginException if problems during load | |||
* @throws PluginRuntimeException if problems during load | |||
*/ | |||
@Override | |||
protected PluginWrapper loadPluginFromPath(Path pluginPath) throws PluginException { | |||
protected PluginWrapper loadPluginFromPath(Path pluginPath) { | |||
// First unzip any ZIP files | |||
try { | |||
pluginPath = FileUtils.expandIfZip(pluginPath); |
@@ -24,7 +24,6 @@ import org.pf4j.util.OrFileFilter; | |||
import org.pf4j.util.ZipFileFilter; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.pf4j.util.NameFileFilter; | |||
import java.io.File; | |||
import java.io.FileFilter; | |||
@@ -54,7 +53,7 @@ public class DefaultPluginRepository extends BasePluginRepository { | |||
} | |||
@Override | |||
public boolean deletePluginPath(Path pluginPath) throws PluginException { | |||
public boolean deletePluginPath(Path pluginPath) { | |||
FileUtils.optimisticDelete(FileUtils.findWithEnding(pluginPath, ".zip", ".ZIP", ".Zip")); | |||
return super.deletePluginPath(pluginPath); | |||
} |
@@ -66,22 +66,22 @@ public class DefaultPluginStatusProvider implements PluginStatusProvider { | |||
} | |||
@Override | |||
public void disablePlugin(String pluginId) throws PluginException { | |||
public void disablePlugin(String pluginId) { | |||
disabledPlugins.add(pluginId); | |||
try { | |||
FileUtils.writeLines(disabledPlugins, pluginsRoot.resolve("disabled.txt").toFile()); | |||
} catch (IOException e) { | |||
throw new PluginException(e); | |||
throw new PluginRuntimeException(e); | |||
} | |||
} | |||
@Override | |||
public void enablePlugin(String pluginId) throws PluginException { | |||
public void enablePlugin(String pluginId) { | |||
disabledPlugins.remove(pluginId); | |||
try { | |||
FileUtils.writeLines(disabledPlugins, pluginsRoot.resolve("disabled.txt").toFile()); | |||
} catch (IOException e) { | |||
throw new PluginException(e); | |||
throw new PluginRuntimeException(e); | |||
} | |||
} | |||
@@ -272,7 +272,7 @@ public class DependencyResolver { | |||
/** | |||
* It will be thrown if a cyclic dependency is detected. | |||
*/ | |||
public static class CyclicDependencyException extends PluginException { | |||
public static class CyclicDependencyException extends PluginRuntimeException { | |||
public CyclicDependencyException() { | |||
super("Cyclic dependencies"); | |||
@@ -283,7 +283,7 @@ public class DependencyResolver { | |||
/** | |||
* Indicates that the dependencies required were not found. | |||
*/ | |||
public static class DependenciesNotFoundException extends PluginException { | |||
public static class DependenciesNotFoundException extends PluginRuntimeException { | |||
private List<String> dependencies; | |||
@@ -302,7 +302,7 @@ public class DependencyResolver { | |||
/** | |||
* Indicates that some dependencies have wrong version. | |||
*/ | |||
public static class DependenciesWrongVersionException extends PluginException { | |||
public static class DependenciesWrongVersionException extends PluginRuntimeException { | |||
private List<WrongDependencyVersion> dependencies; | |||
@@ -20,6 +20,6 @@ package org.pf4j; | |||
*/ | |||
public interface ExtensionFactory { | |||
<T> T create(Class<T> extensionClass) throws PluginException; | |||
<T> T create(Class<T> extensionClass); | |||
} |
@@ -32,7 +32,7 @@ public class ExtensionWrapper<T> implements Comparable<ExtensionWrapper<T>> { | |||
} | |||
@SuppressWarnings("unchecked") | |||
public T getExtension() throws PluginException { | |||
public T getExtension() { | |||
if (extension == null) { | |||
extension = (T) extensionFactory.create(descriptor.extensionClass); | |||
} |
@@ -52,13 +52,13 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder { | |||
} | |||
@Override | |||
public PluginDescriptor find(Path pluginPath) throws PluginException { | |||
public PluginDescriptor find(Path pluginPath) { | |||
Manifest manifest = readManifest(pluginPath); | |||
return createPluginDescriptor(manifest); | |||
} | |||
protected Manifest readManifest(Path pluginPath) throws PluginException { | |||
protected Manifest readManifest(Path pluginPath) { | |||
if (FileUtils.isJarFile(pluginPath)) { | |||
try (JarFile jar = new JarFile(pluginPath.toFile())) { | |||
Manifest manifest = jar.getManifest(); | |||
@@ -66,24 +66,24 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder { | |||
return manifest; | |||
} | |||
} catch (IOException e) { | |||
throw new PluginException(e); | |||
throw new PluginRuntimeException(e); | |||
} | |||
} | |||
Path manifestPath = getManifestPath(pluginPath); | |||
if (manifestPath == null) { | |||
throw new PluginException("Cannot find the manifest path"); | |||
throw new PluginRuntimeException("Cannot find the manifest path"); | |||
} | |||
log.debug("Lookup plugin descriptor in '{}'", manifestPath); | |||
if (Files.notExists(manifestPath)) { | |||
throw new PluginException("Cannot find '{}' path", manifestPath); | |||
throw new PluginRuntimeException("Cannot find '{}' path", manifestPath); | |||
} | |||
try (InputStream input = Files.newInputStream(manifestPath)) { | |||
return new Manifest(input); | |||
} catch (IOException e) { | |||
throw new PluginException(e); | |||
throw new PluginRuntimeException(e); | |||
} | |||
} | |||
@@ -60,21 +60,21 @@ public class Plugin { | |||
* This method is called by the application when the plugin is started. | |||
* See {@link PluginManager#startPlugin(String)}. | |||
*/ | |||
public void start() throws PluginException { | |||
public void start() { | |||
} | |||
/** | |||
* This method is called by the application when the plugin is stopped. | |||
* See {@link PluginManager#stopPlugin(String)}. | |||
*/ | |||
public void stop() throws PluginException { | |||
public void stop() { | |||
} | |||
/** | |||
* This method is called by the application when the plugin is deleted. | |||
* See {@link PluginManager#deletePlugin(String)}. | |||
*/ | |||
public void delete() throws PluginException { | |||
public void delete() { | |||
} | |||
} |
@@ -20,7 +20,7 @@ import java.nio.file.Path; | |||
/** | |||
* @author Decebal Suiu | |||
*/ | |||
public class PluginAlreadyLoadedException extends PluginException { | |||
public class PluginAlreadyLoadedException extends PluginRuntimeException { | |||
private final String pluginId; | |||
private final Path pluginPath; |
@@ -29,12 +29,9 @@ public interface PluginDescriptorFinder { | |||
/** | |||
* Returns true if this finder is applicable to the given {@link Path}. | |||
* | |||
* @param pluginPath | |||
* @return | |||
*/ | |||
boolean isApplicable(Path pluginPath); | |||
PluginDescriptor find(Path pluginPath) throws PluginException; | |||
PluginDescriptor find(Path pluginPath); | |||
} |
@@ -69,11 +69,10 @@ public interface PluginManager { | |||
* Load a plugin. | |||
* | |||
* @param pluginPath the plugin location | |||
* @return the pluginId of the installed plugin as specified in | |||
* its {@linkplain PluginDescriptor metadata} | |||
* @throws PluginException if load of plugin fails | |||
* @return the pluginId of the installed plugin as specified in its {@linkplain PluginDescriptor metadata} | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
String loadPlugin(Path pluginPath) throws PluginException; | |||
String loadPlugin(Path pluginPath); | |||
/** | |||
* Start all active plugins. | |||
@@ -84,8 +83,9 @@ public interface PluginManager { | |||
* Start the specified plugin and its dependencies. | |||
* | |||
* @return the plugin state | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
PluginState startPlugin(String pluginId) throws PluginException; | |||
PluginState startPlugin(String pluginId); | |||
/** | |||
* Stop all active plugins. | |||
@@ -96,40 +96,45 @@ public interface PluginManager { | |||
* Stop the specified plugin and its dependencies. | |||
* | |||
* @return the plugin state | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
PluginState stopPlugin(String pluginId) throws PluginException; | |||
PluginState stopPlugin(String pluginId); | |||
/** | |||
* Unload a plugin. | |||
* | |||
* @param pluginId the unique plugin identifier, specified in its metadata | |||
* @return true if the plugin was unloaded | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
boolean unloadPlugin(String pluginId) throws PluginException; | |||
boolean unloadPlugin(String pluginId); | |||
/** | |||
* Disables a plugin from being loaded. | |||
* | |||
* @param pluginId the unique plugin identifier, specified in its metadata | |||
* @return true if plugin is disabled | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
boolean disablePlugin(String pluginId) throws PluginException; | |||
boolean disablePlugin(String pluginId); | |||
/** | |||
* Enables a plugin that has previously been disabled. | |||
* | |||
* @param pluginId the unique plugin identifier, specified in its metadata | |||
* @return true if plugin is enabled | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
boolean enablePlugin(String pluginId) throws PluginException; | |||
boolean enablePlugin(String pluginId); | |||
/** | |||
* Deletes a plugin. | |||
* | |||
* @param pluginId the unique plugin identifier, specified in its metadata | |||
* @return true if the plugin was deleted | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
boolean deletePlugin(String pluginId) throws PluginException; | |||
boolean deletePlugin(String pluginId); | |||
ClassLoader getPluginClassLoader(String pluginId); | |||
@@ -195,7 +200,8 @@ public interface PluginManager { | |||
String getSystemVersion(); | |||
/** | |||
* Gets the path of the folder where plugins are installed | |||
* Gets the path of the folder where plugins are installed. | |||
* | |||
* @return Path of plugins root | |||
*/ | |||
Path getPluginsRoot(); |
@@ -38,7 +38,8 @@ public interface PluginRepository { | |||
* | |||
* @param pluginPath the plugin path | |||
* @return true if deleted | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
boolean deletePluginPath(Path pluginPath) throws PluginException; | |||
boolean deletePluginPath(Path pluginPath); | |||
} |
@@ -23,29 +23,25 @@ import org.pf4j.util.StringUtils; | |||
* | |||
* @author Decebal Suiu | |||
*/ | |||
public class PluginException extends Exception { | |||
public class PluginRuntimeException extends RuntimeException { | |||
public PluginException() { | |||
public PluginRuntimeException() { | |||
super(); | |||
} | |||
public PluginException(String message) { | |||
public PluginRuntimeException(String message) { | |||
super(message); | |||
} | |||
public PluginException(Throwable cause) { | |||
public PluginRuntimeException(Throwable cause) { | |||
super(cause); | |||
} | |||
public PluginException(String message, Throwable cause) { | |||
super(message, cause); | |||
} | |||
public PluginException(Throwable cause, String message, Object... args) { | |||
public PluginRuntimeException(Throwable cause, String message, Object... args) { | |||
super(StringUtils.format(message, args), cause); | |||
} | |||
public PluginException(String message, Object... args) { | |||
public PluginRuntimeException(String message, Object... args) { | |||
super(StringUtils.format(message, args)); | |||
} | |||
@@ -33,14 +33,16 @@ public interface PluginStatusProvider { | |||
* Disables a plugin from being loaded. | |||
* | |||
* @param pluginId the unique plugin identifier, specified in its metadata | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
void disablePlugin(String pluginId) throws PluginException; | |||
void disablePlugin(String pluginId); | |||
/** | |||
* Enables a plugin that has previously been disabled. | |||
* | |||
* @param pluginId the unique plugin identifier, specified in its metadata | |||
* @throws PluginRuntimeException if something goes wrong | |||
*/ | |||
void enablePlugin(String pluginId) throws PluginException; | |||
void enablePlugin(String pluginId); | |||
} |
@@ -63,34 +63,34 @@ public class PropertiesPluginDescriptorFinder implements PluginDescriptorFinder | |||
} | |||
@Override | |||
public PluginDescriptor find(Path pluginPath) throws PluginException { | |||
public PluginDescriptor find(Path pluginPath) { | |||
Properties properties = readProperties(pluginPath); | |||
return createPluginDescriptor(properties); | |||
} | |||
protected Properties readProperties(Path pluginPath) throws PluginException { | |||
protected Properties readProperties(Path pluginPath) { | |||
Path propertiesPath = getPropertiesPath(pluginPath, propertiesFileName); | |||
if (propertiesPath == null) { | |||
throw new PluginException("Cannot find the properties path"); | |||
throw new PluginRuntimeException("Cannot find the properties path"); | |||
} | |||
log.debug("Lookup plugin descriptor in '{}'", propertiesPath); | |||
if (Files.notExists(propertiesPath)) { | |||
throw new PluginException("Cannot find '{}' path", propertiesPath); | |||
throw new PluginRuntimeException("Cannot find '{}' path", propertiesPath); | |||
} | |||
Properties properties = new Properties(); | |||
try (InputStream input = Files.newInputStream(propertiesPath)) { | |||
properties.load(input); | |||
} catch (IOException e) { | |||
throw new PluginException(e); | |||
throw new PluginRuntimeException(e); | |||
} | |||
return properties; | |||
} | |||
protected Path getPropertiesPath(Path pluginPath, String propertiesFileName) throws PluginException { | |||
protected Path getPropertiesPath(Path pluginPath, String propertiesFileName) { | |||
if (Files.isDirectory(pluginPath)) { | |||
return pluginPath.resolve(Paths.get(propertiesFileName)); | |||
} else { | |||
@@ -98,7 +98,7 @@ public class PropertiesPluginDescriptorFinder implements PluginDescriptorFinder | |||
try { | |||
return FileUtils.getPath(pluginPath, propertiesFileName); | |||
} catch (IOException e) { | |||
throw new PluginException(e); | |||
throw new PluginRuntimeException(e); | |||
} | |||
} | |||
} |
@@ -40,7 +40,7 @@ public class SingletonExtensionFactory extends DefaultExtensionFactory { | |||
@Override | |||
@SuppressWarnings("unchecked") | |||
public <T> T create(Class<T> extensionClass) throws PluginException { | |||
public <T> T create(Class<T> extensionClass) { | |||
String extensionClassName = extensionClass.getName(); | |||
if (cache.containsKey(extensionClassName)) { | |||
return (T) cache.get(extensionClassName); |
@@ -87,7 +87,7 @@ public class CompoundPluginDescriptorFinderTest { | |||
@Test | |||
public void testNotFound() { | |||
PluginDescriptorFinder descriptorFinder = new CompoundPluginDescriptorFinder(); | |||
assertThrows(PluginException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3"))); | |||
assertThrows(PluginRuntimeException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3"))); | |||
} | |||
@Test |
@@ -45,7 +45,7 @@ public class DefaultExtensionFactoryTest { | |||
* Test of create method, of class DefaultExtensionFactory. | |||
*/ | |||
@Test | |||
public void testCreate() throws PluginException { | |||
public void testCreate() { | |||
assertNotNull(extensionFactory.create(TestExtension.class)); | |||
} | |||
@@ -54,7 +54,7 @@ public class DefaultExtensionFactoryTest { | |||
*/ | |||
@Test | |||
public void testCreateFailConstructor() { | |||
assertThrows(PluginException.class, () -> extensionFactory.create(FailTestExtension.class)); | |||
assertThrows(PluginRuntimeException.class, () -> extensionFactory.create(FailTestExtension.class)); | |||
} | |||
} |
@@ -65,24 +65,24 @@ public class DefaultPluginManagerTest { | |||
} | |||
@Test | |||
public void validateOK() throws PluginException { | |||
public void validateOK() { | |||
pluginManager.validatePluginDescriptor(pluginDescriptor); | |||
} | |||
@Test | |||
public void validateFailsOnId() { | |||
pluginDescriptor.setPluginId(""); | |||
assertThrows(PluginException.class, () -> pluginManager.validatePluginDescriptor(pluginDescriptor)); | |||
assertThrows(PluginRuntimeException.class, () -> pluginManager.validatePluginDescriptor(pluginDescriptor)); | |||
} | |||
@Test | |||
public void validateFailsOnVersion() { | |||
pluginDescriptor.setPluginVersion(null); | |||
assertThrows(PluginException.class, () -> pluginManager.validatePluginDescriptor(pluginDescriptor)); | |||
assertThrows(PluginRuntimeException.class, () -> pluginManager.validatePluginDescriptor(pluginDescriptor)); | |||
} | |||
@Test | |||
public void validateNoPluginClass() throws PluginException { | |||
public void validateNoPluginClass() { | |||
pluginManager.validatePluginDescriptor(pluginDescriptor); | |||
assertEquals(Plugin.class.getName(), pluginDescriptor.getPluginClass()); | |||
} |
@@ -67,7 +67,7 @@ public class DefaultPluginRepositoryTest { | |||
* Test of {@link DefaultPluginRepository#deletePluginPath(Path)} method. | |||
*/ | |||
@Test | |||
public void testDeletePluginPath() throws PluginException { | |||
public void testDeletePluginPath() { | |||
PluginRepository repository = new DefaultPluginRepository(pluginsPath); | |||
assertTrue(Files.exists(pluginsPath.resolve("plugin-1.zip"))); |
@@ -102,7 +102,7 @@ public class LoadPluginsTest { | |||
// Verify the second plugin is not loaded as it has the same metadata | |||
pluginManager.loadPluginFromPath(plugin2.path()); | |||
fail("Expected loadPluginFromPath to fail"); | |||
} catch (PluginException e) { | |||
} catch (PluginRuntimeException e) { | |||
// Check the path of the loaded plugin remains the same | |||
PluginWrapper loadedPlugin = pluginManager.getPlugin(pluginId); | |||
assertThat(loadedPlugin.getPluginPath(), equalTo(loadedPlugin1Path)); | |||
@@ -141,7 +141,7 @@ public class LoadPluginsTest { | |||
// Verify the second plugin is not loaded as it has the same pluginId | |||
pluginManager.loadPluginFromPath(plugin2.path()); | |||
fail("Expected loadPluginFromPath to fail"); | |||
} catch (PluginException e) { | |||
} catch (PluginRuntimeException e) { | |||
// Check the path and version of the loaded plugin remain the same | |||
PluginWrapper loadedPlugin = pluginManager.getPlugin(pluginId); | |||
assertThat(loadedPlugin.getPluginPath(), equalTo(loadedPlugin1Path)); |
@@ -107,7 +107,7 @@ public class ManifestPluginDescriptorFinderTest { | |||
@Test | |||
public void testFindNotFound() { | |||
PluginDescriptorFinder descriptorFinder = new ManifestPluginDescriptorFinder(); | |||
assertThrows(PluginException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3"))); | |||
assertThrows(PluginRuntimeException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3"))); | |||
} | |||
private Manifest getPlugin1Manifest() { |
@@ -104,7 +104,7 @@ public class PropertiesPluginDescriptorFinderTest { | |||
@Test | |||
public void testNotFound() { | |||
PluginDescriptorFinder descriptorFinder = new PropertiesPluginDescriptorFinder(); | |||
assertThrows(PluginException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3"))); | |||
assertThrows(PluginRuntimeException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3"))); | |||
} | |||
private Properties getPlugin1Properties() { |
@@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; | |||
public class SingletonExtensionFactoryTest { | |||
@Test | |||
public void create() throws PluginException { | |||
public void create() { | |||
ExtensionFactory extensionFactory = new SingletonExtensionFactory(); | |||
Object extensionOne = extensionFactory.create(TestExtension.class); | |||
Object extensionTwo = extensionFactory.create(TestExtension.class); | |||
@@ -36,7 +36,7 @@ public class SingletonExtensionFactoryTest { | |||
} | |||
@Test | |||
public void createNewEachTime() throws PluginException { | |||
public void createNewEachTime() { | |||
ExtensionFactory extensionFactory = new SingletonExtensionFactory(FailTestExtension.class.getName()); | |||
Object extensionOne = extensionFactory.create(TestExtension.class); | |||
Object extensionTwo = extensionFactory.create(TestExtension.class); |