net.firstpartners.rp.mid.global
Class PluginManager

java.lang.Object
  extended by net.firstpartners.rp.mid.global.PluginManager

public class PluginManager
extends java.lang.Object

Central point to get handle to the plugins available to the system
This one propogates Events to the loaded plugins.

Version:
1.1
Author:
Firstpartners.net

Nested Class Summary
(package private)  class PluginManager.PluginThread
          This class is responsable for initialization of the plugin Process of initialzation (onLoad process ) will be made in background
 
Field Summary
private static ICategoryManager categoryManager
          Category manager
private static ICategoryStore categoryStores
          Category store
private  int countSearch
          Flag to indicate that search processs is active
private static IFeedbackDataStore feedbackDataStores
          Feedback store
private static IIndexManager indexManager
          Index manager
protected  org.apache.log4j.Logger logger
          Logger for this class and subclasses
private static java.lang.String m_encodedCredentials
          User credentials
private static java.util.LinkedList m_listPluginsInAdd
          List of plugins interested in add
private static java.util.LinkedList m_listPluginsInExtract
          List of plugins interested in extract data
private static java.util.LinkedList m_listPluginsInFeedback
          List of plugins interested in feedback
private static java.util.LinkedList m_listPluginsInFilter
          List of plugins interested in filter
private static java.util.LinkedList m_listPluginsInSearch
          List of plugins interested in search
private static java.util.LinkedList m_listRunningPlugins
          List of the running plugins ( controlled in the search process )
private static RPClassLoader m_loader
          Actual class loader which extends the tomcat.class loader
private  java.util.Collection plugins
          List of plugins which belongs to the system
private  Proxy proxy
          Proxy configuration
private  java.lang.String root
          Root plugins
 
Constructor Summary
protected PluginManager()
          Creates a new PluginManager object.
 
Method Summary
static void addPluginThread(IInterestedInAdd plugin, INewInformation info)
          Add the controller thread formed by plugin and information to the running list in order to be controlled
private  void addPluginTypeInAdd(IInterestedInAdd plugin)
          Add the plugin to InAdd list
private  void addPluginTypeInExtract(IDataExtractor plugin)
          Add the plugin to the InExtract list
private  void addPluginTypeInFeedback(IInterestedInFeedback plugin)
          Add the plugin to InFeedback list
private  void addPluginTypeInFilter(IInterestedInResultsFilter plugin)
          Add the plugin to InFilter list
private  void addPluginTypeInSearch(IInterestedInSearch plugin)
          Add the plugin to the InSearch list
 void endSearchOp()
          A search operation was finished
static IDataExtractor getBestExtractor(INewInformation addInfo)
           
static ICategoryManager getCategoryManager()
           
static ICategoryStore getCategoryStores()
          Get a handle to all the available DataStores (classes)
static IDataExtractor[] getDataExtractors()
          Get a handle to all the plugins that can extract data
static IFeedbackDataStore getFeedbackDataStores()
          Get a handle to the FeedbackDataStore
static IIndexManager getIndexManager()
           
static IInterestedInAdd[] getInterestedInAdd()
          Get a handle to all the plugins interested in receiving add events
static IInterestedInFeedback[] getInterestedInFeedback()
          Get a handle to all the plugins interested in receiving feedback events
static IInterestedInResultsFilter[] getInterestedInFilterResults()
          Get a handle to all the plugins interested in receiving feedback
static IInterestedInSearch[] getInterestedInSearch()
          Get a handle to all the plugins interested in receiving Search Events
 java.util.Collection getPlugins()
           
 Proxy getProxy()
           
static java.lang.String getProxyCredentials()
          Get the proxy credentials in Base64 (sun) encoding
 java.lang.String getRoot()
           
static boolean isInAddProcess()
          Validate if the system is in adding process
private  boolean isPlugin(java.lang.Object plugin)
          Validate if the specified object is a plugin (implement one of the default IPlugin interfaces).
(package private)  void loadPlugins()
          'Walks' Directory Tree from point X (specified in config file) and loads all classes that implement the IPlugin interface.
 void setCategoryManager(ICategoryManager categoryManager)
           
 void setCategoryStores(ICategoryStore categoryStore)
           
 void setFeedbackDataStores(IFeedbackDataStore feedbackDataStore)
           
 void setIndexManager(IIndexManager indexManager)
           
 void setPlugins(java.util.Collection plugins)
           
private  void setPriority(int priority)
          Set the low priority for the threads (a search is in running )
 void setProxy(Proxy proxy)
           
 void setRoot(java.lang.String root)
           
 void startSearchOp()
          A new search operation was invoked into the system
static void storeAndAddDocument(DocumStruct doc)
          Add the document structure to the system
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.log4j.Logger logger
Logger for this class and subclasses


root

private java.lang.String root
Root plugins


categoryManager

private static ICategoryManager categoryManager
Category manager


indexManager

private static IIndexManager indexManager
Index manager


categoryStores

private static ICategoryStore categoryStores
Category store


feedbackDataStores

private static IFeedbackDataStore feedbackDataStores
Feedback store


m_listPluginsInAdd

private static java.util.LinkedList m_listPluginsInAdd
List of plugins interested in add


m_listPluginsInFeedback

private static java.util.LinkedList m_listPluginsInFeedback
List of plugins interested in feedback


m_listPluginsInFilter

private static java.util.LinkedList m_listPluginsInFilter
List of plugins interested in filter


m_listPluginsInSearch

private static java.util.LinkedList m_listPluginsInSearch
List of plugins interested in search


m_listPluginsInExtract

private static java.util.LinkedList m_listPluginsInExtract
List of plugins interested in extract data


m_encodedCredentials

private static java.lang.String m_encodedCredentials
User credentials


proxy

private Proxy proxy
Proxy configuration


plugins

private java.util.Collection plugins
List of plugins which belongs to the system


m_listRunningPlugins

private static java.util.LinkedList m_listRunningPlugins
List of the running plugins ( controlled in the search process )


m_loader

private static RPClassLoader m_loader
Actual class loader which extends the tomcat.class loader


countSearch

private int countSearch
Flag to indicate that search processs is active

Constructor Detail

PluginManager

protected PluginManager()
Creates a new PluginManager object.

Method Detail

loadPlugins

void loadPlugins()
           throws RpException
'Walks' Directory Tree from point X (specified in config file) and loads all classes that implement the IPlugin interface. Holds these as internal Cache for the other methods on this class to query for specific plugin types (e.g. getDataSources / getMetaDataStores).

Throws:
RpException - If an error must to be signaled

isPlugin

private boolean isPlugin(java.lang.Object plugin)
Validate if the specified object is a plugin (implement one of the default IPlugin interfaces). If yes, also the detect the plugin type

Parameters:
plugin - Plugin object to validate
Returns:
True if the object is a plugin object, false otherwise

getBestExtractor

public static IDataExtractor getBestExtractor(INewInformation addInfo)
                                       throws RpException
Throws:
RpException

storeAndAddDocument

public static void storeAndAddDocument(DocumStruct doc)
Add the document structure to the system

Parameters:
doc - DocumentStruct to be added to the system
Throws:
RpException

getCategoryStores

public static ICategoryStore getCategoryStores()
                                        throws RpException
Get a handle to all the available DataStores (classes)

Returns:
single IBasicCategoryStore - as specified in the config file
Throws:
RpException - if there are no such plugins available at runtime

getFeedbackDataStores

public static IFeedbackDataStore getFeedbackDataStores()
                                                throws RpException
Get a handle to the FeedbackDataStore

Returns:
IFeedbackDataStore (one per system , as per config file)
Throws:
RpException - if there are no such plugins available at runtime

getInterestedInFeedback

public static IInterestedInFeedback[] getInterestedInFeedback()
                                                       throws RpException
Get a handle to all the plugins interested in receiving feedback events

Returns:
array of IInterestedInFeedback - one for each plugin available. Guaranteed not to be null , zero length or contain any null elements in array.
Throws:
RpException - if there are no such plugins available at runtime

getInterestedInAdd

public static IInterestedInAdd[] getInterestedInAdd()
                                             throws RpException
Get a handle to all the plugins interested in receiving add events

