If you are using Oracle ATG Web Commerce as part of a multisite installation (see the ATG Multisite Administration Guide for general information on multisite features), you can include a processor that uses the current site ID to fork your processor chain. This allows you to specify different processing behaviors for different sites in your installation.

Site-based forking involves two components. The first is the /atg/commerce/CommercePipelineManager component. This component is based on the atg.commerce.pipeline.CommercePipelineManager, which extends the basic PipelineManager class. The CommercePipelineManager component adds the current site ID to the map of pipeline parameters (note, however, that if an ID is already in the parameter map, CommercePipelineManager does not override the existing value).

The CommercePipelineManager component includes the useSiteFromOrder property. If this property is set to true and there is no current site context, the CommercePipelineManager gets the site ID from the current order object instead of from the site context. This property is used for scheduled orders (see Scheduling Recurring Orders), for which no site context is available.

The second component used in site-based forking is the /atg/dynamo/service/pipeline/processor/SiteForkProcessor component. It includes a sitesMap property, which you configure to map your sites to numeric values as shown:

sitesMap=\
  siteA=1;\
  siteB=2

The SiteForkProcessor retrieves the site ID from the pipeline parameters map and uses its own sitesMap to find the corresponding number. If there is no number for the site, the component finds the list of sites that occupy the same sharing group (if any), and iterates over that list; when it finds an entry that does appear in the sites map, it returns the number associated with that site. If no site is found, the siteForkProcessor returns a value of 0. You can use this returned value to select among options in your pipeline chain.

In addition to the sitesMap, the SiteForkProcessor component has a shareableTypeId property. By default this value is not set. It can contain the ID of a shareable type such as the shopping cart. To find the valid shareableType items, look at the /atg/multisite/SiteGroupManager component. An example of a shareableType is atg.ShoppingCart.

The shareableTypeId can be null, in which case there must be an exact match between the site ID in the pipeline parameters and the site ID in the map.

For example, to insert a fork that processes differently based on which of two sites the user is visiting, configure your SiteForkProcessor component’s sitesMap property as shown:

sitesMap=\
  apparel=1;\
  home=2

Then create the following pipeline chain:

...
<pipelinelink name="SiteForkProcessor" transaction="TX_MANDATORY">
  <processor jndi="/myApp/pipeline/processor/SiteForkProcessor"/>
  <transition returnValue="1" link="apparelPipelineProcessor"/>
  <transition returnValue="2" link="homePipelineProcessor"/>
</pipelinelink>

<pipelinelink name="homePipelineProcessor" transaction="TX_MANDATORY">
  <processor jndi="/atg/commerce/HomeSiteProcessor"/>
  <transition returnValue="1" link="anotherProcessor"/>
</pipelinelink>

<pipelinelink name="apparelPipelineProcessor" transaction="TX_MANDATORY">
  <processor jndi="/atg/commerce/ApparelSiteProcessor"/>
  <transition returnValue="1" link="anotherProcessor"/>
</pipelinelink>