Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.ejb.jndi.config » [javadoc | source]

    1   // $Header: /home/cvs/jakarta-jmeter/src/protocol/jndi/config/MethodConfig.java,v 1.3 2004/02/13 02:40:54 sebb Exp $
    2   /*
    3    * Copyright 2001-2004 The Apache Software Foundation.
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * 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.ejb.jndi.config;
   20   
   21   import java.io.Serializable;
   22   import java.lang.reflect.Method;
   23   import java.util.ArrayList;
   24   
   25   import org.apache.jmeter.config.AbstractConfigElement;
   26   import org.apache.jmeter.config.ConfigElement;
   27   import org.apache.jmeter.ejb.jndi.config.gui.MethodConfigGui;
   28   import org.apache.jmeter.util.JMeterUtils;
   29   import org.apache.log4j.Category;
   30   
   31   /**
   32    * Stores the configuration for remote method execution
   33    *
   34    * @author	Khor Soon Hin
   35    * Created	2001 Dec 24
   36    * @version $Revision: 1.3 $ Last Updated: $Date: 2004/02/13 02:40:54 $
   37    */
   38   public class MethodConfig extends AbstractConfigElement implements Serializable
   39   {
   40     private static Category catClass = Category.getInstance(
   41   	MethodConfig.class.getName());
   42   
   43     protected static final String METHOD_HOME_NAME = 
   44   	"MethodConfig.method_home_name";
   45     protected static final String METHOD_HOME_LIST = 
   46   	"MethodConfig.method_home_list";
   47     protected static final String METHOD_HOME_PARMS = 
   48   	"MethodConfig.method_home_parms";
   49     protected static final String METHOD_REMOTE_INTERFACE_LIST = 
   50   	"MethodConfig.method_remote_name_list";
   51     protected static final String METHOD_REMOTE_NAME =
   52   	"MethodConfig.method_remote_name";
   53     protected static final String METHOD_REMOTE_LIST =
   54   	"MethodConfig.method_remote_list";
   55     protected static final String METHOD_REMOTE_PARMS =
   56   	"MethodConfig.method_remote_parms";
   57     protected static final String METHOD_CONFIG_GUI =
   58   	"MethodConfig.method_config_gui";
   59   	// Attach the gui to the model.  This enables us to get the gui
   60   	// instance given the model.  This is important for MethodConfig
   61   	// class since sampling this class generates Method names
   62   	// and parameters (through reflection) which will be used in the
   63   	// MethodConfigGui
   64     protected static final String METHOD_REMOTE_INTERFACE_TYPE = 
   65   	"MethodConfig.method_remote_interface_type";
   66   
   67     // Below are the states the MethodConfig can be in. Depending on the state
   68     // which MethodConfig is in, when 'Run' is executed, the sampler
   69     // will perform different things.  See explanation of each state below.
   70     public static final int METHOD_GET_HOME_NAMES = 0;
   71   	// reflect on all the method names of the Home interface
   72     public static final int METHOD_GET_HOME_PARMS = 1;
   73   	// with a Home method selected reflect on all parms of the method
   74     public static final int METHOD_INVOKE_HOME = 2;
   75   	// with all parms of the selected method filled, invoke the method
   76     public static final int METHOD_SELECT_REMOTE_INTERFACE = 3;
   77     public static final int METHOD_GET_REMOTE_NAMES = 4;
   78   	// reflect on all the method names of the Remote interface
   79     public static final int METHOD_GET_REMOTE_PARMS = 5;
   80   	// with a Remote method selected reflect on all parms of the method
   81     public static final int METHOD_INVOKE_REMOTE = 6;
   82     public static final int METHOD_COMPLETE = 7;
   83   
   84     protected Method homeMethod;
   85     protected Method remoteMethod;
   86     protected int state;
   87     // This variable is always false until the 'Reflect' button on the
   88     // ejb method config panel is clicked.  This allows the JNDISampler
   89     // to differentiate between sampling and relfection since it does both.
   90     // When it does reflection, it will only run one reflection step at each time
   91     // e.g. the first reflection will expose all methods of the home object
   92     // returned by the lookup, the second the parms of the selected home object
   93     // method etc.  For sampling all the steps will be run.
   94     protected boolean reflectionStatus = false;
   95   	
   96     public MethodConfig()
   97     {
   98     }
   99   
  100     public Class getGuiClass()
  101     {
  102       return org.apache.jmeter.ejb.jndi.config.gui.MethodConfigGui.class;
  103     }
  104   
  105     public Object clone()
  106     {
  107       MethodConfig newConfig = new MethodConfig();
  108       configureClone(newConfig);
  109       return newConfig;
  110     }
  111   
  112     public String getMethodHomeName()
  113     {
  114       String string = (String)this.getProperty(METHOD_HOME_NAME);
  115       if(catClass.isDebugEnabled())
  116       {
  117         catClass.debug("getMethodHomeName1 : method home name - " + string);
  118       }
  119       return string;
  120     }
  121   
  122     public void setMethodHomeName(String string)
  123     {
  124       if(catClass.isDebugEnabled())
  125       {
  126         catClass.debug("setMethodHomeName1 : method home name  - " + string);
  127       }
  128       this.putProperty(METHOD_HOME_NAME, string);
  129     }
  130   
  131     public String getMethodRemoteName()
  132     {
  133       String string = (String)this.getProperty(METHOD_REMOTE_NAME);
  134       if(catClass.isDebugEnabled())
  135       {
  136         catClass.debug("getMethodRemoteName1 : method remote name - " + string);
  137       }
  138       return string;
  139     }
  140   
  141     public void setMethodRemoteName(Object ref)
  142     {
  143       if(catClass.isDebugEnabled())
  144       {
  145         catClass.debug("setMethodRemoteName1 : method remote name  - " + ref);
  146       }
  147       this.putProperty(METHOD_REMOTE_NAME, ref);
  148     }
  149   
  150     public Object getRemoteInterfaceType()
  151     {
  152       Object ref  = this.getProperty(METHOD_REMOTE_INTERFACE_TYPE);
  153       if(catClass.isDebugEnabled())
  154       {
  155         catClass.debug("getRemoteInterfaceType1 : remote interface - " + 
  156   	ref);
  157       }
  158       return ref;
  159     }
  160   
  161     public void setRemoteInterfaceType(Object ref)
  162     {
  163       if(catClass.isDebugEnabled())
  164       {
  165         catClass.debug("setRemoteInterfaceType1 : remote interface - " +
  166   	ref);
  167       }
  168       this.putProperty(METHOD_REMOTE_INTERFACE_TYPE, ref);
  169     }
  170   
  171     public Object getRemoteInterfaceList()
  172     {
  173       Object ref = this.getProperty(METHOD_REMOTE_INTERFACE_LIST);
  174       if(catClass.isDebugEnabled())
  175       {
  176         catClass.debug("getRemoteInterfaceList1 : remote interface list - " + 
  177   	ref);
  178       }
  179       return ref;
  180     }
  181   
  182     public void setRemoteInterfaceList(Object ref)
  183     {
  184       if(catClass.isDebugEnabled())
  185       {
  186         catClass.debug("setRemoteInterfaceList1 : remote interface list - " +
  187   	ref);
  188       }
  189       this.putProperty(METHOD_REMOTE_INTERFACE_LIST, ref);
  190     }
  191   
  192     public String[] getMethodHomeList()
  193     {
  194       String[] strings = (String[])this.getProperty(METHOD_HOME_LIST);
  195       return strings;
  196     }
  197   
  198     public void setMethodHomeList(String[] list)
  199     {
  200       this.putProperty(METHOD_HOME_LIST, list);
  201     }
  202   
  203     public String[] getMethodRemoteList()
  204     {
  205       String[] strings = (String[])this.getProperty(METHOD_REMOTE_LIST);
  206       return strings;
  207     }
  208   
  209     public void setMethodRemoteList(String[] list)
  210     {
  211       this.putProperty(METHOD_REMOTE_LIST, list);
  212     }
  213   
  214     public Class[] getMethodHomeParms()
  215     {
  216       Class[] classes= (Class[])this.getProperty(METHOD_HOME_PARMS);
  217       return classes;
  218     }
  219   
  220     public void setMethodHomeParms(Class[] list)
  221     {
  222       this.putProperty(METHOD_HOME_PARMS, list);
  223     }
  224   
  225     public  Class[] getMethodRemoteParms()
  226     {
  227       Class[] classes= (Class[])this.getProperty(METHOD_REMOTE_PARMS);
  228       return classes;
  229     }
  230   
  231     public void setMethodRemoteParms(Class[] list)
  232     {
  233       this.putProperty(METHOD_REMOTE_PARMS, list);
  234     }
  235   
  236     public int getState()
  237     {
  238       return state;
  239     }
  240   
  241     public void setState(int current)
  242     {
  243       state = current;
  244     }
  245   
  246     public String getClassLabel()
  247     {
  248       return JMeterUtils.getResString("jndi_method_title");
  249     }
  250   
  251     public void addConfigElement(ConfigElement config)
  252     {
  253     }
  254   
  255     public void setGui(MethodConfigGui gui)
  256     {
  257       this.putProperty(METHOD_CONFIG_GUI, gui);
  258     }
  259   
  260     public MethodConfigGui getGui()
  261     {
  262       return (MethodConfigGui)this.getProperty(METHOD_CONFIG_GUI);
  263     }
  264   
  265     public void setHomeMethod(Method aMethod)
  266     {
  267       homeMethod = aMethod;
  268     }
  269   
  270     public Method getHomeMethod()
  271     {
  272       return homeMethod;
  273     }
  274   
  275     public void setRemoteMethod(Method aMethod)
  276     {
  277       remoteMethod = aMethod;
  278     }
  279   
  280     public Method getRemoteMethod()
  281     {
  282       return remoteMethod;
  283     }
  284   
  285     public void setReflectionStatus(boolean status)
  286     { 
  287       reflectionStatus = status;
  288     }
  289   
  290     public boolean getReflectionStatus()
  291     {
  292       return reflectionStatus;
  293     }
  294   }

Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.ejb.jndi.config » [javadoc | source]