Returns:
array of IInterestedInFeedback - one for each plugin available. Guaranteed not to be null , zero length or contain any null elements in array.
Throws:
RpException - if there are no such plugins available at runtime

getInterestedInSearch

public static IInterestedInSearch[] getInterestedInSearch()
                                                   throws RpException
Get a handle to all the plugins interested in receiving Search Events

Returns:
array of IInterestedInFeedback - one for each plugin available. Guaranteed not to be null , zero length or contain any null elements in array.
Throws:
RpException - if there are no such plugins available at runtime

getInterestedInFilterResults

public static IInterestedInResultsFilter[] getInterestedInFilterResults()
                                                                 throws RpException
Get a handle to all the plugins interested in receiving feedback

Returns:
array of IInterestedInFeedback - one for each plugin available. Guaranteed not to be null , zero length or contain any null elements in array.
Throws:
RpException - if there are no such plugins available at runtime

getDataExtractors

public static IDataExtractor[] getDataExtractors()
                                          throws RpException
Get a handle to all the plugins that can extract data

Returns:
array of IInterestedInFeedback - one for each plugin available. Guaranteed not to be null , zero length or contain any null elements in array.
Throws:
RpException - if there are no such plugins available at runtime

addPluginThread

public static void addPluginThread(IInterestedInAdd plugin,
                                   INewInformation info)
Add the controller thread formed by plugin and information to the running list in order to be controlled

Parameters:
plugin -
info -

isInAddProcess

public static boolean isInAddProcess()
Validate if the system is in adding process

Returns:
True if exists one plugin which is running process

setPriority

private void setPriority(int priority)
Set the low priority for the threads (a search is in running )


startSearchOp

public void startSearchOp()
A new search operation was invoked into the system


endSearchOp

public void endSearchOp()
A search operation was finished


addPluginTypeInAdd

private void addPluginTypeInAdd(IInterestedInAdd plugin)
Add the plugin to InAdd list

Parameters:
plugin - Plugin object to be add

addPluginTypeInFeedback

private void addPluginTypeInFeedback(IInterestedInFeedback plugin)
Add the plugin to InFeedback list

Parameters:
plugin - Plugin object to be add

addPluginTypeInFilter

private void addPluginTypeInFilter(IInterestedInResultsFilter plugin)
Add the plugin to InFilter list

Parameters:
plugin - Plugin object to be add

addPluginTypeInSearch

private void addPluginTypeInSearch(IInterestedInSearch plugin)
Add the plugin to the InSearch list

Parameters:
plugin - Plugin object to be add

addPluginTypeInExtract

private void addPluginTypeInExtract(IDataExtractor plugin)
Add the plugin to the InExtract list

Parameters:
plugin - Plugin object to be add

getRoot

public java.lang.String getRoot()
Returns:
Returns the root.

setRoot

public void setRoot(java.lang.String root)
Parameters:
root - The root to set.

getProxyCredentials

public static java.lang.String getProxyCredentials()
Get the proxy credentials in Base64 (sun) encoding

Returns:

getCategoryManager

public static ICategoryManager getCategoryManager()
Returns:
Returns the categoryManager.

setCategoryManager

public void setCategoryManager(ICategoryManager categoryManager)
Parameters:
categoryManager - The categoryManager to set.

getIndexManager

public static IIndexManager getIndexManager()
Returns:
Returns the indexManager.

setIndexManager

public void setIndexManager(IIndexManager indexManager)
Parameters:
indexManager - The indexManager to set.

getPlugins

public java.util.Collection getPlugins()
Returns:
Returns the plugins.

setPlugins

public void setPlugins(java.util.Collection plugins)
Parameters:
plugins - The plugins to set.

getProxy

public Proxy getProxy()
Returns:
Returns the proxy.

setProxy

public void setProxy(Proxy proxy)
Parameters:
proxy - The proxy to set.

setCategoryStores

public void setCategoryStores(ICategoryStore categoryStore)
Parameters:
proxy - The CategoryStore to set.

setFeedbackDataStores

public void setFeedbackDataStores(IFeedbackDataStore feedbackDataStore)
Parameters:
proxy - The FeedbackStore to set.