Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is context object design pattern?

what is context object design pattern ?

like image 431
Isabel Jinson Avatar asked Apr 21 '09 10:04

Isabel Jinson


People also ask

What is the context object?

The context object is an internal JSON structure that is available during an execution, and contains information about your state machine and execution. This allows your workflows access to information about their specific execution. You can access the context object from the following fields: InputPath. OutputPath.

What is a context object in Java?

A Context object contains a list of properties in the form of NamedValue objects. These properties represent information about the client, the environment, or the circumstances of a request and generally are properties that might be inconvenient to pass as parameters.

Is context an Antipattern?

Context is an anti pattern, since it is used as a container for what is unknown a priori.

What is context in Java programming?

A Context represents your environment. It represents the state surrounding where you are in your system. For example, in web programming in Java, you have a Request, and a Response. These are passed to the service method of a Servlet. A property of the Servlet is the ServletConfig, and within that is a ServletContext.


2 Answers

A Context is a collection of data, often stored in a Map or in a custom class which acts as a struct with accessors and modifiers. It is used for maintaining state and for sharing information within a system. See this PDF for an indepth description. Though it can be used for efficient and effective data sharing, you should note that many are wary of the Context pattern as an anti-pattern.

like image 159
akf Avatar answered Oct 16 '22 00:10

akf


An example for it might be the HttpSession object: you have attributes which is basically a map with String keys and Object elements. This provides state information between http requests. Another example is the ServletRequest which provides state information between Servlets.

like image 25
Tamas Rev Avatar answered Oct 16 '22 02:10

Tamas Rev