Tutorials > Management Center > Extend the Recipes tool to support workspaces

< Previous | Next >


Enable workspace support for the service module

In this lesson, we will enable workspace support for the service module.

One key aspect of enabling workspaces support is classifying your data as managed content assets or managed operational assets. The distinction between content and operational data is discussed in detail in Workspaces data model. You need to understand whether the tables you want to manage using workspaces are content or operational before performing this task. The tables you are working with are all content managed. See Enable workspaces support for a custom table in an existing WebSphere Commerce BOD service module for more information


Procedure

  1. For the custom service module that you created for recipe, create the following file :

    WC_EAR\xml\content-management\com.mycompany.commerce.project.resource-managers.xml
    

  2. Open the file in a text or XML editor and add the following lines to beginning of the file:

    <wc:ResourceContainer xmlns:wc="http://www.ibm.com/xmlns/prod/WebSphereCommerce" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.ibm.com/xmlns/prod/WebSphereCommerce xsd/wc-resource-managers.xsd">
    <wc:Definition  name="ProjectResourceContainer" 
    className="com.ibm.commerce.context.content.resources.DSLResourceContainer">
    </wc:Definition> 
    

    The wc:Definition element defines the resource container that is used by the service module. All BOD service modules use className="com.ibm.commerce.context.content.resources.DSLResourceContainer" as shown in the example. The only value that you should change from the sample XML is the id. The value of the id is a unique integer, not previously used by WebSphere Commerce, or other workspace customizations. IBM reserves values ranging from 1 to 9999. Use a value over 10000.

  3. To add workspace support for a content managed table, add the following sample code to the file:

    <wc:ManagedResources>
    <wc:ManagedResource  name="XPROJECT" resource="XPROJECT"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPROJECT_ID">
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJDES" resource="XPRJDES"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPROJECT_ID,LANGUAGE_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPROJECT" />
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJMTR" resource="XPRJMTR"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPRJMTR_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPROJECT" />
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJMTRDES" resource="XPRJMTRDES"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPRJMTR_ID,LANGUAGE_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPROJECT" />
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJMTRCATREL"
                resource="XPRJMTRCATREL" resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPRJMTR_ID,STOREENT_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPROJECT" />
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPRJMTR" />
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJINS" resource="XPRJINS"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPRJINS_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPROJECT" />
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJINSDES" resource="XPRJINSDES"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPRJINS_ID,LANGUAGE_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPROJECT" />
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJCATREL" resource="XPRJCATREL"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPROJECT_ID,CATENTRY_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPROJECT" />
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJCOL" resource="XPRJCOL"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPRJCOL_ID">
            </wc:ManagedResource>
            <wc:ManagedResource  name="XPRJCOLDES" resource="XPRJCOLDES"
                resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPRJCOL_ID,LANGUAGE_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPRJCOL" />
            </wc:ManagedResource>
    <wc:ManagedResource  name="XPRJPRJCOLREL"
                resource="XPRJPRJCOLREL" resourceClassName=""
    resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager"
                managed="true" resourceKeys="XPROJECT_ID,XPRJCOL_ID">
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPRJCOL" />
                <wc:RelatedManagedResource
                    resourceContainer="ProjectResourceContainer"
                    managedResource="XPROJECT" />
            </wc:ManagedResource>
        </wc:ManagedResources>
    

    Notes:

    • The resource container is the name of the container that defines the related resource. The resource container is listed in the definition element. For example:

      <wc:Definition  name="ProjectResourceContainer" 
      className="com.ibm.commerce.context.content.resources.DSLResourceContainer">
      </wc:Definition> 
      

    • A managed resource element is required for each content managed table.

    • The related managed resource element relates one resource to another resource. For example, the XPRJDES, XPRJMTR, and XPRJMTRDES tables are related to the XPROJECT table. If an entry in the XPROJECT table is locked, the related data in the other three tables is also locked.

    • The managed resource IDs are unique per resource container. However, for any cases where you are adding managed resources to an existing WebSphere Commerce resource container, it is recommended that you use values greater than 10000, to avoid all possible collisions.

    • The resourceClassName attribute is always set to an empty string for Data Service Layer based implementations. This attribute is only used by workspaces in WebSphere Commerce Accelerator.

    • The resourceKeys attribute is the primary key of the table. For example resourceKeys="LANGUAGE_ID,STOREENT_ID".

  4. Close the file with the following lines:

    <wc:PublishRequest uniqueTransaction="false" />
    </wc:ResourceContainer>
    

    The <wc:PublishRequest> element is used to indicate whether to keep the transactions for this whole file (the resource container) separate from all others when a workspace is published. If set to true, the transactions for this resourceContainer are published separately. If set to false, transactions are grouped for all resourceContainers.

  5. From a command line, run ANT target: UpdateWorkspAccesschema to create the necessary tables and views in the workspaces for the tables that you have configured.

< Previous | Next >


+

Search Tips   |   Advanced Search