org.carrot2.core
Interface IControllerContext


public interface IControllerContext

The controller context is a map of key-value pairs, attached to an initialized Controller instance. The context is created in Controller.init() methods and remains valid until Controller.dispose() is invoked.

The context instance is passed to all components that take part in query processing inside the controller object (IProcessingComponent.init(IControllerContext)). IProcessingComponent implementations may use the context object to store data shared between all component instances (such as thread pools, counters, etc.). In such scenario it is essential to remember to attach a IControllerContextListener and clean up any resources when the controller is destroyed.

See Also:
Controller.init(), Controller.dispose(), IProcessingComponent.init(IControllerContext)

Method Summary
 void addListener(IControllerContextListener listener)
          Adds a IControllerContextListener to this context.
 Object getAttribute(String key)
          Atomically retrieves the value for a given key.
 void removeListener(IControllerContextListener listener)
          Removes a IControllerContextListener from this context.
 void setAttribute(String key, Object value)
          Atomically binds the given key to the value.
 

Method Detail

setAttribute

void setAttribute(String key,
                  Object value)
Atomically binds the given key to the value. Component implementors are encouraged to use custom namespaces to avoid conflicts.


getAttribute

Object getAttribute(String key)
Atomically retrieves the value for a given key. Component implementors are encouraged to use custom namespaces to avoid conflicts.


addListener

void addListener(IControllerContextListener listener)
Adds a IControllerContextListener to this context.


removeListener

void removeListener(IControllerContextListener listener)
Removes a IControllerContextListener from this context.



Copyright (c) Dawid Weiss, Stanislaw Osinski