Friday, April 27, 2012

Overview of ItemPricingEngineImpl : ATG


ItemPricingEngineImpl

atg.commerce.pricing.ItemPricingEngineImpl


All Implemented Interfaces:

ItemPricingEngine, PricingEngine, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener


public class ItemPricingEngineImpl extends PricingEngineService 
implements ItemPricingEngine


An ItemPricingEngine implementation which computes the price for an order. It accomplishes this task by invoking a series of ItemPricingCalculators which incrementally compute the items' prices:
  • The first step is to allow the preCalculators to manipulate the price. They are invoked in the order in which they appear in the preCalculators list.
  • The second step is to extract the calculators from any input PricingModels, and invoke them in the order in which they appear in the pPricingModels list.
  • The last step is to invoke the postCalculators in the order in which they appear in the postCalculators list.
Note: if a particular order of calculator invocation is desired, sorting must be done prior to passing discounts/precalculators/postcalculators in to the Engine.
Properties:
  • licenseFileNames is the names of the nucleus components which are the B2B and B2C licenses.
  • preCalculators is a list of ItemPricingCalculators whose pricing methods should be invoked on the input pPriceQuote before any pricing models are evaluated.
  • postCalculators is a list of ItemPricingCalculators whose pricing methods should be invoked on the input pPriceQuote after any pricing models are evaluated.

Important properties:


PriceItem

public ItemPriceInfo priceItem(CommerceItem pItem,
                               java.util.Collection pPricingModels,
                               java.util.Locale pLocale,
                               RepositoryItem pProfile,
                               java.util.Map pExtraParameters)
                        throws PricingException

 

PriceItems

public java.util.List priceItems(java.util.List pItems,
                                 java.util.Collection pPricingModels,
                                 java.util.Locale pLocale,
                                 RepositoryItem pProfile,
                                 Order pOrder,
                                 java.util.Map pExtraParameters)
                          throws PricingException

 

priceEachItem:

public java.util.List priceEachItem(java.util.List pItems,
                                    java.util.Collection pPricingModels,
                                    java.util.Locale pLocale,
                                    RepositoryItem pProfile,
                                    java.util.Map pExtraParameters)
                             throws PricingException

 

checkPromotionsForCloseness:


public void checkPromotionsForCloseness(java.util.List pPriceInfos,
                                        java.util.List pItems,
                                        java.util.Collection pPricingModels,
                                        java.util.Locale pLocale,
                                        RepositoryItem pProfile,
                                        Order pOrder,
                                        java.util.Map pExtraParameters)
                                 throws PricingException





Class Qualifier : ATG


Class Qualifier

atg.commerce.pricing.Qualifier

All Implemented Interfaces:

NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener


public class Qualifier extends GenericService


A Helper class for discount calculators. Calculators call their helper method in this class to determine to which items they should apply their discount. As a side effect, the Qualifier also keeps track of which items acted as qualifiers for the input promotion, if applicable, and marks their priceInfos as appropriate.
  • ItemDiscountCalculator uses findQualifyingItems
  • OrderDiscountCalculator uses findQualifyingOrder
  • ShippingDiscountCalculator uses findQualifyingShipping
  • TaxDiscountCalculator uses findQualifyingOrder

This class can be extended. New "findQualifyingX" methods can be added to act as helper methods to new kinds of PricingCalculator. Any calculator that needs a rule to determine whether to apply a discount might use the Qualifier class.
By default, the Qualifier evaluates rules written in PMDL (Pricing Model Description Language). evaluateQualifier and evaluateTarget evaluate the qualfier and target elements of PMDL repspectively. The evaluateQualfier and evaluateTarget methods are protected and are available to be extended.
  • licenseFileNames is the component names of the license files which this component requires.
  • pmdlCache is the cache which maps pricing model RepositoryItems to their parsed PMDL bean representations.
  • pricingModelProperties is a list of the names of the properties of a pricing model RepositoryItem.
There are a number of properties that can be configured to adjust the way in which CommerceItems are allowed to participate in pricing rule evaluation. There are two rules which make up a PMDL rule: the qualifier rule and target rule. Accordingly, there two categories of filter property: filterForQualifier and filterForTarget.
In all of the properties listed below, a value of true indicates that items with the specified attributes should be excluded from the qualification process.

