Processor Chains and the Pipeline Manager
Processor 就是一个执行一些功能和返回状态码的一个组件,状态码决定chain中下一个是哪一个processor被执行。
PipelineManager 可以使你动态的添加或删除processor.Pipeline要执行processor。需要调用runProcess().他首先会找请求的链,如果is enable,PipelineManager 调用runProcess(),如果isn't enable,就会抛出一个异常。
The following sections describe how to create a processor pipeline:
配置Pipeline Manager:
每一个processor chain 都是有pipeline manager 控制的,它位于/atg/commerce/
PipelineManager. The PipelineManager属性:
$class=atg.commerce.pipeline.CommercePipelineManager # The location of the XML configuration file in the classpath. # Default: /atg/commerce/CommercePipeline.xml definitionFile=/atg/commerce/commercepipeline.xml # The transaction manager that the PipelineManager will use to coordinate its # transactions. transactionManager=/atg/dynamo/transaction/TransactionManager # The amount of time in milliseconds that a thread will wait to execute a pipeline. # Default: 15000 msec chainLockWaitTimeout=15000 # # The schedule to reinitialize the PipelineManager. # scheduler=/atg/dynamo/service/Scheduler schedule=every 6 hours in 6 hours
definitionFile是定义processor chains的。
Creating Processors:
首先要实现atg.service.pipeline.PipelineProcessor interface。
public abstract interface PipelineProcessor { public static final String CLASS_VERSION = "$Id: //product/DAS/version/10.2/Java/atg/service/pipeline/PipelineProcessor.java#2 $$Change: 768621 $"; public static final int STOP_CHAIN_EXECUTION_AND_COMMIT = 0; public static final int STOP_CHAIN_EXECUTION = 0; public static final int STOP_CHAIN_EXECUTION_AND_ROLLBACK = -1; public abstract int runProcess(Object paramObject, PipelineResult paramPipelineResult) throws Exception; public abstract int[] getRetCodes(); }
public abstract class ProcProcessPaymentGroup extends GenericService implements PipelineProcessor { public static String CLASS_VERSION = "$Id: //product/DCS/version/10.2/Java/atg/commerce/payment/processor/ProcProcessPaymentGroup.java#2 $$Change: 768796 $"; public static final int SUCCESS = 1; protected void invokeProcessorAction(PaymentManagerAction pProcessorAction, PaymentManagerPipelineArgs pParams) throws CommerceException { PaymentStatus status = null; if (isLoggingDebug()) { logDebug("Obtained processorAction with: " + pProcessorAction); } if (pProcessorAction == PaymentManagerAction.AUTHORIZE) status = authorizePaymentGroup(pParams); else if (pProcessorAction == PaymentManagerAction.DEBIT) status = debitPaymentGroup(pParams); else if (pProcessorAction == PaymentManagerAction.CREDIT) status = creditPaymentGroup(pParams); else if (pProcessorAction == PaymentManagerAction.DECREASE_AUTH_AMT) status = decreaseAuthorizationForPaymentGroup(pParams); else { throw new CommerceException("Invalid processor action specified: " + pProcessorAction); } pParams.setPaymentStatus(status); } public PaymentStatus decreaseAuthorizationForPaymentGroup(PaymentManagerPipelineArgs pParams) throws CommerceException { return null; } public abstract PaymentStatus authorizePaymentGroup(PaymentManagerPipelineArgs paramPaymentManagerPipelineArgs) throws CommerceException; public abstract PaymentStatus debitPaymentGroup(PaymentManagerPipelineArgs paramPaymentManagerPipelineArgs) throws CommerceException; public abstract PaymentStatus creditPaymentGroup(PaymentManagerPipelineArgs paramPaymentManagerPipelineArgs) throws CommerceException; public int runProcess(Object pParam, PipelineResult pResult) throws Exception { PaymentManagerPipelineArgs params = (PaymentManagerPipelineArgs)pParam; PaymentManagerAction action = params.getAction(); try { invokeProcessorAction(action, params); } catch (CommerceException e) { logError(e); pResult.addError("ProcProcessPaymentGroupFailed", e); return 0; } return 1; } public int[] getRetCodes() { int[] retCodes = { 1 }; return retCodes; } }
Pipeline Definition Files:
PipelineManager:定义文件根节点
pipelinechain: 定义一个procesor chain
- name:名字
- transaction:processor默认使用的事物模式
- headlink:在processor chain中的第一个processor被执行
- classname:将被实例化和用于PipelineChain对象,默认是atg.service.pipeline.PipelineChain.而且一定是他的子类
- resultclassname:用于pipleineResult对象,The default is atg.service.pipeline.PipelineResult. The value must implement PipelineResult.
pipelinelink:在 processor chain中定义processor.
- name:processor的名字
- transaction
processor:The name of the PipelineProcessor object.
- jndi :所引用processor类,这个对象是通过JNDI来解决的e
transition:根绝返回值决定下一个将要被执行的引用
- returnvalue:An integer string that is used to define the next pipeline element.
- 下一个将会被执行的pipelineprocessor,如果当前的返回值匹配return value
<?xml version="1.0"?> <!DOCTYPE PipelineManager SYSTEM "PipelineManager.dtd"> <PipelineManager> <pipelinechain name="AddToCart" transaction="TX_REQUIRED" headlink="proc1"> <pipelinelink name="proc1"> <processor class="atg.commerce.addA"/> <transition returnvalue="1" link="proc2"/> <transition returnvalue="2" link="proc3"/> </pipelinelink> <pipelinelink name="proc2" transaction="TX_REQUIRES_NEW"> <processor class="atg.commerce.addB"/> <transition returnvalue="1" link="proc4"/> <transition returnvalue="2" link="proc5"/> </pipelinelink> <pipelinelink name="proc3"> <processor class="atg.commerce.addE"/> <transition returnvalue="1" link="proc6"/> <transition returnvalue="2" link="proc7"/> <transition returnvalue="3" link="proc2"/> </pipelinelink> <pipelinelink name="proc4"> <processor class="atg.commerce.addC"/> </pipelinelink> <pipelinelink name="proc5" transaction="TX_REQUIRES_NEW"> <processor class="atg.commerce.addD"/> </pipelinelink> <pipelinelink name="proc6" transaction="TX_NOT_SUPPORTED"> <processor class="atg.commerce.addF"/> </pipelinelink> <pipelinelink name="proc7" transaction="TX_SUPPORTS"> <processor jndi="/dynamo/atg/commerce/addG"/> </pipelinelink> </pipelinechain> <pipelinechain name="RemoveFromCart" transaction="TX_REQUIRED" headlink="proc99" classname="atg.service.pipeline.PipelineMonoChain"> <pipelinelink name="proc99"> <processor class="atg.commerce.removeA"/> </pipelinelink> </pipelinechain> </PipelineManager>
相关推荐
Markov Chains and Stochastic Stability compiled ver
Haggstrom O Finite Markov chains and algorithmic applications CUP 2002 125s);随机过程
Markov chains – are a fundamental class of stochastic models for sequences of non–independent random variables, i.e. of random variables possessing a specific dependency structure. – have numerous ...
Finite markov chains and algorithmic applications 2002, 114pp. softcover gbp 14.95 isbn 0-521-89001-2 cambridge 本书是作者在瑞典chalmers技术大学讲课的基础上形成的一本数学教材,主题是...
这是关于马尔科夫链的电子书,高清,最新版本,经典著作,英文版
Markov Chains and Mixing Times David A. Levin Yuval Peres Elizabeth L. Wilmer
本书描述了一般状态空间马尔可夫链的现代理论,并将其应用于运筹学,时间序列分析以及系统和控制理论。
Probability, Markov chains, queues and simulation: the mathematical basis of performance modeling BOOK
资源是OperationsResearch上很经典的一篇论文,希望对大家有所帮助
princeton university F’02 cos 597D: a theorist’s toolkitLecture 7: Markov Chains and Random WalksLecturer: Sanjeev Arora Scribe:Elena Nabieva1 BasicsA Markov chain is a discrete-time stochastic ...
马尔科夫链理论与应用
Queueing Networks and Markov Chains Modeling and Performance Evaluation with Computer Science Application第二版,排队网络的经典书籍,Gunter Bolch,Stefan Greiner, Hermann de Meer, Kishor S....
SUMS58 Understanding Markov Chains -- Examples and Applications, Nicolas Privault (2013).zip
dent trials process, the possible outcomes for each experiment are the same and occur with the same probability. Further, knowledge of the outcomes of the pre- vious experiments does not influence our...
The basic analytical tool is the maximum principle, which is natural in this setting. It is superfcially compared to martingale methods in some instances. The basic probabilistic tool is the Markov ...
SUMS85 Understanding Markov Chains -- Examples and Applications, 2nd Edition, Nicolas Privault (2018).zip
In our example, if one transaction (T1) holds an exclusive lock at the table level, and another transaction (T2) holds an exclusive lock at the row level, each of the transactions believe they have ...
IRP hooking and Device Chains
06-algorithm-chains-and-pipelines