Presentation layer contexts exist in an unlimited context tree that organizes the contexts in a hierarchy from general to specific. Within the tree, a context has a parent context and may have one or more child contexts. The exception to this is a root context, which does not have a parent and must be unique in the JVM. The following diagram is an example of a context tree:
The parent context is more general in nature and its children are more specific, which enables processes and services to process the tree in a structured and flexible way to access the resources they need. For example, a context holds user-specific data and one of its child contexts holds service data. In the chain of responsibility pattern that the toolkit uses for contexts, if the service requires some data element or service but the toolkit does not find it in the service context, the toolkit then searches in the parent of that context. The toolkit continues to search upward in the context tree until it finds the data needed for the service or EJB invocation or it reaches the root context. The set of contexts in which the toolkit searches is called the context chain.
Note The length of the chain can vary. For example, there may be few contexts in the chain between the process context and the root context. For other processes, there may be many contexts in the chain.