org.pentaho.test.platform.engine.core
Class PluginManagerAdapter

java.lang.Object
  extended by org.pentaho.test.platform.engine.core.PluginManagerAdapter
All Implemented Interfaces:
IPluginManager

public class PluginManagerAdapter
extends Object
implements IPluginManager


Constructor Summary
PluginManagerAdapter()
           
 
Method Summary
 Object getApplicationContext(String pluginId)
           
 Object getBean(String beanId)
          If any plugins have registered a bean by id beanId, this method will return a new instance of the object.
 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.
 IContentGenerator getContentGenerator(String id, IPentahoSession session)
           
 IContentGenerator getContentGeneratorForType(String type, IPentahoSession session)
           
 String getContentGeneratorIdForType(String type, IPentahoSession session)
           
 IContentGeneratorInfo getContentGeneratorInfo(String id, IPentahoSession session)
           
 List<IContentGeneratorInfo> getContentGeneratorInfoForType(String type, IPentahoSession session)
          Returns a list of info objects that can be used to create content generators for a given type.
 String getContentGeneratorTitleForType(String type, IPentahoSession session)
           
 String getContentGeneratorUrlForType(String type, IPentahoSession session)
           
 IContentInfo getContentInfoFromExtension(String extension, IPentahoSession session)
           
 Set<String> getContentTypes()
          Returns a set of the content types that the registered plugins can process.
 IContentGeneratorInfo getDefaultContentGeneratorInfoForType(String type, IPentahoSession session)
           
 List<String> getExternalResourcesForContext(String context)
          Return a List of scripts registered for a given context.
 IFileInfo getFileInfo(String extension, IPentahoSession session, ISolutionFile file, InputStream in)
          Retrieves meta information for the given solution file.
 List<org.pentaho.ui.xul.IMenuCustomization> getMenuCustomizations()
          Returns a list of menu customization objects.
 List<org.pentaho.ui.xul.XulOverlay> getOverlays()
          Returns a list of the XUL overlays that are defined by all the plug-ins.
 String getPluginIdForClassLoader(ClassLoader classLoader)
           
 String getPluginIdForContentGeneratorInfo(IContentGeneratorInfo contentGeneratorInfo)
           
 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.
 List<String> getRegisteredPlugins()
           
 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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginManagerAdapter

public PluginManagerAdapter()
Method Detail

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.

Specified by:
getBean in interface IPluginManager
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

getClassLoader

public ClassLoader getClassLoader(IPlatformPlugin plugin)
Specified by:
getClassLoader in interface IPluginManager

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.

Specified by:
getClassLoader in interface IPluginManager
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).

getContentGenerator

public IContentGenerator getContentGenerator(String id,
                                             IPentahoSession session)
                                      throws ObjectFactoryException
Specified by:
getContentGenerator in interface IPluginManager
Throws:
ObjectFactoryException

getContentGeneratorForType

public IContentGenerator getContentGeneratorForType(String type,
                                                    IPentahoSession session)
                                             throws ObjectFactoryException
Specified by:
getContentGeneratorForType in interface IPluginManager
Throws:
ObjectFactoryException

getContentGeneratorIdForType

public String getContentGeneratorIdForType(String type,
                                           IPentahoSession session)
Specified by:
getContentGeneratorIdForType in interface IPluginManager

getContentGeneratorInfo

public IContentGeneratorInfo getContentGeneratorInfo(String id,
                                                     IPentahoSession session)
Specified by:
getContentGeneratorInfo in interface IPluginManager

getContentGeneratorInfoForType

public List<IContentGeneratorInfo> getContentGeneratorInfoForType(String type,
                                                                  IPentahoSession session)
Description copied from interface: IPluginManager
Returns a list of info objects that can be used to create content generators for a given type. In most cases there will only be one content generator for any one type.

Specified by:
getContentGeneratorInfoForType in interface IPluginManager
session - A session used for storing objects from session-scoped factories
Returns:
List of IObjectCreator objects

getContentGeneratorTitleForType

public String getContentGeneratorTitleForType(String type,
                                              IPentahoSession session)
Specified by:
getContentGeneratorTitleForType in interface IPluginManager

getContentGeneratorUrlForType

public String getContentGeneratorUrlForType(String type,
                                            IPentahoSession session)
Specified by:
getContentGeneratorUrlForType in interface IPluginManager

getContentInfoFromExtension

public IContentInfo getContentInfoFromExtension(String extension,
                                                IPentahoSession session)
Specified by:
getContentInfoFromExtension in interface IPluginManager

getContentTypes

public Set<String> getContentTypes()
Description copied from interface: IPluginManager
Returns a set of the content types that the registered plugins can process. If the plugin is intended to handle the processing of a document in the solution repository the types need to match with the filename extension.

Specified by:
getContentTypes in interface IPluginManager
Returns:

getDefaultContentGeneratorInfoForType

public IContentGeneratorInfo getDefaultContentGeneratorInfoForType(String type,
                                                                   IPentahoSession session)
Specified by:
getDefaultContentGeneratorInfoForType in interface IPluginManager

getFileInfo

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

Specified by:
getFileInfo in interface IPluginManager
Parameters:
extension - used to identify the appropriate plugin that handles this type of content
session - the current session
file - 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)
Specified by:
getPluginSetting in interface IPluginManager

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.

Specified by:
getPluginSetting in interface IPluginManager
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

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.

Specified by:
getServicePlugin in interface IPluginManager
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

getStaticResource

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

Specified by:
getStaticResource in interface IPluginManager
Parameters:
path - the path to the plugin resource
Returns:
the InputStream which may be used to read the plugin resource

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)

Specified by:
isBeanRegistered in interface IPluginManager
Parameters:
beanId - Cannot be null
Returns:
true if the bean is registered

isResourceLoadable

public IPlatformPlugin isResourceLoadable(String path)
Specified by:
isResourceLoadable in interface IPluginManager

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.

Specified by:
isStaticResource in interface IPluginManager
Parameters:
path - static resource path
Returns:
true if path begins as a static resource

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.

Specified by:
loadClass in interface IPluginManager
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

reload

public 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.

Specified by:
reload in interface IPluginManager
Parameters:
session - the current session
Returns:
true if no errors were encountered

unloadAllPlugins

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

Specified by:
unloadAllPlugins in interface IPluginManager

getMenuCustomizations

public List<org.pentaho.ui.xul.IMenuCustomization> getMenuCustomizations()
Description copied from interface: IPluginManager
Returns a list of menu customization objects.

Specified by:
getMenuCustomizations in interface IPluginManager
Returns:
List of IMenuCustomization objects

getOverlays

public List<org.pentaho.ui.xul.XulOverlay> getOverlays()
Description copied from interface: IPluginManager
Returns a list of the XUL overlays that are defined by all the plug-ins. The overlays are XML fragments.

Specified by:
getOverlays in interface IPluginManager
Returns:
List of XML XUL overlays

getPluginIdForClassLoader

public String getPluginIdForClassLoader(ClassLoader classLoader)

getPluginIdForContentGeneratorInfo

public String getPluginIdForContentGeneratorInfo(IContentGeneratorInfo contentGeneratorInfo)

getApplicationContext

public Object getApplicationContext(String pluginId)

getRegisteredPlugins

public List<String> getRegisteredPlugins()
Specified by:
getRegisteredPlugins in interface IPluginManager
Returns:

getExternalResourcesForContext

public List<String> getExternalResourcesForContext(String context)
Description copied from interface: IPluginManager
Return a List of scripts registered for a given context.

Specified by:
getExternalResourcesForContext in interface IPluginManager
Parameters:
context - named area in the platform
Returns:
list of registered scripts