Commit 64ff2ec2c34b755af0cb02bba1556bb03f044c17
1 parent
064d2ecd
Exists in
AFDemo_Timeout_Ex3
and in
4 other branches
AFDemo_Ex07
Showing
5 changed files
with
111 additions
and
22 deletions
Show diff stats
AF-Demo/src/af/control/StateManager.java
| ... | ... | @@ -4,6 +4,7 @@ import af.interfaces.AFState; |
| 4 | 4 | import af.state.StateIdle; |
| 5 | 5 | import af.state.StateWaitE01; |
| 6 | 6 | import af.state.StateWaitA; |
| 7 | +import af.state.StateWaitC; | |
| 7 | 8 | import ec02.af.abstracts.AbstractAFStateManager; |
| 8 | 9 | |
| 9 | 10 | public class StateManager extends AbstractAFStateManager { |
| ... | ... | @@ -18,5 +19,8 @@ public class StateManager extends AbstractAFStateManager { |
| 18 | 19 | else if (state.equals(AFState.W_ARes)) { |
| 19 | 20 | this.afState = new StateWaitA(); |
| 20 | 21 | } |
| 22 | + else if (state.equals(AFState.W_CRes)) { | |
| 23 | + this.afState = new StateWaitC(); | |
| 24 | + } | |
| 21 | 25 | } |
| 22 | 26 | } | ... | ... |
AF-Demo/src/af/interfaces/AFState.java
AF-Demo/src/af/state/StateIdle.java
| ... | ... | @@ -4,6 +4,7 @@ import java.util.ArrayList; |
| 4 | 4 | |
| 5 | 5 | import af.instatnce.E01Instance; |
| 6 | 6 | import af.instatnce.EC02Instance; |
| 7 | +import af.instatnce.EQXRawInstance; | |
| 7 | 8 | import af.interfaces.AFEvent; |
| 8 | 9 | import af.interfaces.AFState; |
| 9 | 10 | import af.interfaces.EQXMsg; |
| ... | ... | @@ -30,7 +31,7 @@ public class StateIdle implements IAFState { |
| 30 | 31 | ec02Ins.getAFInstance().setInvoke(eqxRawData.getInvoke()); |
| 31 | 32 | ec02Ins.getAFInstance().setOrig(eqxRawData.getRawDataAttribute(EQXMsg.ORIG)); |
| 32 | 33 | |
| 33 | - if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_HTTP_Request)){ | |
| 34 | + /*if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_HTTP_Request)){ | |
| 34 | 35 | E01Instance e01Ins = new E01Instance(); |
| 35 | 36 | ArrayList<String> keys = new ArrayList<String>(); |
| 36 | 37 | keys.add(eqxRawData.getRawDataMessage()); |
| ... | ... | @@ -50,7 +51,21 @@ public class StateIdle implements IAFState { |
| 50 | 51 | abstractAF.getUtils().incrementStats("raise_by_stat"); |
| 51 | 52 | abstractAF.getUtils().raiseAlarm("my_alarm", parameter, AlarmSeverity.WARNING, AlarmCategory.APPLICATION, AlarmType.Normal); |
| 52 | 53 | this.eqxState = AFState.W_E01Res; |
| 53 | - } | |
| 54 | + }*/ | |
| 55 | + ArrayList<EQXRawInstance> eqxRawList = new ArrayList<EQXRawInstance>(); | |
| 56 | + | |
| 57 | + EQXRawInstance eqxRaw = new EQXRawInstance(); | |
| 58 | + eqxRaw.setMessage("B Req."); | |
| 59 | + eqxRaw.setTo(abstractAF.getUtils().getHmWarmConfig().get("Resource-Name-B").get(0)); | |
| 60 | + eqxRaw.setCtype(EQXMsg.TEXTXML); | |
| 61 | + eqxRawList.add(eqxRaw); | |
| 62 | + ArrayList<EquinoxRawData> rawList = this.ec02Builder.getHTTPRequest(eqxRawList); | |
| 63 | + for (int i = 0; i < rawList.size(); i++) { | |
| 64 | + this.eqxRawDataList.add(rawList.get(i)); | |
| 65 | + } | |
| 66 | + | |
| 67 | + this.eqxState = AFState.W_ARes; | |
| 68 | + | |
| 54 | 69 | } |
| 55 | 70 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); |
| 56 | 71 | return this.eqxState; | ... | ... |
AF-Demo/src/af/state/StateWaitA.java
| ... | ... | @@ -18,29 +18,43 @@ public class StateWaitA implements IAFState { |
| 18 | 18 | private String eqxState = null; |
| 19 | 19 | private EC02Builder ec02Builder = new EC02Builder(); |
| 20 | 20 | private ArrayList<EquinoxRawData> eqxRawDataList = new ArrayList<EquinoxRawData>(); |
| 21 | - | |
| 21 | + | |
| 22 | 22 | @Override |
| 23 | 23 | public String doAction(AbstractAF abstractAF, Object instance, ArrayList<EquinoxRawData> eqxRawDataList) { |
| 24 | - EC02Instance ec02Ins = (EC02Instance)instance; | |
| 25 | - | |
| 26 | - for(EquinoxRawData eqxRawData : eqxRawDataList) { | |
| 27 | - this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); | |
| 28 | - if(eqxRawData.getRawEventType().equals(AFEvent.Incoming_A_Response)){ | |
| 29 | - StringExtract str = new StringExtract(); | |
| 30 | - HashMap<String, String> map = str.getAll(str.setMessage(eqxRawData.getRawDataMessage().trim())); | |
| 31 | - String message = map.get("MSG[0].value"); | |
| 32 | - if (message.trim().equals("SUCCESS")) { | |
| 33 | - EQXRawInstance eqxRaw = new EQXRawInstance(); | |
| 34 | - eqxRaw.setMessage(message.trim()); | |
| 35 | - eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | |
| 36 | - eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | |
| 37 | - this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); | |
| 38 | - this.eqxState = AFState.IDLE; | |
| 39 | - } | |
| 40 | - else { | |
| 41 | - | |
| 42 | - } | |
| 24 | + EC02Instance ec02Ins = (EC02Instance) instance; | |
| 25 | + | |
| 26 | + for (EquinoxRawData eqxRawData : eqxRawDataList) { | |
| 27 | + this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); | |
| 28 | + /* | |
| 29 | + * if(eqxRawData.getRawEventType().equals(AFEvent. | |
| 30 | + * Incoming_A_Response)){ StringExtract str = new StringExtract(); | |
| 31 | + * HashMap<String, String> map = | |
| 32 | + * str.getAll(str.setMessage(eqxRawData.getRawDataMessage().trim())) | |
| 33 | + * ; String message = map.get("MSG[0].value"); if | |
| 34 | + * (message.trim().equals("SUCCESS")) { EQXRawInstance eqxRaw = new | |
| 35 | + * EQXRawInstance(); eqxRaw.setMessage(message.trim()); | |
| 36 | + * eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | |
| 37 | + * eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | |
| 38 | + * this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)) | |
| 39 | + * ; this.eqxState = AFState.IDLE; } else { | |
| 40 | + * | |
| 41 | + * } } | |
| 42 | + */ | |
| 43 | + | |
| 44 | + ArrayList<EQXRawInstance> eqxRawList = new ArrayList<EQXRawInstance>(); | |
| 45 | + | |
| 46 | + EQXRawInstance eqxRaw = new EQXRawInstance(); | |
| 47 | + eqxRaw.setMessage("C Req."); | |
| 48 | + eqxRaw.setTo(abstractAF.getUtils().getHmWarmConfig().get("Resource-Name-C").get(0)); | |
| 49 | + eqxRaw.setCtype(EQXMsg.TEXTXML); | |
| 50 | + eqxRawList.add(eqxRaw); | |
| 51 | + ArrayList<EquinoxRawData> rawList = this.ec02Builder.getHTTPRequest(eqxRawList); | |
| 52 | + for (int i = 0; i < rawList.size(); i++) { | |
| 53 | + this.eqxRawDataList.add(rawList.get(i)); | |
| 43 | 54 | } |
| 55 | + | |
| 56 | + this.eqxState = AFState.W_CRes; | |
| 57 | + | |
| 44 | 58 | } |
| 45 | 59 | ec02Ins.setEqxRawDataList(this.eqxRawDataList); |
| 46 | 60 | return this.eqxState; | ... | ... |
| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | +package af.state; | |
| 2 | + | |
| 3 | +import java.util.ArrayList; | |
| 4 | +import java.util.HashMap; | |
| 5 | + | |
| 6 | +import th.co.ais.equinox.utils.StringExtract; | |
| 7 | +import af.instatnce.EC02Instance; | |
| 8 | +import af.instatnce.EQXRawInstance; | |
| 9 | +import af.interfaces.AFEvent; | |
| 10 | +import af.interfaces.AFState; | |
| 11 | +import af.interfaces.EQXMsg; | |
| 12 | +import af.message.EC02Builder; | |
| 13 | +import ec02.af.abstracts.AbstractAF; | |
| 14 | +import ec02.af.data.EquinoxRawData; | |
| 15 | +import ec02.af.interfaces.IAFState; | |
| 16 | + | |
| 17 | +public class StateWaitC implements IAFState { | |
| 18 | + private String eqxState = null; | |
| 19 | + private EC02Builder ec02Builder = new EC02Builder(); | |
| 20 | + private ArrayList<EquinoxRawData> eqxRawDataList = new ArrayList<EquinoxRawData>(); | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + public String doAction(AbstractAF abstractAF, Object instance, ArrayList<EquinoxRawData> eqxRawDataList) { | |
| 24 | + EC02Instance ec02Ins = (EC02Instance) instance; | |
| 25 | + | |
| 26 | + for (EquinoxRawData eqxRawData : eqxRawDataList) { | |
| 27 | + this.ec02Builder.setEquinoxRawData(eqxRawData, abstractAF, ec02Ins); | |
| 28 | + /* | |
| 29 | + * if(eqxRawData.getRawEventType().equals(AFEvent. | |
| 30 | + * Incoming_A_Response)){ StringExtract str = new StringExtract(); | |
| 31 | + * HashMap<String, String> map = | |
| 32 | + * str.getAll(str.setMessage(eqxRawData.getRawDataMessage().trim())) | |
| 33 | + * ; String message = map.get("MSG[0].value"); if | |
| 34 | + * (message.trim().equals("SUCCESS")) { EQXRawInstance eqxRaw = new | |
| 35 | + * EQXRawInstance(); eqxRaw.setMessage(message.trim()); | |
| 36 | + * eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | |
| 37 | + * eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | |
| 38 | + * this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)) | |
| 39 | + * ; this.eqxState = AFState.IDLE; } else { | |
| 40 | + * | |
| 41 | + * } } | |
| 42 | + */ | |
| 43 | + | |
| 44 | + EQXRawInstance eqxRaw = new EQXRawInstance(); | |
| 45 | + eqxRaw.setMessage("A Res."); | |
| 46 | + eqxRaw.setTo(ec02Ins.getAFInstance().getOrig()); | |
| 47 | + eqxRaw.setCtype(EQXMsg.TEXTPLAIN); | |
| 48 | + this.eqxRawDataList.add(this.ec02Builder.getHTTPResponse(eqxRaw)); | |
| 49 | + this.eqxState = AFState.IDLE; | |
| 50 | + | |
| 51 | + } | |
| 52 | + ec02Ins.setEqxRawDataList(this.eqxRawDataList); | |
| 53 | + return this.eqxState; | |
| 54 | + } | |
| 55 | +} | ... | ... |