org.apache.avalon.framework.context
Interface Context

All Known Implementing Classes:
DefaultContext

public interface Context

The context is the interface through which the Component and it's Container communicate.

Each Container-Component relationship will also involve defining a contract between two entities. This contract will specify the services, settings and information that is supplied by the Container to the Component.

This relationship should be documented in a well known place. It is sometimes convenient to derive from Context to provide a particular style of Context for your Component-Container relationship. The documentation for required entries in context can then be defined there. (examples include MailetContext, BlockContext etc.)

There are traditionally four differet types of Context that may be used in a system. These ideas are partially derived from linguistic theory and partially from tradition computer science;

  1. World Context / Per-Application context: This describes application wide settings/context. An example may be the working directory of the application.
  2. Person Context / Per-Component context: This contains context information specific to the component. An example may be the name of the component.
  3. Conversation Context / Per-Session context: This contains context information specific to the component. An example may be the IP address of the entity who you are talking to.
  4. Speach Act Context / Per-Request context: This contains information about a specific request in component. Example may include the parameter submitted to a particular web form or whatever.

When we implement this (1) and (2) are generally merged into one interface. For instance in the Pheonix Application Server there is a BlockContext. Part of the BlockContext consists of two methods. One is getHomeDirectory() and that belongs to (1) while the other is getName() which belongs to (2).

(4) is usually passed into a service() style method as parameters. Often it will named something like RequestObject. So you may have something like:

 void doMagic( int param1, int param2, Context otherParamsInHere );
 

When (3) is needed in the system it is usually also passed into the a serice method method, along with the request context (4). Alternatively it is made available via the context representing (4).

Author:
Federico Barbieri, Pierpaolo Fumagalli, Stefano Mazzocchi, Peter Donald

Method Summary
 java.lang.Object get(java.lang.Object key)
          Retrieve an object from Context.
 

Method Detail

get

public java.lang.Object get(java.lang.Object key)
                     throws ContextException
Retrieve an object from Context.
Parameters:
key - the key into context
Returns:
the object
Throws:
ContextException - if object not found. Note that this means that either Component is asking for invalid entry or the Container is not living up to contract.


"Copyright © 2001 Apache Jakarta Project. All Rights Reserved."