org.rhq.enterprise.server.plugin.pc.content
Class ContentServerPluginContainer

java.lang.Object
  extended by org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer
      extended by org.rhq.enterprise.server.plugin.pc.content.ContentServerPluginContainer

public class ContentServerPluginContainer
extends AbstractTypeServerPluginContainer

The container responsible for managing the lifecycle of content server-side plugins.

Author:
John Mazzitelli

Constructor Summary
ContentServerPluginContainer(MasterServerPluginContainer master)
           
 
Method Summary
protected  ContentProviderManager createAdapterManager()
          Creates the adapter manager that the PC will use.
protected  ServerPluginManager createPluginManager()
          This will be called when its time for this plugin container to create its plugin manager.
 ContentProviderManager getAdapterManager()
          Returns the object that is responsible for managing all adapters which are the things that know how to download content from a specific ContentSource.
 ServerPluginType getSupportedServerPluginType()
          Each plugin container will tell the master which plugins it can support via this method; this method returns the type of plugin that the plugin container can process.
 void initialize()
          The initialize method that prepares the plugin container.
 void scheduleAllPluginJobs()
          If a plugin has scheduled jobs, this method will schedule them now.
 void scheduleSyncJob(ContentSource contentSource)
          This will schedule the sync job for the given content source.
 void scheduleSyncJobs()
          It will schedule one job per adapter such that each adapter is scheduled to be synchronized as per its defined sync schedule.
 void shutdown()
          The shutdown method that will stop and unload all plugins.
 void start()
          This method informs the plugin container that all of its plugins have been loaded.
 void syncNow(ContentSource contentSource)
          This will syncronize the given content source, meaning its PackageVersions will be updated and, if not lazy-loading, will load the package versions that are not loaded yet.
 void unscheduleSyncJob(ContentSource contentSource)
          This will unschedule the sync job for the given content source.
 
Methods inherited from class org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer
getLog, getMasterServerPluginContainer, getPluginManager, loadPlugin, reloadPlugin, scheduleJob, schedulePluginJobs, stop, unloadPlugin, unschedulePluginJobs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentServerPluginContainer

public ContentServerPluginContainer(MasterServerPluginContainer master)
Method Detail

initialize

public void initialize()
                throws java.lang.Exception
Description copied from class: AbstractTypeServerPluginContainer
The initialize method that prepares the plugin container. This should get the plugin container ready to accept plugins. Subclasses are free to perform additional tasks by overriding this method.

Overrides:
initialize in class AbstractTypeServerPluginContainer
Throws:
java.lang.Exception - if the plugin container failed to initialize for some reason

start

public void start()
Description copied from class: AbstractTypeServerPluginContainer
This method informs the plugin container that all of its plugins have been loaded. Once this is called, the plugin container can assume all plugins that it will ever know about have been loaded.

Overrides:
start in class AbstractTypeServerPluginContainer

shutdown

public void shutdown()
Description copied from class: AbstractTypeServerPluginContainer
The shutdown method that will stop and unload all plugins. Subclasses are free to perform additional tasks by overriding this method.

Overrides:
shutdown in class AbstractTypeServerPluginContainer

scheduleAllPluginJobs

public void scheduleAllPluginJobs()
                           throws java.lang.Exception
Description copied from class: AbstractTypeServerPluginContainer
If a plugin has scheduled jobs, this method will schedule them now. This particular method implementation schedules the global jobs as defined in the plugin descriptors. Subclasses are free to extend this method to schedule additional plugin jobs, but must ensure they call this method so the global scheduled jobs get added to the scheduler. Note that this is separate from the AbstractTypeServerPluginContainer.start() method because it is possible that the plugin container has been started before the scheduler has. In this case, the caller must wait for the scheduler to be started before this method is called to schedule jobs.

Overrides:
scheduleAllPluginJobs in class AbstractTypeServerPluginContainer
Throws:
java.lang.Exception - if failed to schedule jobs

getSupportedServerPluginType

public ServerPluginType getSupportedServerPluginType()
Description copied from class: AbstractTypeServerPluginContainer
Each plugin container will tell the master which plugins it can support via this method; this method returns the type of plugin that the plugin container can process. Only one plugin container can support a plugin type.

Specified by:
getSupportedServerPluginType in class AbstractTypeServerPluginContainer
Returns:
the type of plugin that this plugin container instance can support

getAdapterManager

public ContentProviderManager getAdapterManager()
Returns the object that is responsible for managing all adapters which are the things that know how to download content from a specific ContentSource.

Returns:
adapter manager

syncNow

public void syncNow(ContentSource contentSource)
             throws org.quartz.SchedulerException
This will syncronize the given content source, meaning its PackageVersions will be updated and, if not lazy-loading, will load the package versions that are not loaded yet.

Note that this will perform the sync asynchronously in a separate thread. This is because this sync operation can potentially run for hours and we do not want to block the calling thread.

Parameters:
contentSource - the content source to sync
Throws:
org.quartz.SchedulerException - if failed to schedule the job for immediate execution

scheduleSyncJob

public void scheduleSyncJob(ContentSource contentSource)
                     throws org.quartz.SchedulerException
This will schedule the sync job for the given content source. Once the scheduling is complete, the content source's adapter will be asked to synchronize with the remote content source according to the time(s) specified in the schedule.

If the content source's sync schedule is empty, this method assumes it should not be automatically sync'ed so no schedule will be created and this method simply returns.

Parameters:
contentSource -
Throws:
org.quartz.SchedulerException - if failed to schedule the job

scheduleSyncJobs

public void scheduleSyncJobs()
It will schedule one job per adapter such that each adapter is scheduled to be synchronized as per its defined sync schedule. This must only be called when all content source adapters have been initialized.


unscheduleSyncJob

public void unscheduleSyncJob(ContentSource contentSource)
                       throws org.quartz.SchedulerException
This will unschedule the sync job for the given content source. Once unscheduled, the content source's adapter will not be asked to synchronize with the remote content source.

Parameters:
contentSource -
Throws:
org.quartz.SchedulerException - if failed to unschedule the job

createPluginManager

protected ServerPluginManager createPluginManager()
Description copied from class: AbstractTypeServerPluginContainer
This will be called when its time for this plugin container to create its plugin manager. Subclasses are free to override this if they need their own specialized plugin manager.

Overrides:
createPluginManager in class AbstractTypeServerPluginContainer
Returns:
the plugin manager for use by this plugin container

createAdapterManager

protected ContentProviderManager createAdapterManager()
Creates the adapter manager that the PC will use.

This is protected scope so subclasses can define their own adapter manager to use. This is mainly to support tests.

Returns:
the new adapter manager


Copyright © 2008-2009 Red Hat, Inc.. All Rights Reserved.