1 19 20 package org.apache.jmeter.module.loadgenerator.spi.impl; 21 22 import java.beans.PropertyChangeListener ; 23 import java.beans.PropertyChangeSupport ; 24 import org.apache.jmeter.engine.JMeterEngine; 25 import org.apache.jmeter.engine.JMeterEngineException; 26 27 31 public class ProcessDescriptor implements Cloneable { 32 public static final String RUNNING = "running"; 33 private JMeterEngine engine = null; 34 private String scriptPath = null; 35 private String 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 processName = ""; 42 43 private PropertyChangeSupport pcs = new PropertyChangeSupport (this); 44 45 48 public ProcessDescriptor(final JMeterEngine engine, final String scriptPath, final String displayName) { 49 this(engine, scriptPath, displayName, false); 50 } 51 52 public ProcessDescriptor(final JMeterEngine engine, final String scriptPath, final String displayName, final boolean running) { 53 this.engine = engine; 54 this.scriptPath = scriptPath; 55 this.displayName = displayName; 56 } 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 getScriptPath() { 72 return scriptPath; 73 } 74 75 public String 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 getProcessName() { 89 return processName; 90 } 91 92 public void setProcessName(String processName) { 93 this.processName = processName; 94 } 95 96 public Object clone() { 97 return new ProcessDescriptor(engine, scriptPath, displayName); 98 } 99 100 @Override 101 public boolean equals(Object 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 145 public int hashCode() { 146 return scriptPath.hashCode(); 147 } 148 149 public void addPropertyChangeListener(final String propertyName, final PropertyChangeListener listener) { 150 pcs.addPropertyChangeListener(propertyName, listener); 151 } 152 153 public void addPropertyChangeListener(final PropertyChangeListener listener) { 154 pcs.addPropertyChangeListener(listener); 155 } 156 157 public void removePropertyChangeListener(final String propertyName, final PropertyChangeListener listener) { 158 pcs.removePropertyChangeListener(propertyName, listener); 159 } 160 161 public void removePropertyChangeListener(final PropertyChangeListener listener) { 162 pcs.removePropertyChangeListener(listener); 163 } 164 } 165 | Popular Tags |