Spring Framework

Spring framework is lightweight and it's solved a big problem for Java Enterprise Development , it's very popular in the recent years.

Spring Framework now is foundation for other Spring Projects that have come up in the offerings in the last two to three years.In Spring MVC, IOC, Spring Boot is one of the most popular Spring Framework modules now.


Spring framework  doesn’t force a programmer to extend or implement their class from any predefined class or interface given by Spring API But in struts we used to extend Action Class.We will cover bellow points in next blogs pages.


1. Spring Framework Overview

2. Spring Installation
3. Spring - Dependency Injection (DI)
4. Spring - Aspect Oriented Programming (AOP)
5. Spring - Core Container
6. Spring - Data Access/Integration
7. Spring - Web
8. Spring Boot
9. Spring Cloud
10.Spring Cloud Data Flow 



.

SpringBoot

"Spring Boot make Spring Boot make it easy to create stand-alone application,production-grade Sprig base Application that can "Just run."
we take an opinionated view of tha Spring platform and third-party libraries so you can get started with minimum fess"

it is very popular Java-Base framework for building web and enterprise application and Spring framework provide a wide verity of the features for modern business needs.

  • It is very easy to develop Spring Base application with java or groovy
  • It reduce lots of developments time and increases productivity.
  • Spring boot avoid writing lots of boilerplate Code,Annotations and less Configuration.
  • Spring Boot Opinionated Default Configuration Approach to reduce Developer effort.
  • Spring boot has embedded HTTP Servers like Tomcat and Jetty and we can develop and test our web applications very easily.


why we used Spring Boot?
The main goal os Spring Boot framework is reduce Development as compare to Spring framework .
- TO avoid defining more Annotation COnfiguration.
- TO avoid XML Configuraiton completely.
- To avoid writing lots of import statements.

To Start Opinioned Approach to create Spring Boot Applications. The Spring Team has provide following three approaches.

1.Using Spring Boot CLI Tool.
2.Using Spring STS IDE
3.Using Spring initializer web side.


We will cove bellow topice in next pages:

1.Spring Boot - Installation
2.Spring Boot - Sample Example
3.Spring Boot - Important Annotations


ATG Pricing Calculator

New Calculator are fit into existing ATG commerce pricing architecture ,In ATG four  the calculator are present:
1) atg.commerce.pricing.ItemPricingCalculator
2) atg.commerce.princing.OrderPricingCalculator
3) atg.commerce.pricing.ShippingPricingCalculator
4) atg.commerce.pricing.TaxpricingCaliculator.

For Example: if you want to create new  item  pricing, implement  ItemPricingCalulcator.
Condition:- assume you have identified a need for a calculator that sets an item’s price to half its current price plus one The existing ATG Commerce tools include an ItemDiscountCalculator that discounts items. It can give a percent off a price or an amount off, or it can set an item’s price to a fixed amount. None of these three options, however, easily gives a “half off plus one” discount. To achieve that result, you would have to use two different discounts: one to give 50 percent off, and another to add 1 to that total. A better alternative would be to create a new calculator that discounts an item’s price to half its current price plus one.

Step 1:-Create a new Component under
atg/commerce/pricing/HalfPlusOneDiscountCalculator.properies
$class=com.corbus.commerce.pricing.HalfPlusOneDiscountCalculator
Step: create new class “HalfPlusOneDiscountCalculator.java” and extends ItemDiscountCalculator and override findAdjustedPrice() method.

package com.corbuse.commerce.pricing;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import atg.commerce.order.Order;
import atg.commerce.pricing.DetailedItemPriceInfo;
import atg.commerce.pricing.ItemDiscountCalculator;
import atg.commerce.pricing.PricingException;
import atg.repository.RepositoryItem;

