Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.samplers » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *   http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    *
   17    */
   18   
   19   package org.apache.jmeter.samplers;
   20   
   21   import java.io.Serializable;
   22   import java.rmi.RemoteException;
   23   
   24   import org.apache.jmeter.engine.event.LoopIterationEvent;
   25   import org.apache.jmeter.engine.util.NoThreadClone;
   26   import org.apache.jmeter.testelement.AbstractTestElement;
   27   import org.apache.jmeter.testelement.TestListener;
   28   import org.apache.jorphan.logging.LoggingManager;
   29   import org.apache.log.Logger;
   30   
   31   /**
   32    *
   33    * Lars-Erik Helander provided the idea (and original implementation) for the
   34    * caching functionality (sampleStore).
   35    *
   36    * @version $Revision: 703755 $
   37    */
   38   public class RemoteListenerWrapper extends AbstractTestElement implements SampleListener, TestListener, Serializable,
   39           NoThreadClone {
   40       private static final Logger log = LoggingManager.getLoggerForClass();
   41   
   42       private final RemoteSampleListener listener;
   43   
   44       private final SampleSender sender;
   45   
   46       public RemoteListenerWrapper(RemoteSampleListener l) {
   47           listener = l;
   48           // Get appropriate sender class governed by the behaviour set in the JMeter property
   49           sender = SampleSenderFactory.getInstance(listener);
   50       }
   51   
   52       public RemoteListenerWrapper() // TODO: not used - make private?
   53       {
   54           listener = null;
   55           sender = null;
   56       }
   57   
   58       public void testStarted() {
   59           log.info("Test Started()");
   60           try {
   61               listener.testStarted();
   62           } catch (Throwable ex) {
   63               log.warn("testStarted()", ex);
   64           }
   65   
   66       }
   67   
   68       public void testEnded() {
   69           sender.testEnded();
   70       }
   71   
   72       public void testStarted(String host) {
   73           log.info("Test Started on " + host); // should this be debug?
   74           try {
   75               listener.testStarted(host);
   76           } catch (Throwable ex) {
   77               log.error("testStarted(host)", ex);
   78           }
   79       }
   80   
   81       public void testEnded(String host) {
   82           sender.testEnded(host);
   83       }
   84   
   85       public void sampleOccurred(SampleEvent e) {
   86           sender.sampleOccurred(e);
   87       }
   88   
   89       // Note that sampleStarted() and sampleStopped() is not made to appear
   90       // in synch with sampleOccured() when replaying held samples.
   91       // For now this is not critical since sampleStarted() and sampleStopped()
   92       // is not used, but it may become an issue in the future. Then these
   93       // events must also be stored so that replay of all events may occur and
   94       // in the right order. Each stored event must then be tagged with something
   95       // that lets you distinguish between occured, started and ended.
   96   
   97       public void sampleStarted(SampleEvent e) {
   98           log.debug("Sample started");
   99           try {
  100               listener.sampleStarted(e);
  101           } catch (RemoteException err) {
  102               log.error("sampleStarted", err);
  103           }
  104       }
  105   
  106       public void sampleStopped(SampleEvent e) {
  107           log.debug("Sample stopped");
  108           try {
  109               listener.sampleStopped(e);
  110           } catch (RemoteException err) {
  111               log.error("sampleStopped", err);
  112           }
  113       }
  114   
  115       /*
  116        * (non-Javadoc)
  117        *
  118        * @see TestListener#testIterationStart(LoopIterationEvent)
  119        */
  120       public void testIterationStart(LoopIterationEvent event) {
  121       }
  122   
  123   }

Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.samplers » [javadoc | source]