Qualifier filters:


  • filterForQualifierNegativePrices: default = true. Toggle whether items with negative prices should be allowed to act as qualifiers.
  • filterForQualifierZeroPrices: default = true. Toggle whether items with zero prices should be allowed to act as qualifiers
  • filterForQualifierOnSale: default = false. Toggle whether items that were priced with a sale price should be allowed to act as qualifiers
  • filterForQualifierDiscountedByCurrentDiscountId: default = true. Toggle whether items discounted by the "current" discount should be allowed to act as qualifiers
  • filterForQualifierDiscountedByAnyDiscountId: default = true. Toggle whether items discounted by any discount should be allowed to act as qualifiers. Masks filterForQualifierDiscountedByCurrentDiscountId (if this property is on, it doesn't matter what the other property is set to)

Target filters:

  • filterForTargetNegativePrices: default = true. Toggle whether items with negative prices should be allowed to receive the current discount
  • filterForTargetZeroPrices: default = true. Toggle whether items with zero prices should be allowed to receive the current discount
  • filterForTargetPricesLessThanOrEqualToPromotionPrice: default = true. Toggle whether items with prices that are already less than the price that would be granted by a "fixed price" promotion should receive the promotion.
  • filterForTargetOnSale: default = false. Toggle whether items that were priced with a sale price should be allowed to receive the current discount
  • filterForTargetDiscountedByCurrentDiscountId: default = true. Toggle whether items that have been discounted by the current discount should be allowed to receive the discount again
  • filterForTargetDiscountedByAnyDiscountId: default = true. toggle whether items that have been discounted by any discount should be allowed to receive the discount again
  • filterForTargetActedAsQualifierForAnyDiscount: default = true. toggle whether items that have acted as a qualifier for any discount should be allowed to receive the current discount

Performance Monitor Modes : ATG


Performance Monitor Modes:


The Performance Monitor code can run in one of four modes:

· DISABLED. When the Performance Monitor is disabled, its diagnostic methods immediately return without doing any additional work.

·  NORMAL. In this mode, the Performance Monitor keeps track only of the current stack of operations. This mode is useful in identifying the location in the code of hung or active threads.

·  TIME. In this mode, in addition to the current operation stack, the Performance Monitor maintains dictionaries for each operation. These dictionaries store the number of times each operation has been performed, and the minimum, maximum and average time to process that operation.

·  TIME mode is not meant to be used on a live system for an extended period of time. This mode is for gathering data on the amount of time spent in various parts of the code.

·   MEMORY. In this mode, the Performance Monitor maintains the information specified for NORMAL and TIME mode. In addition, the Performance Monitor maintains dictionaries that store the number of times each operation has been performed, and the minimum, maximum and average amount of memory required to process that operation. These statistics are estimates and do not take into account asynchronous processing activity that may be occurring. Do not rely on data from only one or two samples, since the Performance Monitor may generate anomalous data that can be ignored.
MEMORY mode causes all requests to the server to be serialized and could possibly cause deadlock. This mode is provided for diagnostics during development only and is not suitable for use on a live system.
Set the Performance Monitor’s operating mode at the Performance Monitor Configuration page of the Dynamo Administration UI:

http://hostname:port/dyn/admin/atg/dynamo/admin/en/

performance-monitor-config.jhtml

Click the radio button for the mode you want, and then click the Change Mode button.
You can also set the Performance Monitor’s operating mode by setting the mode property of the component at /atg/dynamo/service/PerformanceMonitor. The value of the modeproperty is an int corresponding to the mode:



mode
int value
disabled
0 (default)
normal
1
time
2
memory
3

Adding PerformanceMonitor Methods to your Code


Adding PerformanceMonitor Methods to your Code

To enable the Performance Monitor to monitor a section of your Java code:

1. Import the atg.service.perfmonitor.* package.
2. Declare an opName parameter to label the section of the code. This parameter is displayed in the Performance Monitor page under the Operation heading.
3. (Optional) Declare a parameter name if you want to gather data on individual executions of an operation.
4. Call the startOperation method at the beginning of the operation whose performance you want to be able to measure.
5. Call the endOperation method at the end of the operation whose performance you want to be able to measure.
6. Optionally, call the cancelOperation method if an exception occurs. This causes the results of the    current execution to be ignored.
For details about the Performance Monitor’s startOperation, endOperation, and cancelOperation methods, see Methods for Storing Performance Data.

For example:

String opName = "render jsp";
String parameter = "foo.jsp";
boolean exception = false;
PerformanceMonitor.startOperation(opName, parameter);
try {
  ... code to actually render foo.jsp
} catch (Exception e) {
  PerformanceMonitor.cancelOperation(opName, parameter);
  exception = true;
} finally {
  if (! exception)
    PerformanceMonitor.endOperation(opName, parameter);
}


These methods can be nested with different or the same opNames.

For example:


private final String RENDER_JSP = "Render JSP page";
private final String EXECUTE_SQL = "Execute SQL Query";
private String mPageName = "page.jsp";
private String mSQLQuery = "select * from table";

PerformanceMonitor.startOperation(RENDER_JSP, mPageName);
... source code to start render
  PerformanceMonitor.startOperation(EXECUTE_SQL, mSQLQuery);
  ... source code to read from table 1 in database
    PerformanceMonitor.startOperation(EXECUTE_SQL);
    ... source code to read from database
    PerformanceMonitor.endOperation(EXECUTE_SQL);
  ... more source code to read from table 1 in database
  PerformanceMonitor.endOperation(EXECUTE_SQL, mSQLQuery);
... more source code to finish render
PerformanceMonitor.endOperation(RENDER_JSP, mPageName);

Note that the calls to startOperation are nested within other calls to startOperation. You must place the endOperation and cancelOperation calls in the code in opposite order that the startOperation calls were placed. If this requirement is not followed, then the endOperation or cancelOperation call throws a PerfStackMismatchException. This exception tells you that the calls to endOperation are not being matched up. Either they were not called in the correct order or the arguments were not exactly the same as those that were passed into the methods.

To ensure that endOperation is always called, wrap the Performance Monitor methods in a try ... finally block, as in this example:

boolean exception = false;
try {
  PerformanceMonitor.startOperation(OP_NAME);
  performOperation (pParameter);
} catch (Exception e) {
  PerformanceMonitor.cancelOperation(OP_NAME);
  exception = true;
} finally {
  try {
    if (!exception)
      PerformanceMonitor.endOperation(OP_NAME);
  } catch (PerfStackMismatchException e) {
    System.out.println(e);
  }
}

Wednesday, April 4, 2012

Ant Task: Init

Ant Task: Init

 

Creates and initializes the metadata table in the schema.

Usage:

 

<flyway:init />

Configuration:


Driver = flyway.driver: The fully qualified classname of the jdbc driver to use to connect to the database , Required=YES,

URL = flyway.url: The jdbc url to use to connect to the database,

User = flyway.user: The user to use to connect to the database,

Password = flyway.password: The password to use to connect to the database, Required=NO, Default       Value=blank,

Schemas = flyway.schemas: Comma-separated list of schemas managed by Flyway. The first schema in the list will be the one containing the metadata table,Required=NO, Default Value= default schema of the connection,

Table =  flyway.table: The name of Flyway's metadata table.By default (single-schema mode) the metadata table is placed in the default schema for the connection provided by the     datasource.When the flyway.schemas property is set (multi-schema mode), the metadata table is placed in the first schema of the list,Required=No,Default Value = schema_version,

InitialVersion = flyway.initialVersion: The initial version to put in the database, Required=NO, Default Value=0,

InitialDescription = flyway.initialDescription: The description of the initial version, Required=NO, Default Value=<< Flyway Init >>,

ClassPath = flyway.classpath: The Ant classpath used to load the JDBC driver and the migrations, Required=NO,

ClassPathref = flyway.classpathref: The Ant classpath reference used to load the JDBC driver and the migrations, Required=NO.

Sample configuration;


<property name="flyway.driver" value="org.hsqldb.jdbcDriver"/>
<property name="flyway.url" value="jdbc:hsqldb:file:/db/flyway_sample"/>
<property name="flyway.user" value="SA"/>
<property name="flyway.password" value="mySecretPwd"/>
<property name="flyway.schemas" value="schema1,schema2,schema3"/>
<property name="flyway.table" value="schema_history"/>
<property name="flyway.initialVersion" value="1.0"/>
<property name="flyway.initialDescription" value="Base Migration"/>


Sample output

 

 

Popular Posts