|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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;
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).
Method Summary | |
java.lang.Object |
get(java.lang.Object key)
Retrieve an object from Context. |
Method Detail |
public java.lang.Object get(java.lang.Object key) throws ContextException
key
- the key into context
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |