In a multisite environment, site groups and individual non-grouped sites might each require access to the same shared component. For example, the site group US_StoresGroup might contain two member sites: RetailSite and OutletSite, where both sites share the same ShoppingCart component. Two non-grouped sites—EuroSite and ChinaSite—each have their own ShoppingCart component. If a user in the same session accesses sites US_StoresGroup.RetailSite and EuroSite, two separate ShoppingCart instances must be created and managed, and each client request on a ShoppingCart must be relayed to the appropriate instance.

To handle this, Nucleus relies on a cglib2-based proxying mechanism that creates and maintains unique ShoppingCart instances for each site group and ungrouped site, and maintains a ProxyCallback map for relaying each ShoppingCart request to the appropriate instance.

In general, Nucleus processes all component requests in a multisite environment as follows:

  1. Checks whether the component can be shared—that is, the component is referenced by a registered ShareableType.

  2. For a shared component, invokes one of the installed Proxy Factories to create:

    • A cglib2-based proxy that intercepts all calls to this component.

    • An atg.service.proxy.multitarget.ProxyCallback object, which maps method invocations to the appropriate context-specific proxy target component.

The ProxyCallback creates, as needed, a proxy target component for each site group that uses the shared component; it also creates a proxy target component for each site that does not belong to any group.

Viewing Shared Components

A shared component’s proxy is visible to debugging and administrative tools such as ATG Dynamo Server Admin. The ATG Dynamo Server Admin also lets you view proxy target components for a given site group through its Component Browser Context page.

Restricting Access to Proxy Target Components

A proxy target component such as a ShoppingCart cannot return a direct reference to itself to the calling code. This provides basic protection from invocations that inadvertently circumvent the ShoppingCart proxy, which should intercept and route all calls. However, by following references that eventually lead back to the proxied ShoppingCart, it is possible to circumvent this protection. For example, care should be taken to prevent the proxy target component from returning references that can be used, in turn, to obtain a reference to the parent object.

The following graphic shows how proxying might handle invocations on a shared ShoppingCart component:

Proxy Factories

Nucleus uses two extensions of the MultiTargetComponentProxyFactory: