Save This Page
Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.visualizers » [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, WITHOUT
   13    * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   14    * License for the specific language governing permissions and limitations
   15    * under the License.
   16    *  
   17    */
   18   
   19   package org.apache.jmeter.visualizers;
   20   
   21   import org.apache.bsf.BSFException;
   22   import org.apache.bsf.BSFManager;
   23   import org.apache.jmeter.samplers.SampleEvent;
   24   import org.apache.jmeter.samplers.SampleListener;
   25   import org.apache.jmeter.samplers.SampleResult;
   26   import org.apache.jmeter.testbeans.TestBean;
   27   import org.apache.jmeter.util.BSFTestElement;
   28   import org.apache.jorphan.logging.LoggingManager;
   29   import org.apache.log.Logger;
   30   
   31   public class BSFListener extends BSFTestElement 
   32       implements Cloneable, SampleListener, TestBean, Visualizer {
   33   // N.B. Needs to implement Visualizer so that TestBeanGUI can find the correct GUI class
   34   
   35       private static final Logger log = LoggingManager.getLoggerForClass();
   36       
   37       private static final long serialVersionUID = 234L;
   38       
   39       public void sampleOccurred(SampleEvent event) {
   40           try {
   41               BSFManager mgr = getManager();
   42               if (mgr == null) {
   43                   log.error("Problem creating BSF manager");
   44                   return; 
   45               }
   46               mgr.declareBean("sampleEvent", event, SampleEvent.class);
   47               SampleResult result = event.getResult();
   48               mgr.declareBean("sampleResult", result, SampleResult.class);
   49               processFileOrScript(mgr);
   50               mgr.terminate();
   51           } catch (BSFException e) {
   52               log.warn("Problem in BSF script "+e);
   53           }
   54       }
   55   
   56       public void sampleStarted(SampleEvent e) {
   57       }
   58   
   59       public void sampleStopped(SampleEvent e) {
   60       }
   61   
   62       public void add(SampleResult sample) {
   63       }
   64   
   65       public boolean isStats() {
   66           return false;
   67       }
   68   }

Save This Page
Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.visualizers » [javadoc | source]