org.pentaho.platform.plugin.services.pluginmgr
Class DefaultPluginManager

java.lang.Object
  extended by org.pentaho.platform.plugin.services.pluginmgr.AbstractPluginManager
      extended by org.pentaho.platform.plugin.services.pluginmgr.DefaultPluginManager
All Implemented Interfaces:
IPluginManager

public class DefaultPluginManager
extends AbstractPluginManager


Constructor Summary
DefaultPluginManager()
           
 
Method Summary
 Object getBean(String beanId)
          If any plugins have registered a bean by id beanId, this method will return a new instance of the object.
 IPentahoObjectFactory getBeanFactory()
           
 ClassLoader getClassLoader(IPlatformPlugin plugin)
           
 ClassLoader getClassLoader(String pluginId)
          Returns the classloader instance that was assigned by the plugin manager to load all classes for the specified plugin.
 IFileInfo getFileInfo(String extension, IPentahoSession session, ISolutionFile solutionFile, InputStream in)
          Retrieves meta information for the given solution file.
 Object getPluginSetting(IPlatformPlugin plugin, String key, String defaultValue)
           
 Object getPluginSetting(String pluginId, String key, String defaultValue)
          Retrieves a plugin setting for a given plugin and key.
 String getServicePlugin(String path)
          Returns the plugin that can handle a request for the resource at "path".
 InputStream getStaticResource(String path)
          Returns and InputStream to the specified resource path.
 boolean isBeanRegistered(String beanId)
          Returns true if a bean with id beanId has been registered with the plugin manager, i.e.
 IPlatformPlugin isResourceLoadable(String path)
           
 boolean isStaticResource(String path)
          returns true if the path is a reference to a potential static resource.
 Class<?> loadClass(String beanId)
          Returns a loaded class for the bean registered as beanId.
 boolean reload(IPentahoSession session)
          Causes the plug-in manager object to re-register all of the plug-ins that it knows about.
 void unloadAllPlugins()
          Unloads all the plugins.
 
Methods inherited from class org.pentaho.platform.plugin.services.pluginmgr.AbstractPluginManager
getContentGenerator, getContentGeneratorForType, getContentGeneratorIdForType, getContentGeneratorInfo, getContentGeneratorInfoForType, getContentGeneratorTitleForType, getContentGeneratorUrlForType, getContentInfoFromExtension, getContentTypes, getDefaultContentGeneratorInfoForType, getMenuCustomizations, getOverlays
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPluginManager

public DefaultPluginManager()
Method Detail

reload

public final boolean reload(IPentahoSession session)
Description copied from interface: IPluginManager
Causes the plug-in manager object to re-register all of the plug-ins that it knows about. A IPluginProvider may be invoked to discover plugins from various sources.

Parameters:
session - the current session
Returns:
true if no errors were encountered

getClassLoader

public ClassLoader getClassLoader(IPlatformPlugin plugin)

getClassLoader

public ClassLoader getClassLoader(String pluginId)
Description copied from interface: IPluginManager
Returns the classloader instance that was assigned by the plugin manager to load all classes for the specified plugin. Used in combination with IPluginManager.getServicePlugin(String), this method can provide you with a way to load resources from a plugin when all you have is a request URL/path, such as in a servlet environment.

Returns:
the classloader assigned to this plugin, or null if the plugin is not known by the plugin manager, or for some reason a classloader was not assigned to the plugin (an error condition).

getBeanFactory

public IPentahoObjectFactory getBeanFactory()

getBean

public Object getBean(String beanId)
               throws PluginBeanException
Description copied from interface: IPluginManager
If any plugins have registered a bean by id beanId, this method will return a new instance of the object. The correct classloader must be used to instantiate the object.

Parameters:
beanId - a unique identifier for a particular bean (cannot be null)
Returns:
an instance of the bean registered under beanId
Throws:
PluginBeanException - if there was a problem retrieving the bean instance

loadClass

public Class<?> loadClass(String beanId)
                   throws PluginBeanException
Description copied from interface: IPluginManager
Returns a loaded class for the bean registered as beanId. The class will have been loaded by the proper classloader, so it indirectly provides the caller with it's classloader by class.getClassLoader(). This is often helpful since plugin bean classes are often not available through the caller's classloader.

Parameters:
beanId - a unique identifier for a particular bean (cannot be null)
Returns:
a loaded class for the registered bean
Throws:
PluginBeanException - if there was a problem loading the class

isBeanRegistered

public boolean isBeanRegistered(String beanId)
Description copied from interface: IPluginManager
Returns true if a bean with id beanId has been registered with the plugin manager, i.e. you can get a bean instance by calling IPluginManager.getBean(String)

Parameters:
beanId - Cannot be null
Returns:
true if the bean is registered

unloadAllPlugins

public void unloadAllPlugins()
Description copied from interface: IPluginManager
Unloads all the plugins. Called when the context shuts down.


getFileInfo

public IFileInfo getFileInfo(String extension,
                             IPentahoSession session,
                             ISolutionFile solutionFile,
                             InputStream in)
Description copied from interface: IPluginManager
Retrieves meta information for the given solution file.

Parameters:
extension - used to identify the appropriate plugin that handles this type of content
session - the current session
solutionFile - the solution file we want to know something about
in - the content of the solution file as an InputStream
Returns:
meta information about the solution file

getPluginSetting

public Object getPluginSetting(IPlatformPlugin plugin,
                               String key,
                               String defaultValue)

getPluginSetting

public Object getPluginSetting(String pluginId,
                               String key,
                               String defaultValue)
Description copied from interface: IPluginManager
Retrieves a plugin setting for a given plugin and key.

Parameters:
pluginId - the ID of the plugin to find settings for
key - the setting name to lookup
defaultValue - the default to use if the setting key is not found
Returns:
the plugin setting

isResourceLoadable

public IPlatformPlugin isResourceLoadable(String path)

getServicePlugin

public String getServicePlugin(String path)
Description copied from interface: IPluginManager
Returns the plugin that can handle a request for the resource at "path". A plugin is determined to be able to serve the request if it either a content generator or a static resource of the plugin is configured to handle the path. In other words, if a plugin has a static resource of "/my-plugin/resources", then a request to "/my-plugin/resources/images/file.png" can be handled by the plugin. If ultimately, no plugin can handle the resource path, null is returned.

Parameters:
path - the path to the plugin resource
Returns:
the ID of the plugin which owns the resource or null if one cannot be found

isStaticResource

public boolean isStaticResource(String path)
Description copied from interface: IPluginManager
returns true if the path is a reference to a potential static resource. Note that this does not guarantee that the resource exists, just that it maps to a static resource location.

Parameters:
path - static resource path
Returns:
true if path begins as a static resource

getStaticResource

public InputStream getStaticResource(String path)
Description copied from interface: IPluginManager
Returns and InputStream to the specified resource path.

Parameters:
path - the path to the plugin resource
Returns:
the InputStream which may be used to read the plugin resource