org.modeshape.repository.sequencer
Class SequencingService

java.lang.Object
  extended by org.modeshape.repository.sequencer.SequencingService
All Implemented Interfaces:
AdministeredService

public class SequencingService
extends Object
implements AdministeredService

A sequencing system is used to monitor changes in the content of ModeShape repositories and to sequence the content to extract or to generate structured information.


Nested Class Summary
protected  class SequencingService.Administrator
          The administrative component for this service.
protected static class SequencingService.DefaultSelector
          The default SequencingService.Selector implementation that selects every sequencer every time it's called, regardless of the node (or logger) supplied.
protected  class SequencingService.RepositoryObserver
           
static interface SequencingService.Selector
          Interface used to select the set of Sequencer instances that should be run.
protected  class SequencingService.SequencerCall
           
protected  class SequencingService.SequencerCalls
           
 class SequencingService.Statistics
          The statistics for the system.
 
Field Summary
protected static ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY
          Class loader factory instance that always returns the current thread's context class loader (if not null) or component library's class loader.
static SequencingService.Selector DEFAULT_SEQUENCER_SELECTOR
          The default SequencingService.Selector that considers every Sequencer to be used for every node.
 
Constructor Summary
SequencingService()
          Create a new sequencing system, configured with no sequencers and not monitoring any workspaces.
 
Method Summary
 boolean addSequencer(SequencerConfig config)
          Add the configuration for a sequencer, or update any existing one that represents the same configuration
protected  ExecutorService createDefaultExecutorService()
          Override this method to creates a different kind of default executor service.
protected  boolean doAwaitTermination(long timeout, TimeUnit unit)
           
 ServiceAdministrator getAdministrator()
          Return the administrative component for this service.
 ExecutionContext getExecutionContext()
           
 ExecutorService getExecutorService()
          Get the executor service used to run the sequencers.
 RepositoryLibrary getRepositoryLibrary()
          Get the repository library to be used for repository lookup
protected  ComponentLibrary<Sequencer,SequencerConfig> getSequencerLibrary()
           
 List<SequencerConfig> getSequencers()
          Get configurations for all known sequencers
 SequencingService.Selector getSequencerSelector()
          Get the sequencing selector used by this system.
 List<Sequencer> getSequencersList()
           
 SequencingService.Statistics getStatistics()
          Get the statistics for this system.
protected  boolean isServiceTerminated()
           
protected  void processChange(NetChangeObserver.NetChanges changes)
          Do the work of processing by sequencing the node.
 boolean removeSequencer(SequencerConfig config)
          Remove the configuration for a sequencer.
 void setExecutionContext(ExecutionContext executionContext)
           
 void setExecutorService(ExecutorService executorService)
          Set the executor service that should be used by this system.
 void setRepositoryLibrary(RepositoryLibrary repositoryLibrary)
           
 void setSequencerSelector(SequencingService.Selector sequencerSelector)
          Set the sequencer selector, or null if the default sequencer selector should be used.
 void setSequencersList(List<Sequencer> sequencersList)
           
protected  void shutdownService()
           
protected  void startService()
           
 boolean updateSequencer(SequencerConfig config)
          Update the configuration for a sequencer, or add it if there is no matching configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SEQUENCER_SELECTOR

public static final SequencingService.Selector DEFAULT_SEQUENCER_SELECTOR
The default SequencingService.Selector that considers every Sequencer to be used for every node.

See Also:
setSequencerSelector(org.modeshape.repository.sequencer.SequencingService.Selector)

DEFAULT_CLASSLOADER_FACTORY

protected static final ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY
Class loader factory instance that always returns the current thread's context class loader (if not null) or component library's class loader.

Constructor Detail

SequencingService

public SequencingService()
Create a new sequencing system, configured with no sequencers and not monitoring any workspaces. Upon construction, the system is paused and must be configured and then started.

Method Detail

getAdministrator

public ServiceAdministrator getAdministrator()
Return the administrative component for this service.

Specified by:
getAdministrator in interface AdministeredService
Returns:
the administrative component; never null

getStatistics

public SequencingService.Statistics getStatistics()
Get the statistics for this system.

Returns:
statistics

getSequencerLibrary

protected ComponentLibrary<Sequencer,SequencerConfig> getSequencerLibrary()
Returns:
sequencerLibrary

addSequencer

