org.scijava.plugin
Class PluginInfo<PT extends SciJavaPlugin>

java.lang.Object
  extended by org.scijava.AbstractBasicDetails
      extended by org.scijava.AbstractUIDetails
          extended by org.scijava.plugin.PluginInfo<PT>
Type Parameters:
PT - The type of plugin described by this metadata. See SciJavaPlugin for a list of common plugin types.
All Implemented Interfaces:
Comparable<Prioritized>, BasicDetails, Identifiable, Instantiable<PT>, Locatable, Prioritized, UIDetails, Versioned
Direct Known Subclasses:
CommandInfo

public class PluginInfo<PT extends SciJavaPlugin>
extends AbstractUIDetails
implements Instantiable<PT>, Identifiable, Locatable, Versioned

A collection of metadata about a particular plugin.

For performance reasons, the metadata is populated without actually loading the plugin class, by reading from an efficient binary cache (see DefaultPluginService for details). As such, we can very quickly build a complex structure containing all available plugins without waiting for the Java class loader.

Author:
Curtis Rueden
See Also:
Plugin, PluginService

Field Summary
 
Fields inherited from interface org.scijava.UIDetails
APPLICATION_MENU_ROOT
 
Constructor Summary
  PluginInfo(Class<? extends PT> pluginClass, Class<PT> pluginType)
          Creates a new plugin metadata object.
  PluginInfo(Class<? extends PT> pluginClass, Class<PT> pluginType, Plugin annotation)
          Creates a new plugin metadata object.
protected PluginInfo(String className, Class<? extends PT> pluginClass, Class<PT> pluginType, Plugin annotation, ClassLoader classLoader)
           
  PluginInfo(String className, Class<PT> pluginType)
          Creates a new plugin metadata object.
  PluginInfo(String className, Class<PT> pluginType, Plugin annotation)
          Creates a new plugin metadata object.
  PluginInfo(String className, Class<PT> pluginType, Plugin annotation, ClassLoader classLoader)
          Creates a new plugin metadata object.
 
Method Summary
 PT createInstance()
          Creates an object.
 Plugin getAnnotation()
          Gets the associated @Plugin annotation.
 String getClassName()
          Gets the fully qualified name of the Class of the objects that can be created.
 URL getIconURL()
          Gets the URL corresponding to the icon resource path.
 String getIdentifier()
          Gets a string intended to function as an identifier for the object.
 String getLocation()
          Gets the URL string defining the object's location.
 Class<? extends PT> getPluginClass()
          Obtains the Class of the item objects, if that class has already been loaded.
 Class<PT> getPluginType()
          Gets the type of plugin described by the metadata.
 String getVersion()
          Gets the version of the object.
 boolean inject(Object o)
          Injects the metadata into the given object.
 Class<? extends PT> loadClass()
          Loads the class corresponding to the objects that are created by Instantiable.createInstance().
 void setPluginClass(Class<? extends PT> pluginClass)
          Explicitly sets the Class of the item objects.
 void setPluginType(Class<PT> pluginType)
          Sets the type of plugin described by the metadata.
 String toString()
           
 
Methods inherited from class org.scijava.AbstractUIDetails
compareTo, getIconPath, getMenuPath, getMenuRoot, getPriority, getSelectionGroup, getTitle, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setPriority, setSelectable, setSelected, setSelectionGroup, setVisible
 
Methods inherited from class org.scijava.AbstractBasicDetails
get, getDescription, getLabel, getName, is, set, setDescription, setLabel, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.scijava.BasicDetails
get, getDescription, getLabel, getName, is, set, setDescription, setLabel, setName
 

Constructor Detail

PluginInfo

public PluginInfo(String className,
                  Class<PT> pluginType)
Creates a new plugin metadata object.

Parameters:
className - The name of the class, which must implement SciJavaPlugin.
pluginType - The type of plugin described by this metadata. See SciJavaPlugin for a list of common plugin types.

PluginInfo

public PluginInfo(String className,
                  Class<PT> pluginType,
                  Plugin annotation)
Creates a new plugin metadata object.

Parameters:
className - The name of the class, which must implement SciJavaPlugin.
pluginType - The type of plugin described by this metadata. See SciJavaPlugin for a list of common plugin types.
annotation - The @Plugin annotation to associate with this metadata object.