public class HalfPlusOneItemDiscountCalculator extends ItemDiscountCalculator {
          /**
             * Override the findAdjustedPrice to allow us to always compute the
             * new price of the input DetailedItemPriceInfo to be half its current
             * price plus one.
             * @param pDetailedItemPriceInfo the details on the item being priced
             * @param pPriceQuotes list of itemPriceInfo
             * @param pItems list of commerceItems
             * @param pPricingModel pricing model being used to calculate price
             * @param pProfile users profile, not used here
             * @param pLocale users locale, not used here
             * @param pOrder users order, not used here
             * @param pExtraParameters map of extra params, not used here
             * @return a value of type 'double'
             * @exception PricingException if an error occurs
             */
            public double findAdjustedPrice(DetailedItemPriceInfo pDetailedItemPriceInfo,
                List pPriceQuotes,
                List pItems,
                RepositoryItem pPricingModel,
                RepositoryItem pProfile,
                Locale pLocale,
                Order pOrder,
                Map pExtraParameters) throws PricingException {
                // current price of an item
                double currentAmount = pDetailedItemPriceInfo.getAmount();
                return ( currentAmount / 2) + 1;
            } // end findAdjustedPrice

}

Step 2: Update the pricingModels Repository,
Create a new pricingModel.xml under the atg/commerce/pricing/pricingMpdel.xml

<gsa-template>
      <item-descriptor expert="false" sub-type-value="Item Discount - half off plus one" id-separator=":"
            display-name-resource="itemDiscount - halfoffplusone" writable="true" version-property="version" super-type="Item Discount"
            cache-mode="simple" id-space-name="promotion" content="false" folder="false" default="false" query-cache-size="1000" hidden="false"
            name="Item Discount - half off plus one" use-id-for-path="false" item-cache-size="1000">
            <attribute name="resourceBundle" value="atg.commerce.PricingModelsTemplateResources" />

            <table name="dcs_discount_promo" id-column-name="promotion_id" type="auxiliary" shared-table-sequence="1">
                  <property expert="false" readable="true" category-resource="categoryACCOnly" display-name-resource="pricingCalculatorService" writable="true"
                        cache-mode="inherit" column-name="calculator" default="/atg/commerce/pricing/calculators/HalfPlusOneItemDiscountCalculator"
                        data-type="string" hidden="false" name="pricingCalculatorService" required="false" queryable="true">
                        <attribute name="uiwritable" value="false" />
                        <attribute name="propertySortPriority" value="100" />
                  </property>
                  <property expert="false" readable="true" category-resource="categoryACCOnly"
                        column-name="adjuster" display-name-resource="adjusterPercent" data-type="double" hidden="false" writable="true" name="adjuster"
                        required="false" cache-mode="inherit" queryable="true">
                        <attribute name="propertySortPriority" value="60" />
                  </property>
            </table>
            <property expert="true" readable="true" category-resource="categoryACCOnly" default="halfoffplusone" display-name-resource="discountType" data-type="string"
                  hidden="false" writable="true" name="discountType" required="false" cache-mode="inherit" queryable="true">
                  <attribute name="uiwritable" value="false" />
                  <attribute name="propertySortPriority" value="80" />
            </property>
      </item-descriptor>

      <item-descriptor name="promotion">
            <table name="dcs_promotion" id-column-name="promotion_id" type="primary">
                  <property expert="false" readable="true" category-resource="categoryBasics" column-name="promotion_type" display-name-resource="discountType"      
                        data-type="enumerated" hidden="true" writable="true" name="type" required="false" cache-mode="inherit" queryable="true">
                        <option value="Item Discount - half off plus one" code="4" />
                  </property>
            </table>
      </item-descriptor>
</gsa-template>

Step 3: now Create new promotion
  
1)   Open http:localhost:8080/dyn/admin/
2)   Open ATG Control Center Admistrator.
3)   Open Pricing tab,under pricing click on promotions .
4)   Create new promotions (Note: when you will create on new promotions you can see Custom item type promotion name).
5)   When you will create new Promotion ,you can check the date base tables also(dcs_promotion, dcs_discount_promo)
6)   Check below the screen shot:
7)   You can check the way  ItemPricingCalculator oney way you will added new item into card or check below link:


http://localhost:8080/dyn/admin/nucleus/atg/commerce/order/purchase/CartModifierFormHandler/?propertyName=order.priceInfo
ATG Pricing Calculator