This section describes the configuration steps you must take before performing a database switch of the data source used by the product catalog and price lists on your Web site. You must complete this process before performing an initial database switch. However, you don’t need to complete this process before subsequent database switches as long as the data sources involved remain the same.

When you perform a database switch, you use a SwitchingDataSource to switch between two product catalog/price lists data sources. The SwitchingDataSource can switch from one underlying data source to another. For example, the method could switch from a test database to a production database.

The Nucleus components used in this example are located at /atg/commerce/jdbc.

Note: While the process used in this section assumes the data is in a SOLID database, the mechanisms are the same regardless of what kind of database is used.

Follow these configuration steps to prepare to switch the data source used by the product catalog and price lists repositories:

  1. Create the underlying data sources. Alternatively, you can use the data sources provided with the default configuration of ATG Commerce. They are:

    /atg/commerce/jdbc/ProductCatalogDataSourceA and /atg/commerce/jdbc/ProductCatalogDataSourceB.

    These data sources are used as the example data sources in this procedure.

  2. Configure the dataSource property in each of the data sources.

    The dataSource property contains a reference to the data source that stores information for connection to a database. By setting this property for ProductCatalogDataSourceA and ProductCatalogDataSourceB, you control to what database each data source points.

    By default, ProductCatalogDataSourceA.dataSource is set to ProductCatalogFakeXADataSourceA, and ProductCatalogDataSourceB.dataSource is set to ProductCatalogFakeXADataSourceB. Both of these FakeXADataSource data sources are configured as follows:

    $class=atg.service.jdbc.FakeXADataSource

    driver=solid.jdbc.SolidDriver
    URL=jdbc:solid://hostname:port
    user=user
    password=password

    The port for SOLID is typically 1313.

    Note: In this example, both FakeXADataSource data sources have the same configuration. In an actual database switch, the configuration of the two data sources would be different.

  3. Create a SwitchingDataSource. Alternatively, you can use ProductCatalogSwitchingDataSource, which is located in Nucleus at /atg/commerce/jdbc/. This SwitchingDataSource is provided with the default configuration of ATG Commerce.

    A SwitchingDataSource is a DataSource that can switch between two or more underlying data sources. In a SwitchingDataSource, all DataSource method calls are passed through to the DataSource specified in the currentDataSource property, which is defined at run time. For more information on SwitchingDataSource, see the ATG API Reference and the ATG Installation and Configuration Guide.

    The following example shows the configuration for the ProductCatalogSwitchingDataSource included with ATG Commerce.

    $class=atg.service.jdbc.SwitchingDataSource
    #
    # A map from data source names to data sources
    #
    dataSources=\
         DataSourceA=/atg/commerce/jdbc/ProductCatalogDataSourceA,\
         DataSourceB=/atg/commerce/jdbc/ProductCatalogDataSourceB
    #
    # The name of the data source that should be used
    #
    initialDataSourceName=DataSourceA

    The dataSources property of a SwitchingDataSource is a mapping of data source names to the Nucleus path of each data source.

    The initialDataSource is the data source used.

  4. Configure the ProductCatalog repository to use the SwitchingDataSource. By default, the ProductCatalog repository does not use this data source, so you must add the following to the ProductCatalog.properties file at localconfig/atg/commerce/catalog/:

    dataSource=/atg/commerce/jdbc/ProductCatalogSwitchingDataSource

  5. Configure the PriceLists repository to use the SwitchingDataSource. By default, the PriceLists repository does not use this data source, so you must add the following to the PriceLists.properties file at localconfig/atg/commerce/pricing/priceLists/:

    dataSource=/atg/commerce/jdbc/ProductCatalogSwitchingDataSource

  6. Configure the switchingDataSource property of the ProductCatalogSwitcher form handler (class atg.droplet.sql.SwitchDataSourceFormHandler) to use the SwitchingDataSource. The Switch UI uses the ProductCatalogSwitcher form handler to perform the database switch; the switchingDataSource property specifies the specific SwitchingDataSource controlled by the form handler.

  7. Perform the database switch, as described in Performing a Database Switch.

 
loading table of contents...