The Core Platform includes a site context system for associating requests with specific sites. Tracking the site context is essential for ensuring the correct site-aware data is made available and the proper site-aware behavior is exhibited. All of the mechanisms discussed in the Sharing Resources section rely on the site context system.
Key elements in the site context system include:
The
SiteContextPipelineServletis a servlet in the request-handling pipeline. It examines each incoming request and applies various rule checks to determine the site to associate the request with. For example, it can associate a request with a site based on the request URL, as described in URL Management.A
SiteContextobject tracks information about a site for the current request. For a given request, there can beSiteContextobjects for one or more sites. At any given point in the handling of the request, oneSiteContextis current. TheSiteContextManagercomponent managesSiteContextobjects, making differentSiteContextobjects current as needed.A
SiteSessionobject tracks information about a site for the current session. For a given session, there can be separateSiteSessionobjects for some or all of the sites. TheSiteSessionManagercomponent managesSiteSessionobjects.
You can use the Site Context API to control the site context in your application. For example, you can write rule filters for the SiteContextPipelineServlet that modify the logic for associating a request with a site. You can also change the current site in the course of handling a request. For example, suppose a page on site A includes a targeter displaying recommended products from site B. To do this, the targeter needs to execute within the context of site B. (See Page Development for information about how this is accomplished.)
JMS Events
Many JMS message classes now have a siteId property for specifying the site where an event is fired. Event senders use the current site context to set the value of this property. Systems that receive these messages can then use this information to affect system behavior. For example, siteId can be used to set the site in an action parameter for a scenario that is triggered by the event. Site information in events can be logged and loaded into the Data Warehouse for use in reporting.

