[关闭]
@gengzhengtao 2015-08-12T08:52:16.000000Z 字数 2773 阅读 1322

工作流和活动(Workflows and Activities)

电商平台broadleafCommerce Broadleaf概念


Broadleaf 为电子商务进程的关键阶段提供了可配置的工作流程 -即:结账,定价和购物车操作。这些工作流使用 Spring application context 文件中的 xml 来表示。在最基本的层面,Broadleaf为结账提供了使用简单模块覆盖基本步骤的默认配置。为了使用自己的需求和业务规范,大部分用户可能需要重写部分或者全部默认的配置步骤。我们将开始通过描述默认的配置,然后再进入自定义策略。

工作流的剖析

  1. <!-- Pricing Workflow configuration -->
  2. <bean p:order="1000" id="blOfferActivity" class="org.broadleafcommerce.core.pricing.service.workflow.OfferActivity" />
  3. <bean p:order="2000" id="blConsolidateFulfillmentFeesActivity" class="org.broadleafcommerce.core.pricing.service.workflow.ConsolidateFulfillmentFeesActivity" />
  4. <bean p:order="3000" id="blFulfillmentItemPricingActivity" class="org.broadleafcommerce.core.pricing.service.workflow.FulfillmentItemPricingActivity" />
  5. <bean p:order="4000" id="blFulfillmentGroupMerchandiseTotalActivity" class="org.broadleafcommerce.core.pricing.service.workflow.FulfillmentGroupMerchandiseTotalActivity" />
  6. <bean p:order="5000" id="blFulfillmentGroupPricingActivity" class="org.broadleafcommerce.core.pricing.service.workflow.FulfillmentGroupPricingActivity" />
  7. <bean p:order="6000" id="blShippingOfferActivity" class="org.broadleafcommerce.core.pricing.service.workflow.ShippingOfferActivity" />
  8. <bean p:order="7000" id="blTaxActivity" class="org.broadleafcommerce.core.pricing.service.workflow.TaxActivity" />
  9. <bean p:order="8000" id="blTotalActivity" class="org.broadleafcommerce.core.pricing.service.workflow.TotalActivity" />
  10. <bean p:order="9000" id="blAdjustOrderPaymentsActivity" class="org.broadleafcommerce.core.pricing.service.workflow.AdjustOrderPaymentsActivity" />
  11. <bean id="blPricingWorkflow" class="org.broadleafcommerce.core.workflow.SequenceProcessor">
  12. <property name="processContextFactory">
  13. <bean class="org.broadleafcommerce.core.pricing.service.workflow.PricingProcessContextFactory"/>
  14. </property>
  15. <property name="activities">
  16. <list>
  17. <ref bean="blOfferActivity" />
  18. <ref bean="blConsolidateFulfillmentFeesActivity" />
  19. <ref bean="blFulfillmentItemPricingActivity" />
  20. <ref bean="blFulfillmentGroupMerchandiseTotalActivity" />
  21. <ref bean="blFulfillmentGroupPricingActivity" />
  22. <ref bean="blShippingOfferActivity" />
  23. <ref bean="blTaxActivity" />
  24. <ref bean="blTotalActivity"/>
  25. <ref bean="blAdjustOrderPaymentsActivity"/>
  26. </list>
  27. </property>
  28. <property name="defaultErrorHandler">
  29. <bean class="org.broadleafcommerce.core.workflow.DefaultErrorHandler">
  30. <property name="unloggedExceptionClasses">
  31. <list>
  32. <value>org.hibernate.exception.LockAcquisitionException</value>
  33. </list>
  34. </property>
  35. </bean>
  36. </property>
  37. </bean>

每个工作流实际上是来自SequenceProcessor类的一个实例。此类管理他们应该发生的下属活动的顺序活动以及处理错误状态。工作流被配置成在三个主要的区域,包括 the process context factory,the activities list,以及 the rollback handler

ProcessContextFactory

processContextFactory属性必须被设置为一个实现ProcessContextFactory接口的实例。所有此类实现者负责创建实现 ProcessContext 接口 (更多关于这一点) 的类的一个实例。在我们例子中,我们使用PricingProcessContextFactory,并使用他创建一个ProcessContext<Order>的实例。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注