|
What this is
Other links
The source code// $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testbeans/BeanInfoSupport.java,v 1.4 2004/02/11 14:40:51 jsalvata Exp $ /* * Copyright 2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jmeter.testbeans; import java.awt.Image; import java.beans.BeanDescriptor; import java.beans.BeanInfo; import java.beans.EventSetDescriptor; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.MethodDescriptor; import java.beans.PropertyDescriptor; import java.beans.SimpleBeanInfo; import java.util.MissingResourceException; import java.util.ResourceBundle; import org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer; import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.logging.LoggingManager; import org.apache.log.Logger; /** * Support class for test bean beanInfo objects. It will help using the * introspector to get most of the information, to then modify it at will. *
* The resource bundle will be stored as the bean descriptor's "resourceBundle"
* attribute, so that it can be used for further localization. TestBeanGUI, for
* example, uses it to obtain the group's display names from properties
* groupName.displayName.
*
* @author Jordi Salvat i Alabart
* @version $Revision: 1.4 $ updated on $Date: 2004/02/11 14:40:51 $
*/
public abstract class BeanInfoSupport extends SimpleBeanInfo
{
private static transient Logger log = LoggingManager.getLoggerForClass();
// Some known attribute names, just for convenience:
public static final String TAGS=
GenericTestBeanCustomizer.TAGS;
public static final String NOT_UNDEFINED=
GenericTestBeanCustomizer.NOT_UNDEFINED;
public static final String NOT_EXPRESSION=
GenericTestBeanCustomizer.NOT_EXPRESSION;
public static final String NOT_OTHER=
GenericTestBeanCustomizer.NOT_OTHER;
public static final String DEFAULT=
GenericTestBeanCustomizer.DEFAULT;
public static final String RESOURCE_BUNDLE=
GenericTestBeanCustomizer.RESOURCE_BUNDLE;
/** The class for which we're providing the bean info. */
private Class beanClass;
/** The BeanInfo for our class as obtained by the introspector. */
private BeanInfo rootBeanInfo;
/** The icons for this bean. */
private Image[] icons= new Image[5];
/**
* Construct a BeanInfo for the given class.
*/
protected BeanInfoSupport(Class beanClass) {
this.beanClass= beanClass;
try {
rootBeanInfo= Introspector.getBeanInfo(
beanClass,
Introspector.IGNORE_IMMEDIATE_BEANINFO);
} catch (IntrospectionException e) {
log.error("Can't introspect.", e);
throw new Error(e.toString()); // Programming error: bail out.
}
try{
ResourceBundle resourceBundle= ResourceBundle.getBundle(
beanClass.getName()+"Resources",
JMeterUtils.getLocale());
// Store the resource bundle as an attribute of the BeanDescriptor:
getBeanDescriptor().setValue(RESOURCE_BUNDLE, resourceBundle);
// Localize the bean name
try
{
getBeanDescriptor().setDisplayName(
resourceBundle.getString("displayName"));
}
catch (MissingResourceException e)
{
log.debug(
"Localized display name not available for bean "
+beanClass.getName());
}
// Localize the property names and descriptions:
PropertyDescriptor[] properties= getPropertyDescriptors();
for (int i=0; i
* The created groups will get order 1, 2, 3,... in the order in which they
* are created.
*
* @param group name of the group
* @param names property names in the desired order
*/
protected void createPropertyGroup(String group, String[] names)
{
for (int i=0; i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.