org.scijava.object
Class DefaultObjectService

java.lang.Object
  extended by org.scijava.AbstractContextual
      extended by org.scijava.plugin.AbstractRichPlugin
          extended by org.scijava.service.AbstractService
              extended by org.scijava.object.DefaultObjectService
All Implemented Interfaces:
Comparable<Prioritized>, Contextual, Disposable, ObjectService, HasPluginInfo, RichPlugin, SciJavaPlugin, Prioritized, SciJavaService, Service

public final class DefaultObjectService
extends AbstractService
implements ObjectService

Default service for keeping track of registered objects. Automatically registers new objects from ObjectCreatedEvents, and removes objects from ObjectDeletedEvents.

This is useful to retrieve available objects of a particular type. For example, the InputHarvester infrastructure uses it to provide a pool of available objects for widgets such as the ObjectWidget, which provide the user with a multiple-choice selection.

Author:
Curtis Rueden

Constructor Summary
DefaultObjectService()
           
 
Method Summary
 void addObject(Object obj)
          Registers an object with the object service.
 EventService getEventService()
           
 ObjectIndex<Object> getIndex()
          Gets the index of available objects.
<T> List<T>
getObjects(Class<T> type)
          Gets a list of all registered objects compatible with the given type.
 void initialize()
          Performs any needed initialization when the service is first loaded.
protected  void onEvent(ObjectCreatedEvent event)
           
protected  void onEvent(ObjectDeletedEvent event)
           
 void removeObject(Object obj)
          Deregisters an object with the object service.
 
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.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

DefaultObjectService

public DefaultObjectService()
Method Detail

getEventService

public EventService getEventService()
Specified by:
getEventService in interface ObjectService

getIndex

public ObjectIndex<Object> getIndex()
Description copied from interface: ObjectService
Gets the index of available objects.

Specified by:
getIndex in interface ObjectService

getObjects

public <T> List<T> getObjects(Class<T> type)
Description copied from interface: ObjectService
Gets a list of all registered objects compatible with the given type.

Specified by:
getObjects in interface ObjectService

addObject

public void addObject(Object obj)
Description copied from interface: ObjectService
Registers an object with the object service.

Specified by:
addObject in interface ObjectService

removeObject

public void removeObject(Object obj)
Description copied from interface: ObjectService
Deregisters an object with the object service.

Specified by:
removeObject in interface ObjectService

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

onEvent

protected void onEvent(ObjectCreatedEvent event)

onEvent

protected void onEvent(ObjectDeletedEvent event)


Copyright © 2009–2015 SciJava. All rights reserved.