Oracle ATG Web Commerce provides the infrastructure for sharing non-Nucleus objects and other resources. In order to enable sharing of non-Nucleus components:

While the paths property of a NucleusComponentShareableType points to one or more Nucleus components such as a shopping cart, a ShareableType component requires you to write your own code in order to associate with it the objects that are shared within a site group. It is also possible to register a ShareableType component that has no objects associated with it; it exists solely in order to create site groups where membership is based on sharing an abstract condition or quality. The following examples outline both use cases.

Sharing Java Objects

You can use a ShareableType component in order to create site groups that share non-Nucleus components, such as Java objects or other resources. In order to do so, you must write your own code in order to associate these objects/resources with the ShareableType component, so they can be shared within a group that is configured with that ShareableType.

The following steps outline a simple implementation:

In this implementation, the Java class SharedTypeHandler is defined as follows:

package atg.test;
public class SharedTypeHandler
 String shareableTypeId;   // set from properties file, identifies ShareableType
 SharedObj globalObj=null; // share with all sites if shareableTypeId unregistered
 Hashmap<String, sharedObj> siteObjectMap; // maps each site to a SharedObj
 // get a site's SharedObj or globalObj
public SharedObj getSharedObject(){

  start pseudo code:

 get current site-id from SiteContextManager
 if site-id null
   return null
 else if site-id not null
   ask SiteGroupManager whether shareableTypeID is registered
     call SiteGroupManager.getShareableTypeById( shareableTypeId )
   if getShareableTypeById() returns null
     no site groups for shareableTypeID

     if globalObj property is null
       - create SharedObj instance with unique id
       - store SharedObj in globalObj and return globalObj
     else (globalObj property not null)
       return globalObj

   else if shareableTypeId registered
     get siteGroup ID from SiteGroupManager by calling
        getSiteGroup(siteId, shareableTypeId)

     if siteGroup ID null
       site-id does not belong to any group configured with shareableTypeID
       so give site-id its own copy of SharedObj:
         - create SharedObj instance with id property set to current site-id
         - save SharedObj in siteObjecMap map with the current site-id as key
         - return SharedObj
     else if siteGroup ID not null
       if site-id in siteObjecMap
         - return the associated SharedObj
       else if site-id not in siteObjectMap
         - get all site-ids in siteGroup with this siteGroup ID
         - create SharedObj instance with id property set to siteGroup ID
         - iterate over all sites in site group, map all site-ids to same
            SharedObj instance
         - return new SharedObj instance
  end pseudo code

Given this configuration, a JSP can obtain data from the sharedObj instance that the current site shares. For example, the following code renders the current site group ID:

<dsp:valueof bean="/atg/test/" />
Identifying Sites in a Sharing Group

A ShareableType component is not required to be associated with any objects at all; it might be used solely to create a site group where membership is based on sharing an abstract condition or quality. For example, the Oracle ATG Web Commerce reference application Commerce Reference Store groups sites that represent various geographical versions of the same store. Thus, it configures the ShareableType component RelatedRegionalStores:


# The shareable type ID used by application code

# Information used to find strings appropriate for localized UIs

This ShareableType component serves two goals:

The Commerce Reference Store application uses the ShareableType component RelatedRegionalStores to create a site group that includes two sites: ATG Store US and ATG Store Germany. The application’s JSP code uses the servlet bean SharingSitesDroplet to determine which sites share the sharing group RelatedRegionalStores with the current site. When ATG Store US is the current site, the servlet bean returns other sites in the group—in this case, ATG Store Germany—and vice versa. This approach allows addition of sites to the group (via Site Administration) without requiring code changes and application reassembly.

The JSP code renders a widget for each site group member: the current site is represented by an identifying label, while other sites are represented by hyperlinks:

  <dsp:importbean bean="/atg/multisite/Site"/>
  <dsp:importbean bean="/atg/dynamo/droplet/ComponentExists"/>
  <dsp:importbean bean="/atg/dynamo/droplet/ForEach" />
  <dsp:importbean bean="/atg/dynamo/droplet/multisite/SharingSitesDroplet" />

  <%-- Verify that this is an international storefront. If so, the Country portion
      of the site picker should be rendered. --%>
  <dsp:droplet name="ComponentExists">
    <dsp:param name="path" value="/atg/modules/InternationalStore" />
    <dsp:oparam name="true">

      <%-- Retrieve the sites that are in the Related Regional Stores sharing
          group with the current site. --%>
      <dsp:droplet name="SharingSitesDroplet">
        <dsp:param name="shareableTypeId" value="crs.RelatedRegionalStores"/>
        <dsp:oparam name="output">

          <dsp:getvalueof var="sites" param="sites"/>
          <dsp:getvalueof var="size" value="${fn:length(sites)}" />

          <c:if test="${size > 1}">

            <%-- Get the site ID for the current site. The current site should not
                be rendered as a link in the site picker. --%>
            <dsp:getvalueof var="currentSiteId" bean=""/>

            <div id="atg_store_regions">
                <fmt:message key="navigation_internationalStores.RegionsTitle" />
                <fmt:message key="common.labelSeparator"/>

                <dsp:droplet name="ForEach">
                  <dsp:param name="array" param="sites"/>
                  <dsp:setvalue param="site" paramvalue="element"/>
                  <dsp:param name="sortProperties" value="-countryDisplayName"/>

                  <dsp:oparam name="output">
                    <dsp:getvalueof var="size" param="size"/>
                    <dsp:getvalueof var="count" param="count"/>
                    <dsp:getvalueof var="countryName"
                    <dsp:getvalueof var="siteId" param=""/>

                    <li class="<crs:listClass count="${count}" size="${size}"
                        selected="${siteId == currentSiteId}" />">

                        <%-- For the current site, render its name only. --%>
                        <c:when test="${siteId == currentSiteId}">
                          <dsp:valueof value="${countryName}" />

                        <%-- For other sites, render a cross-site link. --%>
                          <%-- this page uses SiteLinkDroplet to create a link
                          from the supplied site ID and customURL value --%>
                          <dsp:include page=
                            <dsp:param name="siteId" value="${siteId}"/>
                            <dsp:param name="customUrl" value="/"/>
                          <dsp:a href="${siteLinkUrl}"


When on the ATG Store US site, the code renders the following output, where the display name for the current site, United States, is rendered as a label, while a hyperlink is generated for the ATG Store Germany site:

This diagram described in preceding text

Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices