You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2004/01/16 00:46:47 UTC

cvs commit: jakarta-jmeter/src/core/org/apache/jmeter/samplers ExampleSampler.java

sebb        2004/01/15 15:46:47

  Modified:    src/core/org/apache/jmeter/samplers ExampleSampler.java
  Log:
  Add some more info and logging
  
  Revision  Changes    Path
  1.2       +27 -1     jakarta-jmeter/src/core/org/apache/jmeter/samplers/ExampleSampler.java
  
  Index: ExampleSampler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/samplers/ExampleSampler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExampleSampler.java	15 Jan 2004 01:02:16 -0000	1.1
  +++ ExampleSampler.java	15 Jan 2004 23:46:47 -0000	1.2
  @@ -61,6 +61,15 @@
   /**
    * Example Sampler (non-Bean version)
    * 
  + * JMeter creates an instance of a sampler class for every
  + * occurrence of the element in every thread.
  + * [some additional copies may be created before the test run starts]
  + *
  + * Thus each sampler is guaranteed to be called by a single thread -
  + * there is no need to synchronize access to instance variables.
  + * 
  + * However, access to class fields must be synchronized.
  + *  
    * @author sebb AT apache DOT org
    * @version $revision$ $date$
    */
  @@ -72,8 +81,13 @@
       // The name of the property used to hold our data
   	public final static String DATA = "ExampleSampler.data";   //$NON-NLS-1$
   	
  +	private transient static int classCount=0; // keep track of classes created
  +	// (for instructional purposes only!)
  +	
   	public ExampleSampler()
   	{
  +		classCount++;
  +		trace("ExampleSampler()");
   	}
   
       /* (non-Javadoc)
  @@ -83,6 +97,7 @@
        */
       public SampleResult sample(Entry e)
       {
  +    	trace("sample()");
   		SampleResult res = new SampleResult();
   		boolean isOK = false; // Did sample succeed?
   		String data=getData(); // Sampler data
  @@ -127,7 +142,7 @@
        */
       private String getTitle()
       {
  -        return "ExampleSample";
  +        return this.getName();
       }
       
       /**
  @@ -137,4 +152,15 @@
       {
       	return getPropertyAsString(DATA);
       }
  +    
  +    /*
  +     * Helper method
  +     */
  +	private void trace(String s)
  +	{
  +		String tl = getTitle();
  +		String tn = Thread.currentThread().getName();
  +		String th = this.toString();
  +		log.debug(tn+" ("+classCount+") "+tl+" "+s+" "+th);
  +	}
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org