PluginInfo

public PluginInfo(String className,
                  Class<PT> pluginType,
                  Plugin annotation,
                  ClassLoader classLoader)
Creates a new plugin metadata object.

Parameters:
className - The name of the class, which must implement SciJavaPlugin.
pluginType - The type of plugin described by this metadata. See SciJavaPlugin for a list of common plugin types.
annotation - The @Plugin annotation to associate with this metadata object.
classLoader - The ClassLoader to use when loading the class via loadClass(), or null to use the current thread's context class loader by default.

PluginInfo

public PluginInfo(Class<? extends PT> pluginClass,
                  Class<PT> pluginType)
Creates a new plugin metadata object.

Parameters:
pluginClass - The plugin class, which must implement SciJavaPlugin.
pluginType - The type of plugin described by this metadata. See SciJavaPlugin for a list of common plugin types.

PluginInfo

public PluginInfo(Class<? extends PT> pluginClass,
                  Class<PT> pluginType,
                  Plugin annotation)
Creates a new plugin metadata object.

Parameters:
pluginClass - The plugin class, which must implement SciJavaPlugin.
pluginType - The type of plugin described by this metadata. See SciJavaPlugin for a list of common plugin types.
annotation - The @Plugin annotation to associate with this metadata object.

PluginInfo

protected PluginInfo(String className,
                     Class<? extends PT> pluginClass,
                     Class<PT> pluginType,
                     Plugin annotation,
                     ClassLoader classLoader)
Method Detail

setPluginClass

public void setPluginClass(Class<? extends PT> pluginClass)
Explicitly sets the Class of the item objects.

This is useful if your class is produced by something other than the system classloader.


getPluginClass

public Class<? extends PT> getPluginClass()
Obtains the Class of the item objects, if that class has already been loaded.

Returns:
The Class, or null if it has not yet been loaded by loadClass().

setPluginType

public void setPluginType(Class<PT> pluginType)
Sets the type of plugin described by the metadata.

See Also:
for a list of common plugin types.

getPluginType

public Class<PT> getPluginType()
Gets the type of plugin described by the metadata.

See Also:
for a list of common plugin types.

getAnnotation

public Plugin getAnnotation()
Gets the associated @Plugin annotation.


getIconURL

public URL getIconURL()
               throws InstantiableException
Gets the URL corresponding to the icon resource path.

Throws:
InstantiableException
See Also:
AbstractUIDetails.getIconPath()

inject

public boolean inject(Object o)
Injects the metadata into the given object. Note that this is only possible if the given object implements the HasPluginInfo interface.

Parameters:
o - The object to which the metadata should be assigned.
Returns:
true If the metadata was successfully injected.

toString

public String toString()
Overrides:
toString in class AbstractUIDetails

getClassName

public String getClassName()
Description copied from interface: Instantiable
Gets the fully qualified name of the Class of the objects that can be created.

Specified by:
getClassName in interface Instantiable<PT extends SciJavaPlugin>

loadClass

public Class<? extends PT> loadClass()
                                                    throws InstantiableException
Description copied from interface: Instantiable
Loads the class corresponding to the objects that are created by Instantiable.createInstance().

Note that this class may not be precisely T.class but instead a subclass thereof.

Specified by:
loadClass in interface Instantiable<PT extends SciJavaPlugin>
Throws:
InstantiableException
See Also:
for an example of an {@code Instantiable} type that typically instantiates objects of a subtype of {@code T} rather than {@code T} itself.

createInstance

public PT createInstance()
                                        throws InstantiableException
Description copied from interface: Instantiable
Creates an object.

Specified by:
createInstance in interface Instantiable<PT extends SciJavaPlugin>
Throws:
InstantiableException

getIdentifier

public String getIdentifier()
Description copied from interface: Identifiable
Gets a string intended to function as an identifier for the object.

Specified by:
getIdentifier in interface Identifiable

getLocation

public String getLocation()
Description copied from interface: Locatable
Gets the URL string defining the object's location.

Specified by:
getLocation in interface Locatable

getVersion

public String getVersion()
Description copied from interface: Versioned
Gets the version of the object.

Specified by:
getVersion in interface Versioned


Copyright © 2009–2014 SciJava. All rights reserved.