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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfindResources(Class<?> clazz, String namePattern) findResources(ClassLoader classLoader, String namePattern) protected ClassLoadergetClassLoader(Class<?> clazz) protected PluginClassLoaderprotected FilegetPluginDir(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) voidsetOverrideClassloader(PluginClassLoader pluginClassloader) Deprecated.voidsetRootDir(File rootDir) Deprecated.voidsetSettingsPath(String settingsPath) 
- 
Constructor Details- 
PluginResourceLoaderpublic PluginResourceLoader()
 
- 
- 
Method Details- 
setSettingsPath
- 
setOverrideClassloaderDeprecated.
- 
getOverrideClassloader
- 
setRootDirDeprecated.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 thePluginClassLoaderfor the root directory.- Parameters:
- rootDir- the root directory in which to search for resources
 
- 
getResourceAsBytes- Specified by:
- getResourceAsBytesin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
- 
getResourceAsStringpublic String getResourceAsString(Class<? extends Object> clazz, String resourcePath) throws UnsupportedEncodingException - Specified by:
- getResourceAsStringin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
- Throws:
- UnsupportedEncodingException
 
- 
getResourceAsStringpublic String getResourceAsString(Class<? extends Object> clazz, String resourcePath, String charsetName) throws UnsupportedEncodingException - Specified by:
- getResourceAsStringin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
- Throws:
- UnsupportedEncodingException
 
- 
getSystemRelativePluginPath
- 
getPluginDir
- 
getClassLoader
- 
getResourceAsStream- Specified by:
- getResourceAsStreamin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
- 
getResourceAsStream- Specified by:
- getResourceAsStreamin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
- 
findResources- Specified by:
- findResourcesin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
- 
findResources- Specified by:
- findResourcesin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
- 
getResourceBundle- Specified by:
- getResourceBundlein interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
- 
getPluginSetting- Specified by:
- getPluginSettingin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
- 
getPluginSetting- Specified by:
- getPluginSettingin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
- 
getPluginSetting- Specified by:
- getPluginSettingin interface- org.pentaho.platform.api.engine.IPluginResourceLoader
 
 
- 
getClassLoader(Class).