Class CatalogCurrencyContextInfoCustomizer

java.lang.Object
com.broadleafcommerce.catalog.service.context.CatalogCurrencyContextInfoCustomizer
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.context.ContextInfoCustomizer, org.springframework.core.Ordered

public class CatalogCurrencyContextInfoCustomizer extends Object implements com.broadleafcommerce.data.tracking.core.context.ContextInfoCustomizer
This component attempts to resolve the default Currency for this request.
Author:
Kelly Tisdell (ktisdell)
  • Field Summary

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    CatalogCurrencyContextInfoCustomizer(com.broadleafcommerce.common.extension.data.DataRouteSupporting route)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    customize(@NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, String routeKey, org.springframework.core.MethodParameter endpoint, org.springframework.web.context.request.NativeWebRequest webRequest)
     
    protected com.broadleafcommerce.money.jackson.CurrencyHolder
    NOTE - This implementation explicitly checks RequestContextHolder.getRequestAttributes() to check if we are in a request scope before trying to interact with the request-scoped CurrencyHolder bean.
    protected com.broadleafcommerce.common.extension.data.DataRouteSupporting
     
    void
    setCurrencyHolder(com.broadleafcommerce.money.jackson.CurrencyHolder currencyHolder)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.context.ContextInfoCustomizer

    getOrder
  • Constructor Details

    • CatalogCurrencyContextInfoCustomizer

      public CatalogCurrencyContextInfoCustomizer(com.broadleafcommerce.common.extension.data.DataRouteSupporting route)
  • Method Details

    • customize

      public void customize(@NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, @Nullable String routeKey, @Nullable org.springframework.core.MethodParameter endpoint, @Nullable org.springframework.web.context.request.NativeWebRequest webRequest)
      Specified by:
      customize in interface com.broadleafcommerce.data.tracking.core.context.ContextInfoCustomizer
    • setCurrencyHolder

      @Autowired public void setCurrencyHolder(com.broadleafcommerce.money.jackson.CurrencyHolder currencyHolder)
    • getCurrencyHolder

      @Nullable protected com.broadleafcommerce.money.jackson.CurrencyHolder getCurrencyHolder()
      NOTE - This implementation explicitly checks RequestContextHolder.getRequestAttributes() to check if we are in a request scope before trying to interact with the request-scoped CurrencyHolder bean. This is because when not in a request scope, the bean will still be non-null, but will throw a ScopeNotActiveException on any interaction. Typically, the recommendation in modern Spring is to use ObjectProvider.getIfAvailable() to avoid this type of issue, but the implementation there simply does a try/catch of the ScopeNotActiveException, which still incurs the penalty of computing the call stack. Thus, we don't use that approach here.
      Returns:
      the currency holder request-scoped bean, if we are in a request scope
    • getRoute

      protected com.broadleafcommerce.common.extension.data.DataRouteSupporting getRoute()