Class PluginResourceLoader
java.lang.Object
org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader
- All Implemented Interfaces:
org.pentaho.platform.api.engine.IPluginResourceLoader
public class PluginResourceLoader
extends Object
implements org.pentaho.platform.api.engine.IPluginResourceLoader
The default implementation of the
IPluginResourceLoader
. Obtains resources by searching the root directory of
a PluginClassLoader
.
Resource discovery
PluginResourceLoader
will search the following places for plugin classes:
- the /lib folder under the plugin's root directory, e.g. "myplugin/lib"
PluginResourceLoader
will search for non-class resources in several locations:
- inside jar files located in the lib directory
- from the filesystem relative to the root directory of the plugin
resourcePath
This class requires resource paths to be the relative paths to plugin resources, relative the root directory of the plugin. A resource path can be specified either using '/' or '.' (or both) in the path, depending on the particular method you are using. It is usually best to specify the path using '/' since both the filesystem and the classloader can handle this delimiter, whereas '.' will not be handled correctly if you are trying to load a resource from the filesystem.Plugin Settings
This class backs the plugin settings APIs with the PentahoSystem settings service. SeePentahoSystem.getSystemSetting(String, String)
and ISystemSettings
. System settings are expected in a
file named settings.xml in the root of the plugin directory.- Author:
- aphillips
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfindResources
(Class<?> clazz, String namePattern) findResources
(ClassLoader classLoader, String namePattern) protected ClassLoader
getClassLoader
(Class<?> clazz) protected PluginClassLoader
protected File
getPluginDir
(ClassLoader classLoader) getPluginSetting
(Class<?> pluginClass, String key) getPluginSetting
(Class<?> pluginClass, String key, String defaultVal) getPluginSetting
(ClassLoader classLoader, String key, String defaultVal) byte[]
getResourceAsBytes
(Class<? extends Object> clazz, String resourcePath) getResourceAsStream
(Class<?> clazz, String resourcePath) getResourceAsStream
(ClassLoader classLoader, String resourcePath) getResourceAsString
(Class<? extends Object> clazz, String resourcePath) getResourceAsString
(Class<? extends Object> clazz, String resourcePath, String charsetName) getResourceBundle
(Class<?> clazz, String resourcePath) getSystemRelativePluginPath
(ClassLoader classLoader) void
setOverrideClassloader
(PluginClassLoader pluginClassloader) Deprecated.void
setRootDir
(File rootDir) Deprecated.void
setSettingsPath
(String settingsPath)
-
Constructor Details
-
PluginResourceLoader
public PluginResourceLoader()
-
-
Method Details
-
setSettingsPath
-
setOverrideClassloader
Deprecated. -
getOverrideClassloader
-
setRootDir
Deprecated.instead of setting the root dir, have your application use a subclass of PluginResourceLoader that returns an appropriately pathed PluginClassLoader from an overriddengetClassLoader(Class)
.Force the resource loader to look for resources in this root directory. If null, the resource loader will consult thePluginClassLoader
for the root directory.- Parameters:
rootDir
- the root directory in which to search for resources
-
getResourceAsBytes
- Specified by:
getResourceAsBytes
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
getResourceAsString
public String getResourceAsString(Class<? extends Object> clazz, String resourcePath) throws UnsupportedEncodingException - Specified by:
getResourceAsString
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
- Throws:
UnsupportedEncodingException
-
getResourceAsString
public String getResourceAsString(Class<? extends Object> clazz, String resourcePath, String charsetName) throws UnsupportedEncodingException - Specified by:
getResourceAsString
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
- Throws:
UnsupportedEncodingException
-
getSystemRelativePluginPath
-
getPluginDir
-
getClassLoader
-
getResourceAsStream
- Specified by:
getResourceAsStream
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
getResourceAsStream
- Specified by:
getResourceAsStream
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
findResources
- Specified by:
findResources
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
findResources
- Specified by:
findResources
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
getResourceBundle
- Specified by:
getResourceBundle
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
getPluginSetting
- Specified by:
getPluginSetting
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
getPluginSetting
- Specified by:
getPluginSetting
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
getPluginSetting
- Specified by:
getPluginSetting
in interfaceorg.pentaho.platform.api.engine.IPluginResourceLoader
-
getClassLoader(Class)
.