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/JndiConfig.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   
   23   import javax.naming.InitialContext;
   24   
   25   import org.apache.jmeter.config.AbstractConfigElement;
   26   import org.apache.jmeter.config.ConfigElement;
   27   import org.apache.jmeter.ejb.jndi.config.LookupConfig;
   28   import org.apache.jmeter.util.JMeterUtils;
   29   import org.apache.log4j.Category;
   30   
   31   /**
   32    * Stores the configuration for JNDI sampling
   33    *
   34    * @author	Khor Soon Hin
   35    * Created	2001 Dec 17
   36    * @version $Revision: 1.3 $ Last Updated: $Date: 2004/02/13 02:40:54 $
   37    */
   38   public class JndiConfig extends AbstractConfigElement implements Serializable
   39   {
   40     private static Category catClass = Category.getInstance(
   41   	JndiConfig.class.getName());
   42   
   43     public static final int JNDI_INITIAL_CONTEXT_FACTORY = 0;
   44     public static final int JNDI_OBJECT_FACTORIES = 1;
   45     public static final int JNDI_STATE_FACTORIES = 2;
   46     public static final int JNDI_URL_PKG_PREFIXES = 3;
   47     public static final int JNDI_PROVIDER_URL = 4;
   48     public static final int JNDI_DNS_URL = 5;
   49     public static final int JNDI_AUTHORITATIVE = 6;
   50     public static final int JNDI_BATCHSIZE = 7;
   51     public static final int JNDI_REFERRAL = 8;
   52     public static final int JNDI_SECURITY_PROTOCOL = 9;
   53     public static final int JNDI_SECURITY_AUTHENTICATION = 10;
   54     public static final int JNDI_SECURITY_PRINCIPAL = 11;
   55     public static final int JNDI_SECURITY_CREDENTIALS = 12;
   56     public static final int JNDI_LANGUAGE = 13;
   57     public static final int JNDI_APPLET = 14;
   58   
   59     public static final String[] JNDI_PROPS = {
   60   	InitialContext.INITIAL_CONTEXT_FACTORY,
   61   	InitialContext.OBJECT_FACTORIES,
   62   	InitialContext.STATE_FACTORIES,
   63   	InitialContext.URL_PKG_PREFIXES,
   64   	InitialContext.PROVIDER_URL,
   65   	InitialContext.DNS_URL,
   66   	InitialContext.AUTHORITATIVE,
   67   	InitialContext.BATCHSIZE,
   68   	InitialContext.REFERRAL,
   69   	InitialContext.SECURITY_PROTOCOL,
   70   	InitialContext.SECURITY_AUTHENTICATION,
   71   	InitialContext.SECURITY_PRINCIPAL,
   72   	InitialContext.SECURITY_CREDENTIALS,
   73   	InitialContext.LANGUAGE,
   74   	InitialContext.APPLET
   75   	};
   76   
   77     protected InitialContext initCtx = null;
   78   
   79     public JndiConfig()
   80     {
   81     }
   82   
   83     public Class getGuiClass()
   84     {
   85       return org.apache.jmeter.ejb.jndi.config.gui.JndiConfigGui.class;
   86     }
   87   
   88     public Object clone()
   89     {
   90       JndiConfig newConfig = new JndiConfig();
   91       configureClone(newConfig);
   92       return newConfig;
   93     }
   94   
   95     public String getValue(int i)
   96     {
   97       String string = (String)this.getProperty(JNDI_PROPS[i]);
   98       if(catClass.isDebugEnabled())
   99       {
  100         catClass.debug("getValue1 : int - " + i);
  101         catClass.debug("getValue1 : name - " + JNDI_PROPS[i]);
  102         catClass.debug("getValue1 : value - " + string);
  103       }
  104       return string;
  105     }
  106   
  107     public void setValue(int i, String string)
  108     {
  109       if(catClass.isDebugEnabled())
  110       {
  111         catClass.debug("setValue1 : int - " + i);
  112         catClass.debug("setValue1 : name - " + JNDI_PROPS[i]);
  113         catClass.debug("setValue1 : value - " + string);
  114       }
  115       this.putProperty(JNDI_PROPS[i], string);
  116     }
  117   
  118     public String getClassLabel()
  119     {
  120       return JMeterUtils.getResString("jndi_config_title");
  121     }
  122   
  123     public void addConfigElement(ConfigElement config)
  124     {
  125       if(config instanceof JndiConfig)
  126       {
  127         updatePropertyIfAbsent((JndiConfig)config);
  128       }
  129     }
  130   
  131     public void setInitialContext(InitialContext initCtx)
  132     {
  133       this.initCtx = initCtx;
  134     }
  135   
  136     public InitialContext getInitialContext()
  137     { 
  138       return initCtx;
  139     }
  140   }

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