Browse Source

Extract constants for some system property namse

tags/release-3.0.0
decebals 5 years ago
parent
commit
73ac9c0d2b

+ 4
- 2
pf4j/src/main/java/org/pf4j/AbstractPluginManager.java View File



private static final Logger log = LoggerFactory.getLogger(AbstractPluginManager.class); private static final Logger log = LoggerFactory.getLogger(AbstractPluginManager.class);


public static final String PLUGINS_DIR_PROPERTY_NAME = "pf4j.pluginsDir";

private Path pluginsRoot; private Path pluginsRoot;


protected ExtensionFinder extensionFinder; protected ExtensionFinder extensionFinder;


/** /**
* Add the possibility to override the plugins root. * Add the possibility to override the plugins root.
* If a {@code pf4j.pluginsDir} system property is defined than this method returns that root.
* If a {@link #PLUGINS_DIR_PROPERTY_NAME} system property is defined than this method returns that root.
* If {@link #getRuntimeMode()} returns {@link RuntimeMode#DEVELOPMENT} than {@code ../plugins} * If {@link #getRuntimeMode()} returns {@link RuntimeMode#DEVELOPMENT} than {@code ../plugins}
* is returned else this method returns {@code plugins}. * is returned else this method returns {@code plugins}.
* *
* @return the plugins root * @return the plugins root
*/ */
protected Path createPluginsRoot() { protected Path createPluginsRoot() {
String pluginsDir = System.getProperty("pf4j.pluginsDir");
String pluginsDir = System.getProperty(PLUGINS_DIR_PROPERTY_NAME);
if (pluginsDir == null) { if (pluginsDir == null) {
if (isDevelopment()) { if (isDevelopment()) {
pluginsDir = "../plugins"; pluginsDir = "../plugins";

+ 5
- 4
pf4j/src/main/java/org/pf4j/DefaultPluginManager.java View File



private static final Logger log = LoggerFactory.getLogger(DefaultPluginManager.class); private static final Logger log = LoggerFactory.getLogger(DefaultPluginManager.class);


public static final String PLUGINS_DIR_CONFIG_PROPERTY_NAME = "pf4j.pluginsConfigDir";

protected PluginClasspath pluginClasspath; protected PluginClasspath pluginClasspath;


public DefaultPluginManager() { public DefaultPluginManager() {


@Override @Override
protected PluginStatusProvider createPluginStatusProvider() { protected PluginStatusProvider createPluginStatusProvider() {
String configDir = System.getProperty("pf4j.pluginsConfigDir");
String configDir = System.getProperty(PLUGINS_DIR_CONFIG_PROPERTY_NAME);
Path configPath = configDir != null ? Paths.get(configDir) : getPluginsRoot(); Path configPath = configDir != null ? Paths.get(configDir) : getPluginsRoot();
return new DefaultPluginStatusProvider(configPath); return new DefaultPluginStatusProvider(configPath);
} }
} }


/** /**
* By default if {@link DefaultPluginManager#isDevelopment()} returns true
* than a {@link DevelopmentPluginClasspath} is returned
* else this method returns {@link DefaultPluginClasspath}.
* By default if {@link #isDevelopment()} returns {@code true} than a {@link DevelopmentPluginClasspath}
* is returned, else this method returns {@link DefaultPluginClasspath}.
*/ */
protected PluginClasspath createPluginClasspath() { protected PluginClasspath createPluginClasspath() {
return isDevelopment() ? new DevelopmentPluginClasspath() : new DefaultPluginClasspath(); return isDevelopment() ? new DevelopmentPluginClasspath() : new DefaultPluginClasspath();

Loading…
Cancel
Save