net.sf.genuine.organizer
Class AbstractModule

java.lang.Object
  extended bynet.sf.genuine.organizer.AbstractModule
All Implemented Interfaces:
Module
Direct Known Subclasses:
DefaultActionModule, PreferencesModule

public abstract class AbstractModule
extends java.lang.Object
implements Module

This class is a default implementation of the Module interface that does nothing by itself but provides convenience methods. It is intended to be sub classed by module classes for which it implements common functionality.

Author:
Tim Wellhausen

Constructor Summary
AbstractModule()
           
 
Method Summary
 VisualComponent createVisualComponent(java.lang.String componentId, java.lang.String instanceId)
          Default implementation does nothing.
 GenuineAction getAction(java.lang.String actionId)
          Implementation of the Module's getAction method that returns GenuineAction instances that have been registered by calling registerAction(GenuineAction).
protected  ComponentManager getComponentManager()
          Convenience method that returns the component manager
protected  HelperService getHelperService()
          Convenience method that returns the helper service
 java.lang.String getId()
          Returns this module's id.
protected  MessageBus getMessageBus()
          Convenience method that returns the message bus
protected  ModuleManager getModuleManager()
          Convenience method that returns the module manager
protected  java.lang.String getProperty(java.lang.String propertyName)
          Returns the value for a property that was passed to the initialize method.
 Service getService(java.lang.Class serviceType)
          Implementation of the Module's getService method that returns Service instances that were registered by using the method registerService(Class, Service).
protected  ServiceBroker getServiceBroker()
          Convenience method that returns the service broker.
 void initialize(java.lang.String moduleId, ModuleManager moduleManager, java.util.Map properties)
          The references to the passed parameters are stored locally.
 void postInitialize()
          Default implementation that does nothing.
protected  void registerAction(GenuineAction action)
          Helper method for modules to register actions so that the module manager may retrieve them by calling getAction(String).
protected  void registerService(java.lang.Class serviceInterface, Service service)
          Helper method for modules to register service instances so that the service broker may retrieve them by calling getService(Class).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractModule

public AbstractModule()
Method Detail

initialize

public void initialize(java.lang.String moduleId,
                       ModuleManager moduleManager,
                       java.util.Map properties)
                throws ConfigurationException
The references to the passed parameters are stored locally.

Specified by:
initialize in interface Module
Parameters:
moduleId - The module's unique identifier that is defined in the application's configuration file.
moduleManager - A reference to the ModuleManager that gives access to all services the Organizer provides to modules.
properties - A collection of properties that has been defined for this module in the application's configuration file. For each key, there is either an Object value or a Set of Object values, depending on the XML configuration data. For each property defined, there is a Object value, for each propertyset defined, there is a Set of Object values. If the value is an integer, the value instance is of type Integer, otherwise the value instance is of type String. A Set instance is actually an instance of LinkedHashSet so that the order of values is kept as in the configuration file if you iterate over them.
Throws:
ConfigurationException - Thrown by the module if a severe error occurs during its initialization so that the module cannot operate.

getId

public java.lang.String getId()
Returns this module's id.

Specified by:
getId in interface Module

getModuleManager

protected ModuleManager getModuleManager()
Convenience method that returns the module manager


getServiceBroker

protected ServiceBroker getServiceBroker()
Convenience method that returns the service broker.


getComponentManager

protected ComponentManager getComponentManager()
Convenience method that returns the component manager


getMessageBus

protected MessageBus getMessageBus()
Convenience method that returns the message bus


getHelperService

protected HelperService getHelperService()
Convenience method that returns the helper service


getProperty

protected java.lang.String getProperty(java.lang.String propertyName)
Returns the value for a property that was passed to the initialize method. Properties are defined in the XML configuration data for each module.

Parameters:
propertyName - The name of a property as defined in the configuration data of the module.
Returns:
The value as defined in the configuration data of the module for the given property.

registerAction

protected void registerAction(GenuineAction action)
Helper method for modules to register actions so that the module manager may retrieve them by calling getAction(String).

Parameters:
action - A fully initialized GenuineAction object whose identifier must match an action reference in the XML configuration data.

getAction

public GenuineAction getAction(java.lang.String actionId)
Implementation of the Module's getAction method that returns GenuineAction instances that have been registered by calling registerAction(GenuineAction).

Specified by:
getAction in interface Module
Parameters:
actionId - The identifier of an action as used in the XML configuration data, for example for a menu item or a toolbar button.
Returns:
The GenuineAction object that has been registered before or null.

createVisualComponent

public VisualComponent createVisualComponent(java.lang.String componentId,
                                             java.lang.String instanceId)
                                      throws ConfigurationException
Default implementation does nothing. Override this method and create visual components there.

Specified by:
createVisualComponent in interface Module
Parameters:
componentId - The id of the component as given in the XML configuration data
Throws:
ConfigurationException

registerService

protected void registerService(java.lang.Class serviceInterface,
                               Service service)
Helper method for modules to register service instances so that the service broker may retrieve them by calling getService(Class). Services have to be created and initialized upon the initialization of the module.

Parameters:
serviceInterface - The service interface that is implemented by the service object
service - The actual service instance

getService

public Service getService(java.lang.Class serviceType)
Implementation of the Module's getService method that returns Service instances that were registered by using the method registerService(Class, Service).

Specified by:
getService in interface Module

postInitialize

public void postInitialize()
Default implementation that does nothing. This method may be overridden if the module needs to perform some initialization after the module manager has finished initilizing all modules.

Specified by:
postInitialize in interface Module