Saturday, August 31, 2013

Configuring ATG Data Sources : ATG




ATG uses its own data sources when running data import scripts. These scripts are used for initial application configuration. The data source is based on /atg/dynamo/service/jdbc/JTDataSource, a Nucleus service that creates new connections to a particular database.


J2EE JDBC supports the Java Transaction API (JTA) via the javax.sql.XADataSource interface. JTA allows multiple resources from different providers to participate in the same transaction. Using two-phase commits, data integrity across different services is ensured. ATG supplies a DataSource that sits on top of an XADataSource and returns wrapped Connections that are registered appropriately with the associated Transaction Manager. ATG’s DataSource must get all its Connections from an XADataSource. Only a true XADataSource produces connections that behave properly in a two-phase commit controlled by JTA. XADataSources should be included in JDBC 2.0 drivers for the various database vendors.


The default DataSource connection pool, JTDataSource, uses the FakeXADataSource component, which is configured by default for the SOLID database. If you want to use a database other than SOLID, you must configure the desired connection pool properties, but note that this datasource should be used only to run ATG data import scripts.


You can set up and configure a connection pool manually by creating two files in your localconfig/atg/dynamo/service/jdbc/ directory:

1. JTDataSource.properties
2. FakeXADataSource.properties


The JTDataSource.properties file contains properties and values similar to the following:


$class=atg.service.jdbc.MonitoredDataSource
min=10
max=10
blocking=true
maxFree=-1
loggingSQLWarning=false
loggingSQLDebug=false
loggingSQLInfo=false
dataSource=/atg/dynamo/service/jdbc/FakeXADataSource.properties
loggingSQLError=false


Important: The min property determines the number of connections that the pool starts out with. The max property determines how many connections are to be kept around in the pool. When the pool starts, it immediately creates the minimum number of connections. Whenever a service requires a connection, it takes one from the pool. If there are no connections free, then the connection pool creates a new connection, until the maximum is reached. Due to various initialization calls, ATG requires at least three JDBC connections on install or when started with a new database. Setting the JDBC connection pool’s max property to anything less causes ATG to hang when starting up.


If the maximum has been reached and a service requires another connection, then the service blocks until some other service frees up a connection. If the blocking property is set to false, then instead of blocking, the connection pool fails and results in a SQL exception.



The FakeXADataSource.properties file contains properties and values similar to the following:


$class=atg.service.jdbc.FakeXADataSource
server=localhost:1313
user=admin
needsSeparateUserInfo=false
URL=jdbc:solid://localhost:1313
readOnly=false
password=admin
database=
driver=solid.jdbc.SolidDriver


By default, the connection pool’s driver and URL are configured for the SOLID database, as follows:


driver=solid.jdbc.SolidDriver
URL=jdbc:solid://localhost:1313

The user and password properties provide the connection with login access to the database, and must be recognized by the target database.

The readOnly property determines whether the resulting connection will only be used to perform read-only operations. Some drivers may be able to improve performance if this is true. Most applications require read and write access, so this property is usually false.


For Connecting to MySQL :


driver=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
URL=jdbc:mysql://localhost:3306


For Connecting to Oracle :


driver=oracle.jdbc.OracleDriver
URL=jdbc:oracle:thin:@localhost:1521

Note: Depends on the Oracle DB version driver may change. Use the driver as per the respective version





Monday, August 26, 2013

Cross-Site Links - Commerce Referrence Store


Cross-Site Links 


Commerce Reference Store includes cross-site links to ATG Home products on the ATG Store site, and links to ATG Store products on the ATG Home site. Cross-site product links appear in the following places:


Search results , Recommended products on the home page ,  Promotional content items that contain target links, Related products on the product detail page, Recently viewed products on the product detail page, Gift and wish lists, Shopping cart, Product comparisons


Commerce Reference Store uses the servlet beans /atg/commerce/multisite/SiteIdForCatalogItem (of class atg.droplet.multisite.SiteIdForItemDroplet) and /atg/dynamo/droplet/multisite/SiteLinkDroplet (of class atg.droplet.multisite.SiteLinkDroplet) to create cross-site links


The following example is adapted from store.war/global/gadgets/crossSiteLinkGenerator.jsp:


<%-- Pass a product repository item to the SiteIdForCatalogItem droplet to
determine the best-matching site ID for the product. --%>
<dsp:droplet name="/atg/commerce/multisite/SiteIdForCatalogItem">
   <dsp:param name="item" param="product" />
   <dsp:oparam name="output">

      <%-- Store the site ID obtained by SiteIdForCatalogItem in a productSiteId
      variable. --%>
      <dsp:getvalueof var="productSiteId" param="siteId" />

      <%-- Pass the site ID and the product's template path to SiteLinkDroplet to
      get a site-specific URL to the product template. --%>
      <dsp:droplet name="/atg/dynamo/droplet/multisite/SiteLinkDroplet">
         <dsp:param name="siteId" value="${productSiteId}" />
         <dsp:param name="path" param="product.template.url" />
         <dsp:oparam name="output">

            <%-- Render the generated URL to the product template, appended with
            the product ID. --%>
            <dsp:getvaluof var="siteLinkUrl" param="url" />
            <dsp:a href="${siteLinkUrl}">
               <dsp:param name="productId" param="product.repositoryId" />
               <dsp:valueof param="product.displayName" />
            </dsp:a>

         </dsp:oparam>
      </dsp:droplet>
   </dsp:oparam>
</dsp:droplet>



This example generates the URL as follows:


1. The SiteIdForCatalogItem servlet bean determines the best site ID to use for the product.

2. The SiteLinkDroplet servlet bean uses the siteId returned by SiteIdForCatalogItem to determine which site the URL should point to and it retrieves the value of the productionURL property for that site. For example, if the link is to a product on ATG Store US, the value of productionURL is /crs/storeus. Note that, in this example, productionURL does not contain domain information, so the URL that SiteLinkDroplet produces also does not include this information. Consequently, the browser will use the current page’s protocol, domain, and port information for the link.

3. The product template portion is taken from the product’s product.template.url property, which is passed to SiteLinkDroplet in its path parameter.

4. The <dsp:a> tag appends the productId to the URL as a query parameter.



The resulting URL looks similar to this:


/crs/homeus/browse/productDetailSingleSku.jsp?productId=xprod2126



Disabling the Scenario Manager Component : ATG

To disable the scenario manager component for a server:



Step 1 : 

Create or edit the ScenarioManager.properties file for the server.

<ATGdir>/home/servers/servername/localconfig/atg/scenario/ScenarioManager.properties

Note : If you are disabling the InternalScenarioManager component for an agent server, make this configuration in the InternalScenarioManager.properties file too.



Step 2 :

Set the enabled property to false. If the enabled property is not present in the file, add it.

enabled=false

Note : if you want to check the logs Set loggingDebug=true




Step 3 :

Restart the server.

Verify that the server has started with the scenario manager component disabled by checking the server’s log file for the following message.

2013-08-24 13:34:01,290 INFO [nucleusNamespace.atg.scenario.ScenarioManager] (main) This ProcessManager is disabled and will not execute processes or handle events




Popular Posts