public boolean addSequencer(SequencerConfig config)
Add the configuration for a sequencer, or update any existing one that represents the same configuration

Parameters:
config - the new configuration
Returns:
true if the sequencer was added, or false if there already was an existing and unchanged sequencer configuration
Throws:
IllegalArgumentException - if config is null
See Also:
updateSequencer(SequencerConfig), removeSequencer(SequencerConfig)

getSequencers

public List<SequencerConfig> getSequencers()
Get configurations for all known sequencers

Returns:
List of SequencerConfigs
Throws:
IllegalArgumentException - if config is null
See Also:
updateSequencer(SequencerConfig), removeSequencer(SequencerConfig)

updateSequencer

public boolean updateSequencer(SequencerConfig config)
Update the configuration for a sequencer, or add it if there is no matching configuration.

Parameters:
config - the updated (or new) configuration
Returns:
true if the sequencer was updated, or false if there already was an existing and unchanged sequencer configuration
Throws:
IllegalArgumentException - if config is null
See Also:
addSequencer(SequencerConfig), removeSequencer(SequencerConfig)

removeSequencer

public boolean removeSequencer(SequencerConfig config)
Remove the configuration for a sequencer.

Parameters:
config - the configuration to be removed
Returns:
true if the sequencer was removed, or false if there was no existing sequencer
Throws:
IllegalArgumentException - if config is null
See Also:
addSequencer(SequencerConfig), updateSequencer(SequencerConfig)

getExecutionContext

public ExecutionContext getExecutionContext()
Returns:
executionContext

setExecutionContext

public void setExecutionContext(ExecutionContext executionContext)
Parameters:
executionContext - Sets executionContext to the specified value.

getRepositoryLibrary

public RepositoryLibrary getRepositoryLibrary()
Get the repository library to be used for repository lookup

Returns:
the repository library

setRepositoryLibrary

public void setRepositoryLibrary(RepositoryLibrary repositoryLibrary)

getExecutorService

public ExecutorService getExecutorService()
Get the executor service used to run the sequencers.

Returns:
the executor service
See Also:
setExecutorService(ExecutorService)

setExecutorService

public void setExecutorService(ExecutorService executorService)
Set the executor service that should be used by this system. By default, the system is set up with a executor that uses a single thread.

Parameters:
executorService - the executor service
See Also:
getExecutorService(), Executors.newCachedThreadPool(), Executors.newCachedThreadPool(java.util.concurrent.ThreadFactory), Executors.newFixedThreadPool(int), Executors.newFixedThreadPool(int, java.util.concurrent.ThreadFactory), Executors.newScheduledThreadPool(int), Executors.newScheduledThreadPool(int, java.util.concurrent.ThreadFactory), Executors.newSingleThreadExecutor(), Executors.newSingleThreadExecutor(java.util.concurrent.ThreadFactory), Executors.newSingleThreadScheduledExecutor(), Executors.newSingleThreadScheduledExecutor(java.util.concurrent.ThreadFactory)

createDefaultExecutorService

protected ExecutorService createDefaultExecutorService()
Override this method to creates a different kind of default executor service. This method is called when the system is started without an executor service being set.

This method creates a single-threaded executor.

Returns:
the executor service

startService

protected void startService()

shutdownService

protected void shutdownService()

isServiceTerminated

protected boolean isServiceTerminated()

doAwaitTermination

protected boolean doAwaitTermination(long timeout,
                                     TimeUnit unit)
                              throws InterruptedException
Throws:
InterruptedException

getSequencerSelector

public SequencingService.Selector getSequencerSelector()
Get the sequencing selector used by this system.

Returns:
the sequencing selector

setSequencerSelector

public void setSequencerSelector(SequencingService.Selector sequencerSelector)
Set the sequencer selector, or null if the default sequencer selector should be used.

Parameters:
sequencerSelector - the selector

processChange

protected void processChange(NetChangeObserver.NetChanges changes)
Do the work of processing by sequencing the node. This method is called by the executor service when it performs it's work on the enqueued NetChange runnable objects.

Parameters:
changes - the change describing the node to be processed.

setSequencersList

public void setSequencersList(List<Sequencer> sequencersList)
Parameters:
sequencersList - Sets sequencersList to the specified value.

getSequencersList

public List<Sequencer> getSequencersList()
Returns:
sequencersList


Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.