KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > isac > plugins > Constants


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 2005 France Telecom R&D
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * CLIF $Name: $
20 *
21 * Contact: clif@objectweb.org
22 */

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 JavaDoc;
32
33
34 /**
35  *
36  * @author Bruno Dillenseger
37  */

38 public class Constants implements SampleAction, TestAction, SessionObjectAction
39 {
40     // tests identifiers
41
static public final int TRUE_TEST = 0;
42     static public final int FALSE_TEST = 1;
43
44     // dummy successful sample identifier
45
static public final int NOP_SAMPLE = 0;
46     // dummy failing sample identifier
47
static public final int ERROR_SAMPLE = 1;
48
49
50     /**
51      * Build a new SessionObject for this plugin
52      * @param params The table containing all the parameters
53      */

54     public Constants(Hashtable JavaDoc params)
55     {
56     }
57
58
59     /**
60      * This constructor is used to clone the specified session object
61      *
62      * @param toClone
63      * The session object to clone
64      */

65     private Constants(Constants toClone)
66     {
67     }
68
69
70     ////////////////////////////
71
// SampleAction interface //
72
////////////////////////////
73

74
75     public ActionEvent doSample(int number, Hashtable JavaDoc 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 JavaDoc("Fatal error in ISAC's Constants plug-in: unknown sample identifier " + number);
93         }
94         return event;
95     }
96
97
98     ///////////////////////////
99
// TestAction interface //
100
///////////////////////////
101

102
103     public boolean doTest(int number, Hashtable JavaDoc 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 JavaDoc("Fatal error in ISAC's Constants plug-in: unknown test identifier " + number);
114         }
115     }
116
117
118     ///////////////////////////////////
119
// SessionObjectAction interface //
120
///////////////////////////////////
121

122
123     public Object JavaDoc 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