| java.lang.Object ti.chimera.Plugin
All known Subclasses: ti.chimera.plugin.WindowManagerPlugin, ti.chimera.plugin.AbstractModePlugin, ti.chimera.plugin.SwingWorkerPlugin,
Plugin | abstract public class Plugin (Code) | | The abstract base class for all plugins. This class provides an easy to
use framework for adding modules to chimera, and a mechanism to
manage resources created by this plugin.
The plugin class itself should be a lightweight container for all the
resources created and/or provided by the plugin. The plugin class will
be instantiated at startup regardless of whether the plugin is actually
started. As much as possible, all resources created by a plugin should
not be created until the the plugin is started. This can be accomplish
by using managed resources.
The
Resource mechanism is used for managing resources created by
this plugin. A plugin is active (ie. running) whenever it has installed
resources, and it is in-active (ie. stopped) whenever all it's resources
have been uninstalled. There are two types of resources that can be
created (see
Plugin.addResource , managed, and unmanaged.
A managed resources is automatically
Resource.install ed when the
plugin is started, and
Resource.uninstall ed when the plugin is
stopped. An unmanaged resource is
Resource.install ed when it
is added (
Plugin.addResource ), and
Resource.uninstall ed when
it is removed (
Plugin.removeResource ). Adding an unmanaged resource
will cause the plugin to become active, if it wasn't already active, and
removing an unmanaged resource could cause the plugin to become inactive
if there are no more unmanaged resources.
author: Rob Clark version: 0.1 |
Inner Class :public class ViewResource extends Resource | |
Inner Class :public interface ViewFactory | |
Inner Class :public class ToolBarResource extends Resource | |
Inner Class :public interface ToolBarFactory | |
Inner Class :public class MenuBarItemResource extends Resource | |
Field Summary | |
protected Main | main The main application. |
main | protected Main main(Code) | | The main application.
|
Plugin | public Plugin(Main main, String name)(Code) | | Class Constructor.
Parameters: main - the main application Parameters: name - the name of this plugin instance |
addResource | public synchronized void addResource(Resource r)(Code) | | Add a resource. If the resource is unmanaged, this could cause the
plugin to become active if it is not already. This does nothing if
the resource has already been added.
Parameters: r - the resource to add See Also: Plugin.removeResource |
getName | public String getName()(Code) | | Get the name of this plugin instance.
the name |
getServiceFactories | Iterator getServiceFactories()(Code) | | Used by registry to determine services provided by plugin.
|
registerService | final public void registerService(Service s)(Code) | | |
registerServiceFactory | final public synchronized void registerServiceFactory(ServiceFactory sh)(Code) | | Register a service provided by this plugin. The serviced provided by
the plugin should be registered by the plugin's constructor, rather
than by the
Plugin.start method, so that the registry can determine
which services are provided by which plugin.
A service is registered via a
ServiceFactory , which should be
the one to actually create an instance of the service. This is done
this way because the registry tracks the instances of a service, and
adds/removes managed resources to when a service instance is created/
GC'd. If the registry, or any other code, where to hold a reference
to the service itself, rather than the service-factory, the service
would never get garbage collected.
The only reason this method is public is for the benefit
of plugins implemented as script. The way the ObjectScript interpreter
works, script code only has access to public methods of a class. This
method should be treated as if it were protected .
Parameters: sh - a factory to a service provided by this plugin |
registerServiceFactory | final public void registerServiceFactory(Value fxn)(Code) | | This is provided to make life easy for script code... script code can
simply pass in a function that returns a service, rather than having
to pass in an instance of
ServiceFactory .
Parameters: fxn - a script function that takes no args and returnsa instance of a service |
removeResource | public synchronized void removeResource(Resource r)(Code) | | Remove a resource. If the resource is unmanged, and there no more
unmanaged resources, this will cause the plugin to become inactive.
This does nothing if the resource has not already been added.
Parameters: r - the resource to add See Also: Plugin.addResource |
toString | public String toString()(Code) | | Overloaded to provide some info about the state of the plugin, which
might be useful while debugging/developing plugins.
a string |
|
|