Thursday, August 4, 2011

All about BCS or Business Context Services

About Business Context in WCS
In previous releases, the context information was stored in the Command Context object.
With the introduction of Business Context in this release, this information are now stored in various business contexts. Command Context becomes a helper class that wraps on top of these business contexts.
One can directly retrieve the same piece of information by retrieving the appropriate business context by using the CommandContext.getContext(businessContextName) method.
Information that is not available from business contexts, remains available and local to the Command Context object.
A command can get the following key information from the command context
Or
Contextual informations are encapsulated in to different Business Contexts. Such as EntitlementContext, CommandContext etc
BCS(Business Context Services) manages information used by Business Contexts

What is Context?

What is Business Context Services? 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
What is Business Context

What is Command Context?
 Commands can obtain information using the command context.
 Examples of information available include the user's ID, the user object, the language identifier, and the store identifier. When writing a command, you have access to the command context by calling the getCommandContext() method of the command's superclass. The command context is set to the controller command when the command is invoked by the component facade.  A controller command should propagate the command context to any task or controller commands that are invoked during processing
 BaseContext baseContext = (BaseContext)getCommandContext().getContext(BaseContext.CONTEXT_NAME);
 baseContext.getRunAsId();
 baseContext.getStoreId()
 baseContext.getUserId()
 baseContext.getUser()
 baseContext.getStore()
 GlobalizationContext globalizationContext = (GlobalizationContext)getCommandContext().getContext(GlobalizationContext.CONTEXT_NAME);
 globalizationContext.getLanguageId();
 globalizationContext.getCurrency(); 
 getCurrentTradingAgreements()
 getCurrentTradingAgreements(CommandContext)


List all type of Business Context public interface Context
 public interface CommandContext
 public class PromotionContext
 public interface BaseContext

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

 EntitlementContext
 Contains the contract information associated with the user
 This context holds information about entitlement criteria, such as reduced prices for gold club membership.

 GlobalizationContext
 Contains the globalization/locale information assosiated with the session
 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.

 CatalogContext
 This context contains information related to the catalog in the current session, such as the catalog ID, the catalog owner,
 and whether this is a master catalog or not.

 GiftRegistryContext
 This context contains gift registry information for a user in the current session, such as a list of gift registries that  the user has accessed, the relationship the user has to specific gift registries (gift giver, registrant or coregistrant), and the external ID of the gift registry the user is currently managing

BipinContext !!
No kidding.. It is possible You can create your own Context. Read the steps given below

Examples of Business Context and how to use it?

How to create new Business Context?

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, you 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.

Refer details here
http://www.ibm.com/developerworks/websphere/tutorials/0701_deluca/section6.html

2 comments:

  1. Hi Bipin and followers,

    I have just, quickly, went thru this blog and it is really helpful for the developers.

    Actually, I am looking for a solution for the issue which I have and could not resolve.

    Issue: One of the e-content spot printing £ symbol as ?.

    Actual Sting: "Standard Delivery £6.95"
    Printing String: "Standard Delivery ?.95"

    Just giving the code snippet how we are calling e-spot from JSP.

    ....

    ...


    ...

    ...

    Even I tried with charEncoding attribute. It is not helpful.

    Please post the solution if you get.

    Thanks,
    -Ramu.

    ReplyDelete
  2. Could noy put JSP code above. Used c:import to load e-content spot.

    Thanks,
    -Ramu.

    ReplyDelete