1 23 24 package org.objectweb.clif.isac.plugins; 25 26 import org.objectweb.clif.scenario.util.isac.plugin.SampleAction; 27 import org.objectweb.clif.scenario.util.isac.plugin.TestAction; 28 import org.objectweb.clif.scenario.util.isac.util.SessionObjectAction; 29 import org.objectweb.clif.scenario.util.isac.exception.IsacRuntimeException; 30 import org.objectweb.clif.storage.api.ActionEvent; 31 import java.util.Hashtable ; 32 33 34 38 public class Constants implements SampleAction, TestAction, SessionObjectAction 39 { 40 static public final int TRUE_TEST = 0; 42 static public final int FALSE_TEST = 1; 43 44 static public final int NOP_SAMPLE = 0; 46 static public final int ERROR_SAMPLE = 1; 48 49 50 54 public Constants(Hashtable params) 55 { 56 } 57 58 59 65 private Constants(Constants toClone) 66 { 67 } 68 69 70 74 75 public ActionEvent doSample(int number, Hashtable params, ActionEvent event) 76 { 77 event.setDate(System.currentTimeMillis()); 78 event.duration = 0; 79 switch (number) 80 { 81 case NOP_SAMPLE: 82 event.type = "NOP"; 83 event.comment = "no operation"; 84 event.successful = true; 85 break; 86 case ERROR_SAMPLE: 87 event.type = "ERROR"; 88 event.comment = "forced error"; 89 event.successful = false; 90 break; 91 default: 92 throw new Error ("Fatal error in ISAC's Constants plug-in: unknown sample identifier " + number); 93 } 94 return event; 95 } 96 97 98 102 103 public boolean doTest(int number, Hashtable params) 104 throws IsacRuntimeException 105 { 106 switch (number) 107 { 108 case TRUE_TEST: 109 return true; 110 case FALSE_TEST: 111 return false; 112 default: 113 throw new Error ("Fatal error in ISAC's Constants plug-in: unknown test identifier " + number); 114 } 115 } 116 117 118 122 123 public Object createNewSessionObject() 124 { 125 return new Constants(this); 126 } 127 128 129 public void close() 130 { 131 } 132 133 134 public void reset() 135 { 136 } 137 } 138 | Popular Tags |