Business context service

The business context service manages contextual information used by business components. The information is encapsulated within different types of business contexts, this process formalizes the context infrastructure and fosters reuse between different business models.

The abstraction of user contextual information permits:

Before the logic to process the operation is invoked, contextual information is set up and managed by the business context service. After the processing is complete, business context service is invoked to handle any post processing of the context information such as persistence. In the business context model, a client invokes a service to perform an operation. Optionally, the client might receive a response. An example of a business service is a service that helps a company fulfill the needs of its customers. Multiple services can be logically grouped into business components. A component specializes in a function such as catalog management or tax calculation.

The following diagram shows the artifacts in the business context model.

Solution controller

A solution controller is responsible for managing the activity or activities of a user. In the WebSphere Commerce Struts framework the solution controller exists as part of the base action. In the Sales Center the solution controller exist as part of the rich client application. The client performs a limited set of actions while the solution controller provides the additional BCS process hooks.

Activity token

An identifier for an activity which spans multiple requests and transactions. An activity usually begins when a user logs on to the site and ends when a user logs off. The activity token is unique for each caller, run-as user, and store.

The activity token groups the set of contexts effective during a particular client's request to the various business components. The client supplies this activity token on every request to indicate the experience that it would like from the business components. Usually, the solution controller initiates a request to business context service to request for an activity token.

Business components

A business component groups a set of related services together and a service provides a specialized function. It interacts with business context service to signifies the beginning and the end of a request such that any pre and post processing on business contexts can be done. Also, components can retrieve and update various business context during the execution of a request.

Business Context Engine

The business context engine (BCE) provides contexts that dictate the behavioral characteristics of business components over the lifetime of the session. The business context engine is comprised of the Business Context Service and Business Contexts.

Business Context Service

The solution controller uses the business context service (BCS) to manage contexts required by business components. BCS is also an interface used by the components to obtain contexts they need. Multiple unique contexts, used by various business components, are associated under a single identifier, known as an activity, for a limited lifetime. The lifetime of an activity spans multiple requests and transactions. The contexts associated with an activity maintain their state for the lifetime of the activity. BCS also manages a cache of the business contexts associated with an activity within a request. This cache saves resources that would otherwise be used to initialize and destroy multiple business contexts used in the same request.

Business Contexts

Business contexts have the following characteristics:

  • A context establishes an execution environment that affects the output of a business component for the equivalent input based on the solution needs.

  • The output produced by a component for a given input is always identical for the same set of contexts.

  • Contexts are not directly invoked by clients of the business processes. Instead it is the business component that uses the services provided by the contexts during the execution of a request.

  • A context provides a set of service methods and may optionally store session data that does not change very often over an activity lifespan.

  • The lifespan of a context starts with the creation of an activity and ends with the completion of the activity.

  • Each business context implements two interfaces:

    • ContextSPI

      • The ContextSPI interface defines methods for business context service to indicate events such as the beginning of an activity, the start and end of a request.

    • Context

      • The Context interface is extended by each business context which defines methods for business logic to use to retrieve context specific information.

    WebSphere Commerce predefines the following contexts:

    BaseContext

    This context contains the basic attributes that an activity needs, such as store ID, caller ID, and the run-as ID.

    EntitlementContext

    This context holds information about entitlement criteria, such as reduced prices for gold club membership.

    GlobalizationContext

    This context helps components determine locale-specific information such as what language a message should be rendered in, or what currency should be used in the calculation of a price.

    ContentContext

    If Workspaces are enabled, this context determines the content or business objects that can be displayed or edited based on versioning information.

    TaskContext

    If Workspaces are enabled, this context determines which task an administrator is currently performing.

    AuditContext

    This context is usually provided by third party components. You might want to bridge the gap to the third party interface instead of programming to it directly. This context enables you to connect to a different vendor's implementation of the service in the future without the need to rewrite your component.

    PreviewContext

    The preview context is the attempt to solve both problems by allowing multi-users to validate independent content without influencing other users and ensuring the content does not required additional changes after validation. In order to achieve this, a context object will be associated with the preview operation that will represent the state information that will be used when deciding the content to preview along with other external events. By associating a preview context with an activity, operations can use this content state information as a basis to decide what content to display. To solve the date issue, the preview context will contain the preview date which will be used to render the content to be display. By having activities having a unique preview context, this will allow multiple users to preview independent content without having to change content data or global system state information.

    ExperimentContext

    ExperimentContext is used to store the result of all active experiments for individual users, where result is a system-generated number which determines the control or test element to be selected in the experiment. This information is persisted throughout the user session, so the same result will be used in the same session without re-generation of the number.

Business Context Sets

Business contexts are grouped together in business context sets. A business context set is a logical grouping of business contexts for a particular type of request. Different context sets can be configured for requests coming from different Web applications. For example, requests that are initiated from the Accelerator web application need to include content and task contexts for authoring purposes, while requests from the store web application do not have this requirement. This implementation provides these advantages:

  • It improves performance, unneeded business contexts do not need to be initialized. For example, when customers browse the catalog in the storefront, they do not need the presence of the PreviewContext which is for previewing purposes in the authoring environment.

  • It provides security benefits. For example, requests from the Stores Web application do not need to enable the PreviewContext which removes the preview functionality from the customer.

Related tasks

Define business context sets for a Web application

Related reference

Business Context configuration file
Sequence diagram: Creating a new activity based on an existing one
Sequence diagram: Initiating an activity
Sequence diagram: Pre-request and post-request processing
Sequence diagram: Retrieving and updating business contexts
Sequence diagram: Terminating an activity