Business Context configuration file
Default business contexts are defined in the xml/config/businessContext.xml file. The location of the file is defined in the BusinessContextService/BusinessContextConfigFile attribute in WebSphere Commerce configuration file (xml/wc-server.xml). Multiple file locations separated by commas are allowed for this attribute to support component-based development. That is, when creating a new business context, instead of modifying the default configuration file, we can define it in a separate file and append it to the end of the BusinessContextConfigFile attribute on the BusinessContextService element. This implementation allows for future upgrade to the businessContext.xml file without affecting the business context that you have registered.
In the configuration file, there are two major sections.
- BusinessContexts which defines the different business contexts available to the site
- InitialBusinessContextSets defines the business context set which is a logical grouping of business contexts for a particular type of request. If no business context set is defined for the request, the default business context set is used.
- BusinessContexts
- The root element in the configuration file, defined in the xml/config/businessContext.xml file. This elements contains the following required attributes:
- xmlns
- Define the default XML namespace for elements and attributes in the document.
- xmlns:xsi
- Define the XML namespace with prefix xsi, http://www.w3.org/2001/XMLSchema-instance.
- xsi:schemaLocation
- Define the location of the XML schema file for the document, xsd/businessContext.xsd.
- BusinessContext
- Defines the initialization properties of a business context.
- ctxId
- A required attribute that identifies the business context within the configuration file. This identifier is necessary when defining contexts within a business context set. The following attributes can be specified:
- BaseContext
- This context must always exist for an activity and the combination of its values is unique across all activities in a system. In WebSphere Commerce all operations are invoked by a member and performed on a store. A user may act on behalf of another user in the system thus a user essentially has two member identities the callerId and the runAsId. The callerId is used to indicate the true identity of the user and the runAsId is used by the business logic for execution. Thus the Base Context consists of the callerId, runAsId, and storeId. The base context is used by every component in the WebSphere Commerce as every component needs to know under what store an operation is performed.
WebSphere Commerce predefines the following contexts:
- EntitlementContext
- GlobalizationContext
- ContentContext
- TaskContext
- AuditContext
- PreviewContext
- ExperimentContext
- factoryClassname
- A required attribute that specified the name of the class that creates the business context object. This factory class must implement the BusinessContextFactory interface. A default SimpleBusinessContextFactory class is provided out of the box which creates a business context based on a given implementation class name. An abstract class, called AbstractBusinessContextFactory, is also provided to aid the creation of any customized factory class. To create a factory class, two methods, createContextSPI and destroyContextSPI, must be implemented to create and destroy a particular business context.
- parameter
- Parameters are passed to the factory class and are used to create the business context. By default, the SimpleBusinessContextFactory class uses the implementation class name of the business context as parameter. Another usage of this parameter attribute is when initial values must be set at business context creation time. A custom business context factory can then be implemented to take in these initial values as parameters elements and populate the created business context accordingly.
- InitialBusinessContextSets
- Defines a business context set. Different business contexts can be grouped together into a business context set. Multiple business context sets can be defined in the configuration file. Each business context set contains multiple business contexts and they are created in the order specified by the createOrder attribute. The creatdOrder attribute value is an integer. The business context with the smallest value will be created first meaning the value of 0 will be the first one to be created.
Related concepts
Business context service
Related tasks
Defining business context sets for a Web application
Creating a new business context
Related reference
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