org.scijava.plugin
Class AbstractSingletonService<PT extends SingletonPlugin>

java.lang.Object
  extended by org.scijava.AbstractContextual
      extended by org.scijava.plugin.AbstractRichPlugin
          extended by org.scijava.service.AbstractService
              extended by org.scijava.plugin.AbstractPTService<PT>
                  extended by org.scijava.plugin.AbstractSingletonService<PT>
Type Parameters:
PT - Plugin type of the SingletonPlugins being managed.
All Implemented Interfaces:
Comparable<Prioritized>, Contextual, Disposable, HasPluginInfo, PTService<PT>, RichPlugin, SciJavaPlugin, SingletonService<PT>, Prioritized, Service
Direct Known Subclasses:
AbstractHandlerService

public abstract class AbstractSingletonService<PT extends SingletonPlugin>
extends AbstractPTService<PT>
implements SingletonService<PT>

Abstract base class for SingletonServices.

Author:
Curtis Rueden

Constructor Summary
AbstractSingletonService()
           
 
Method Summary
protected  List<? extends PT> filterInstances(List<PT> list)
          Allows subclasses to exclude instances.
<P extends PT>
P
getInstance(Class<P> pluginClass)
          Gets the singleton plugin instance of the given class.
 List<PT> getInstances()
          Gets the list of plugin instances.
 void initialize()
          Performs any needed initialization when the service is first loaded.
 
Methods inherited from class org.scijava.plugin.AbstractPTService
getPlugins, getPluginService
 
Methods inherited from class org.scijava.service.AbstractService
dispose, getContext, registerEventHandlers, setContext, toString
 
Methods inherited from class org.scijava.plugin.AbstractRichPlugin
compareTo, getInfo, getPriority, setInfo, setPriority
 
Methods inherited from class org.scijava.AbstractContextual
context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.scijava.plugin.PTService
getPlugins, getPluginService, getPluginType
 
Methods inherited from interface org.scijava.service.Service
registerEventHandlers
 
Methods inherited from interface org.scijava.Contextual
context, getContext, setContext
 
Methods inherited from interface org.scijava.Prioritized
getPriority, setPriority
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.scijava.plugin.HasPluginInfo
getInfo, setInfo
 
Methods inherited from interface org.scijava.Disposable
dispose
 

Constructor Detail

AbstractSingletonService

public AbstractSingletonService()
Method Detail

getInstances

public List<PT> getInstances()
Description copied from interface: SingletonService
Gets the list of plugin instances. There will be one singleton instance for each available plugin.

Specified by:
getInstances in interface SingletonService<PT extends SingletonPlugin>

getInstance

public <P extends PT> P getInstance(Class<P> pluginClass)
Description copied from interface: SingletonService
Gets the singleton plugin instance of the given class.

Specified by:
getInstance in interface SingletonService<PT extends SingletonPlugin>

initialize

public void initialize()
Description copied from interface: Service
Performs any needed initialization when the service is first loaded.

NB: This method is not intended to be called directly. It is called by the service framework itself (specifically by the ServiceHelper) when initializing the service. It should not be called a second time.

Specified by:
initialize in interface Service
Overrides:
initialize in class AbstractService

filterInstances

protected List<? extends PT> filterInstances(List<PT> list)
Allows subclasses to exclude instances.

Parameters:
list - the initial list of instances
Returns:
the filtered list of instances


Copyright © 2009–2014 SciJava. All rights reserved.