001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
014: * License for the specific language governing permissions and limitations
015: * under the License.
016: *
017: */
018:
019: /*
020: * Created on May 24, 2004
021: *
022: */
023: package org.apache.jmeter.protocol.http.sampler;
024:
025: import java.beans.PropertyDescriptor;
026: import java.io.IOException;
027: import java.util.List;
028:
029: import org.apache.jmeter.protocol.http.util.accesslog.Filter;
030: import org.apache.jmeter.protocol.http.util.accesslog.LogParser;
031: import org.apache.jmeter.testbeans.BeanInfoSupport;
032: import org.apache.jmeter.testbeans.gui.FileEditor;
033: import org.apache.jmeter.util.JMeterUtils;
034: import org.apache.jorphan.logging.LoggingManager;
035: import org.apache.jorphan.reflect.ClassFinder;
036: import org.apache.log.Logger;
037:
038: public class AccessLogSamplerBeanInfo extends BeanInfoSupport {
039: private static final Logger log = LoggingManager
040: .getLoggerForClass();
041:
042: public AccessLogSamplerBeanInfo() {
043: super (AccessLogSampler.class);
044: log.debug("Entered access log sampler bean info");
045: try {
046: createPropertyGroup("defaults", // $NON-NLS-1$
047: new String[] { "domain", "portString",
048: "imageParsing" });// $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
049:
050: createPropertyGroup(
051: "plugins", // $NON-NLS-1$
052: new String[] { "parserClassName", "filterClassName" }); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
053:
054: createPropertyGroup("accesslogfile", // $NON-NLS-1$
055: new String[] { "logFile" }); // $NON-NLS-1$
056:
057: PropertyDescriptor p;
058:
059: p = property("parserClassName");
060: p.setValue(NOT_UNDEFINED, Boolean.TRUE);
061: p.setValue(DEFAULT, AccessLogSampler.DEFAULT_CLASS);
062: p.setValue(NOT_OTHER, Boolean.TRUE);
063: p.setValue(NOT_EXPRESSION, Boolean.TRUE);
064: final List logParserClasses = ClassFinder
065: .findClassesThatExtend(
066: JMeterUtils.getSearchPaths(),
067: new Class[] { LogParser.class });
068: if (log.isDebugEnabled()) {
069: log.debug("found parsers: " + logParserClasses);
070: }
071: p.setValue(TAGS, logParserClasses.toArray(new String[0]));
072:
073: p = property("filterClassName"); // $NON-NLS-1$
074: p.setValue(NOT_UNDEFINED, Boolean.FALSE);
075: p.setValue(DEFAULT, ""); // $NON-NLS-1$
076: p.setValue(NOT_EXPRESSION, Boolean.TRUE);
077: p.setValue(TAGS, ClassFinder.findClassesThatExtend(
078: JMeterUtils.getSearchPaths(),
079: new Class[] { Filter.class }, false).toArray(
080: new String[0]));
081:
082: p = property("logFile"); // $NON-NLS-1$
083: p.setValue(NOT_UNDEFINED, Boolean.TRUE);
084: p.setValue(DEFAULT, "");
085: p.setPropertyEditorClass(FileEditor.class);
086:
087: p = property("domain"); // $NON-NLS-1$
088: p.setValue(NOT_UNDEFINED, Boolean.TRUE);
089: p.setValue(DEFAULT, "");
090:
091: p = property("portString"); // $NON-NLS-1$
092: p.setValue(NOT_UNDEFINED, Boolean.TRUE);
093: p.setValue(DEFAULT, ""); // $NON-NLS-1$
094:
095: p = property("imageParsing"); // $NON-NLS-1$
096: p.setValue(NOT_UNDEFINED, Boolean.TRUE);
097: p.setValue(DEFAULT, Boolean.FALSE);
098: p.setValue(NOT_OTHER, Boolean.TRUE);
099: } catch (IOException e) {
100: log.warn("couldn't find classes and set up properties", e);
101: throw new RuntimeException(
102: "Could not find classes with class finder");
103: }
104: log.debug("Got to end of access log samper bean info init");
105: }
106:
107: }
|