📄 atm.bpel
字号:
<from variable="logOnReq" part="customerName" />
<to variable="unauthorizedAccess" part="detail"
query="/typ:unauthorizedAccess/customerName" />
</copy>
</assign>
<!-- send fault back to the ATM -->
<reply name="logOnOut" operation="logOn" partnerLink="atm"
portType="atm:FrontEnd" variable="unauthorizedAccess"
faultName="atm:unauthorizedAccess" />
</sequence>
</otherwise>
</switch>
<!-- process customer requests, one at a time -->
<while name="customerLoop"
condition="bpel:getVariableData('logged')">
<pick name="customerMenu">
<onMessage operation="logOff" partnerLink="atm"
portType="atm:FrontEnd" variable="customerMsg">
<correlations>
<correlation set="customerInteraction" />
</correlations>
<!-- turn off logged flag for breaking the customer loop -->
<assign name="setLoggedOff">
<copy>
<from expression="false()" />
<to variable="logged" />
</copy>
</assign>
</onMessage>
<onMessage operation="getBalance" partnerLink="atm"
portType="atm:FrontEnd" variable="customerMsg">
<correlations>
<correlation set="customerInteraction" />
</correlations>
<sequence name="balanceSequence">
<!-- get current account balance -->
<invoke operation="queryBalance" partnerLink="account"
portType="acc:AccountSystem"
inputVariable="customerMsg"
outputVariable="balanceMsg">
<correlations>
<correlation set="customerInteraction"
pattern="out" />
</correlations>
</invoke>
<!-- hand the balance back to the ATM -->
<reply name="getBalanceOut" operation="getBalance"
partnerLink="atm" portType="atm:FrontEnd"
variable="balanceMsg" />
</sequence>
</onMessage>
<onMessage operation="deposit" partnerLink="atm"
portType="atm:FrontEnd" variable="balanceChange">
<correlations>
<correlation set="customerInteraction" />
</correlations>
<sequence name="depositSequence">
<!-- populate balance update request -->
<assign name="fillDepositUpdate">
<copy>
<from variable="balanceChange" part="customerName" />
<to variable="accountOperation" part="body"
query="/body/customerName" />
</copy>
<copy>
<from variable="balanceChange" part="amount" />
<to variable="accountOperation" part="body"
query="/body/amount" />
</copy>
</assign>
<!-- post positive balance update -->
<invoke name="updateBalance" operation="updateBalance"
partnerLink="account" portType="acc:AccountSystem"
inputVariable="accountOperation"
outputVariable="balanceMsg">
<correlations>
<correlation set="customerInteraction"
pattern="out" />
</correlations>
</invoke>
<!-- make new balance available to ATM -->
<reply name="depositOut" operation="deposit"
partnerLink="atm" portType="atm:FrontEnd"
variable="balanceMsg" />
</sequence>
</onMessage>
<onMessage operation="withdraw" partnerLink="atm"
portType="atm:FrontEnd" variable="balanceChange">
<correlations>
<correlation set="customerInteraction" />
</correlations>
<sequence name="withdrawSequence">
<!-- populate balance query request -->
<assign name="fillWithdrawQuery">
<copy>
<from variable="balanceChange" part="customerName" />
<to variable="customerMsg" part="customerName" />
</copy>
</assign>
<!-- get current account balance -->
<invoke name="queryBalance" operation="queryBalance"
partnerLink="account" portType="acc:AccountSystem"
inputVariable="customerMsg"
outputVariable="balanceMsg">
<correlations>
<correlation set="customerInteraction"
pattern="out" />
</correlations>
</invoke>
<!-- compute amount that would remain in the account -->
<assign name="decreaseBalance">
<copy>
<from expression="bpel:getVariableData('balanceMsg', 'balance') -
bpel:getVariableData('balanceChange', 'amount')" />
<to variable="newBalance" />
</copy>
</assign>
<!-- decide outcome of withdraw request -->
<switch name="balanceDecision">
<case
condition="bpel:getVariableData('newBalance') >= 0.0">
<!-- accept withdrawing -->
<sequence name="positiveBalanceSequence">
<!-- populate balance update request -->
<assign name="fillWithdrawUpdate">
<copy>
<from variable="balanceChange"
part="customerName" />
<to variable="accountOperation" part="body"
query="/body/customerName" />
</copy>
<copy>
<from
expression="-bpel:getVariableData('balanceChange', 'amount')" />
<to variable="accountOperation" part="body"
query="/body/amount" />
</copy>
</assign>
<!-- post negative balance update -->
<invoke name="updateBalance"
operation="updateBalance" partnerLink="account"
portType="acc:AccountSystem"
inputVariable="accountOperation"
outputVariable="balanceMsg">
<correlations>
<correlation set="customerInteraction"
pattern="out" />
</correlations>
</invoke>
<!-- return new balance to ATM -->
<reply name="withdrawOut" operation="withdraw"
partnerLink="atm" portType="atm:FrontEnd"
variable="balanceMsg" />
</sequence>
</case>
<otherwise>
<!-- reject withdrawing -->
<sequence name="negativeBalanceSequence">
<!-- populate withdraw fault -->
<assign name="fillNoFunds">
<copy>
<from variable="balanceChange"
part="customerName" />
<to variable="insufficientFunds" part="detail"
query="/typ:insufficientFunds/customerName" />
</copy>
<copy>
<from variable="balanceMsg" part="balance" />
<to variable="insufficientFunds" part="detail"
query="/typ:insufficientFunds/amount" />
</copy>
</assign>
<!-- return fault to ATM -->
<reply name="withdrawFlt" operation="withdraw"
partnerLink="atm" portType="atm:FrontEnd"
variable="insufficientFunds"
faultName="atm:insufficientFunds" />
</sequence>
</otherwise>
</switch>
</sequence>
</onMessage>
<onAlarm for="'PT2M'">
<!-- log off after 2 minutes of inactivity -->
<assign name="setLoggedOff">
<copy>
<from expression="false()" />
<to variable="logged" />
</copy>
</assign>
</onAlarm>
</pick>
</while>
</sequence>
</scope>
</onMessage>
</pick>
</while>
</scope>
</sequence>
</process>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -