fr.umlv.tatoo.cc.common.extension
Class ExtensionBus

java.lang.Object
  extended by fr.umlv.tatoo.cc.common.extension.ExtensionBus

public class ExtensionBus
extends Object

Author:
Remi

Nested Class Summary
static interface ExtensionBus.Context
          Extension bus context used by the extension to retrieve all data using the data keys previously registered by the for extension.
static class ExtensionBus.DataKey<D>
          Marker class for all data keys.
static interface ExtensionBus.Registry
          Extension specific registry used by the extension bus to indicate which data keys are required by an extension.
 
Constructor Summary
ExtensionBus()
           
 
Method Summary
 void loadAndRegisterExtension(Class<? extends Extension> extensionClass)
          Loads an extension an register it on the bus.
 void loadAndRegisterExtension(String extensionClassName)
          Loads an extension and register it on the bus.
<D> void
publish(ExtensionBus.DataKey<D> dataKey, D data)
          Publishes a data with its data-key.
 void register(Extension extension)
          Registers an extension to the current bus.
 void register(SimpleExtension extension, ExtensionBus.DataKey<?>... dataKeys)
          Registers a simple extension to the current bus.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionBus

public ExtensionBus()
Method Detail

register

public void register(Extension extension)
Registers an extension to the current bus. This method called Extension.register(ExtensionBus.Registry) in order to register all data keys needed by the extension. The same extension object can be registered several times using this method.

Parameters:
extension - the extension to register.

register

public void register(SimpleExtension extension,
                     ExtensionBus.DataKey<?>... dataKeys)
Registers a simple extension to the current bus. The same simple extension object can be registered several times using this method.

Parameters:
extension - the simple extension to register.

publish

public <D> void publish(ExtensionBus.DataKey<D> dataKey,
                        D data)
Publishes a data with its data-key. This method can call some extensions if the data published was the last data wait by the extension.

Parameters:
dataKey - the key of the data
data - the data

loadAndRegisterExtension

public void loadAndRegisterExtension(String extensionClassName)
Loads an extension and register it on the bus. The classe take as argument must have a default public constructor and must be a subtype of Extension.

Parameters:
extensionClassName - the class name of the extension.
See Also:
loadAndRegisterExtension(Class), register(Extension)

loadAndRegisterExtension

public void loadAndRegisterExtension(Class<? extends Extension> extensionClass)
Loads an extension an register it on the bus. The classe take as argument must have a default public constructor and must be a subtype of Extension.

Parameters:
extensionClass - the class of the extension.
See Also:
loadAndRegisterExtension(String), register(Extension)