KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > module > loadgenerator > spi > impl > ProcessDescriptor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.apache.jmeter.module.loadgenerator.spi.impl;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeSupport JavaDoc;
24 import org.apache.jmeter.engine.JMeterEngine;
25 import org.apache.jmeter.engine.JMeterEngineException;
26
27 /**
28  *
29  * @author Jaroslav Bachorik
30  */

31 public class ProcessDescriptor implements Cloneable JavaDoc {
32   public static final String JavaDoc RUNNING = "running";
33   private JMeterEngine engine = null;
34   private String JavaDoc scriptPath = null;
35   private String JavaDoc displayName = null;
36   private boolean running = false;
37   private int threadsCount = 0;
38   private int interleave = 0;
39   private int rampup = 0;
40   private boolean nbReady = false;
41   private String JavaDoc processName = "";
42   
43   private PropertyChangeSupport JavaDoc pcs = new PropertyChangeSupport JavaDoc(this);
44   
45   /**
46    * Creates a new instance of ProcessDescriptor
47    */

48   public ProcessDescriptor(final JMeterEngine engine, final String JavaDoc scriptPath, final String JavaDoc displayName) {
49     this(engine, scriptPath, displayName, false);
50   }
51   
52   public ProcessDescriptor(final JMeterEngine engine, final String JavaDoc scriptPath, final String JavaDoc displayName, final boolean running) {
53     this.engine = engine;
54     this.scriptPath = scriptPath;
55     this.displayName = displayName;
56 // this.running = running;
57
}
58
59   public void start() throws JMeterEngineException {
60     engine.runTest();
61   }
62   
63   public void stop() {
64     engine.stopTest();
65   }
66   
67   public JMeterEngine getEngine() {
68     return engine;
69   }
70
71   public String JavaDoc getScriptPath() {
72     return scriptPath;
73   }
74
75   public String JavaDoc getDisplayName() {
76     return displayName;
77   }
78
79   public boolean isRunning() {
80     return running;
81   }
82
83   public void setRunning(boolean running) {
84     pcs.firePropertyChange(RUNNING, this.running, running);
85     this.running = running;
86   }
87
88   public String JavaDoc getProcessName() {
89     return processName;
90   }
91
92   public void setProcessName(String JavaDoc processName) {
93     this.processName = processName;
94   }
95
96   public Object JavaDoc clone() {
97     return new ProcessDescriptor(engine, scriptPath, displayName);
98   }
99   
100   @Override JavaDoc
101   public boolean equals(Object JavaDoc another) {
102     if (another == null)
103       return false;
104     if (!(another instanceof ProcessDescriptor))
105       return false;
106     
107     ProcessDescriptor desc = (ProcessDescriptor)another;
108     
109     return scriptPath.equals(desc.scriptPath);
110   }
111
112   public boolean isNbReady() {
113     return nbReady;
114   }
115
116   public void setNbReady(boolean nbReady) {
117     this.nbReady = nbReady;
118   }
119
120   public int getThreadsCount() {
121     return threadsCount;
122   }
123
124   public void setThreadsCount(int threadsCount) {
125     this.threadsCount = threadsCount;
126   }
127   
128   public int getInterleave() {
129     return interleave;
130   }
131
132   public void setInterleave(int interleave) {
133     this.interleave = interleave;
134   }
135
136   public int getRampup() {
137     return rampup;
138   }
139
140   public void setRampup(int rampup) {
141     this.rampup = rampup;
142   }
143
144   @Override JavaDoc
145   public int hashCode() {
146     return scriptPath.hashCode();
147   }
148   
149   public void addPropertyChangeListener(final String JavaDoc propertyName, final PropertyChangeListener JavaDoc listener) {
150     pcs.addPropertyChangeListener(propertyName, listener);
151   }
152   
153   public void addPropertyChangeListener(final PropertyChangeListener JavaDoc listener) {
154     pcs.addPropertyChangeListener(listener);
155   }
156   
157   public void removePropertyChangeListener(final String JavaDoc propertyName, final PropertyChangeListener JavaDoc listener) {
158     pcs.removePropertyChangeListener(propertyName, listener);
159   }
160   
161   public void removePropertyChangeListener(final PropertyChangeListener JavaDoc listener) {
162     pcs.removePropertyChangeListener(listener);
163   }
164 }
165
Popular Tags