alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

JMeter example source code file (AccessLogSamplerBeanInfo.java)

This example JMeter source code file (AccessLogSamplerBeanInfo.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - JMeter tags/keywords

accesslogsamplerbeaninfo, accesslogsamplerbeaninfo, bean, class, io, ioexception, javabean, list, non-nls-1, non-nls-1, non-nls-2, non-nls-3, non-nls-3, propertydescriptor, runtimeexception, string, string, util

The JMeter AccessLogSamplerBeanInfo.java source code

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 *
 */

/*
 * Created on May 24, 2004
 *
 */
package org.apache.jmeter.protocol.http.sampler;

import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.util.List;

import org.apache.jmeter.protocol.http.util.accesslog.Filter;
import org.apache.jmeter.protocol.http.util.accesslog.LogParser;
import org.apache.jmeter.testbeans.BeanInfoSupport;
import org.apache.jmeter.testbeans.gui.FileEditor;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.reflect.ClassFinder;
import org.apache.log.Logger;

public class AccessLogSamplerBeanInfo extends BeanInfoSupport {
    private static final Logger log = LoggingManager.getLoggerForClass();

    public AccessLogSamplerBeanInfo() {
        super(AccessLogSampler.class);
        log.debug("Entered access log sampler bean info");
        try {
            createPropertyGroup("defaults",  // $NON-NLS-1$
                    new String[] { "domain", "portString", "imageParsing" });// $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$

            createPropertyGroup("plugins",  // $NON-NLS-1$
                    new String[] { "parserClassName", "filterClassName" }); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$

            createPropertyGroup("accesslogfile",  // $NON-NLS-1$
                    new String[] { "logFile" }); // $NON-NLS-1$

            PropertyDescriptor p;

            p = property("parserClassName");
            p.setValue(NOT_UNDEFINED, Boolean.TRUE);
            p.setValue(DEFAULT, AccessLogSampler.DEFAULT_CLASS);
            p.setValue(NOT_OTHER, Boolean.TRUE);
            p.setValue(NOT_EXPRESSION, Boolean.TRUE);
            final List<String> logParserClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { LogParser.class });
            if (log.isDebugEnabled()) {
                log.debug("found parsers: " + logParserClasses);
            }
            p.setValue(TAGS, logParserClasses.toArray(new String[0]));

            p = property("filterClassName"); // $NON-NLS-1$
            p.setValue(NOT_UNDEFINED, Boolean.FALSE);
            p.setValue(DEFAULT, ""); // $NON-NLS-1$
            p.setValue(NOT_EXPRESSION, Boolean.TRUE);
            p.setValue(TAGS, ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(),
                    new Class[] { Filter.class }, false).toArray(new String[0]));

            p = property("logFile"); // $NON-NLS-1$
            p.setValue(NOT_UNDEFINED, Boolean.TRUE);
            p.setValue(DEFAULT, "");
            p.setPropertyEditorClass(FileEditor.class);

            p = property("domain"); // $NON-NLS-1$
            p.setValue(NOT_UNDEFINED, Boolean.TRUE);
            p.setValue(DEFAULT, "");

            p = property("portString"); // $NON-NLS-1$
            p.setValue(NOT_UNDEFINED, Boolean.TRUE);
            p.setValue(DEFAULT, ""); // $NON-NLS-1$

            p = property("imageParsing"); // $NON-NLS-1$
            p.setValue(NOT_UNDEFINED, Boolean.TRUE);
            p.setValue(DEFAULT, Boolean.FALSE);
            p.setValue(NOT_OTHER, Boolean.TRUE);
        } catch (IOException e) {
            log.warn("couldn't find classes and set up properties", e);
            throw new RuntimeException("Could not find classes with class finder");
        }
        log.debug("Got to end of access log samper bean info init");
    }

}

Other JMeter examples (source code examples)

Here is a short list of links related to this JMeter AccessLogSamplerBeanInfo.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.