You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/13 00:17:37 UTC
[logging-log4j2] branch master updated: Add classes from version 1.2.17.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new 444e38c Add classes from version 1.2.17.
444e38c is described below
commit 444e38cec537cd74288e10c25e52a2596bd7d4a1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 12 19:12:01 2022 -0500
Add classes from version 1.2.17.
- Binary compatibility.
- Parts may be reimplemented later.
- Some are used in forthcoming tests.
---
.../java/org/apache/log4j/varia/DenyAllFilter.java | 65 ++++++++++
.../apache/log4j/varia/FallbackErrorHandler.java | 126 ++++++++++++++++++++
.../org/apache/log4j/varia/LevelMatchFilter.java | 91 ++++++++++++++
.../org/apache/log4j/varia/LevelRangeFilter.java | 131 +++++++++++++++++++++
.../java/org/apache/log4j/varia/NullAppender.java | 87 ++++++++++++++
.../log4j/varia/ReloadingPropertyConfigurator.java | 47 ++++++++
.../org/apache/log4j/varia/StringMatchFilter.java | 106 +++++++++++++++++
7 files changed, 653 insertions(+)
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/DenyAllFilter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/DenyAllFilter.java
new file mode 100644
index 0000000..4646bda
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/DenyAllFilter.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+package org.apache.log4j.varia;
+
+import org.apache.log4j.spi.Filter;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * Denies all logging events.
+ *
+ * <p>
+ * You can add this filter to the end of a filter chain to switch from the default "accept all unless instructed
+ * otherwise" filtering behavior to a "deny all unless instructed otherwise" behavior.
+ * </p>
+ *
+ * @since 0.9.0
+ */
+public class DenyAllFilter extends Filter {
+
+ /**
+ * Always returns the integer constant {@link Filter#DENY} regardless of the {@link LoggingEvent} parameter.
+ *
+ * @param event The LoggingEvent to filter.
+ * @return Always returns {@link Filter#DENY}.
+ */
+ @Override
+ public int decide(final LoggingEvent event) {
+ return Filter.DENY;
+ }
+
+ /**
+ * Returns <code>null</code> as there are no options.
+ *
+ * @deprecated We now use JavaBeans introspection to configure components. Options strings are no longer needed.
+ */
+ @Deprecated
+ public String[] getOptionStrings() {
+ return null;
+ }
+
+ /**
+ * No options to set.
+ *
+ * @deprecated Use the setter method for the option directly instead of the generic <code>setOption</code> method.
+ */
+ @Deprecated
+ public void setOption(final String key, final String value) {
+ // noop
+ }
+}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java
new file mode 100644
index 0000000..e2a1898
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+
+package org.apache.log4j.varia;
+
+import java.io.InterruptedIOException;
+import java.util.Vector;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.helpers.LogLog;
+import org.apache.log4j.spi.ErrorHandler;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * An ErrorHandler with a secondary appender. This secondary appender takes over if the primary appender fails for
+ * whatever reason.
+ *
+ * <p>
+ * The error message is printed on <code>System.err</code>, and logged in the new secondary appender.
+ * </p>
+ */
+public class FallbackErrorHandler implements ErrorHandler {
+
+ Appender backup;
+ Appender primary;
+ Vector loggers;
+
+ public FallbackErrorHandler() {
+ // noop
+ }
+
+ /**
+ * No options to activate.
+ */
+ public void activateOptions() {
+ // noop
+ }
+
+ /**
+ * Print a the error message passed as parameter on <code>System.err</code>.
+ */
+ @Override
+ public void error(final String message) {
+ // if(firstTime) {
+ // LogLog.error(message);
+ // firstTime = false;
+ // }
+ }
+
+ /**
+ * Prints the message and the stack trace of the exception on <code>System.err</code>.
+ */
+ @Override
+ public void error(final String message, final Exception e, final int errorCode) {
+ error(message, e, errorCode, null);
+ }
+
+ /**
+ * Prints the message and the stack trace of the exception on <code>System.err</code>.
+ */
+ @Override
+ public void error(final String message, final Exception e, final int errorCode, final LoggingEvent event) {
+ if (e instanceof InterruptedIOException) {
+ Thread.currentThread().interrupt();
+ }
+ LogLog.debug("FB: The following error reported: " + message, e);
+ LogLog.debug("FB: INITIATING FALLBACK PROCEDURE.");
+ if (loggers != null) {
+ for (int i = 0; i < loggers.size(); i++) {
+ final Logger l = (Logger) loggers.elementAt(i);
+ LogLog.debug("FB: Searching for [" + primary.getName() + "] in logger [" + l.getName() + "].");
+ LogLog.debug("FB: Replacing [" + primary.getName() + "] by [" + backup.getName() + "] in logger [" + l.getName() + "].");
+ l.removeAppender(primary);
+ LogLog.debug("FB: Adding appender [" + backup.getName() + "] to logger " + l.getName());
+ l.addAppender(backup);
+ }
+ }
+ }
+
+ /**
+ * The appender to which this error handler is attached.
+ */
+ @Override
+ public void setAppender(final Appender primary) {
+ LogLog.debug("FB: Setting primary appender to [" + primary.getName() + "].");
+ this.primary = primary;
+ }
+
+ /**
+ * Set the backup appender.
+ */
+ @Override
+ public void setBackupAppender(final Appender backup) {
+ LogLog.debug("FB: Setting backup appender to [" + backup.getName() + "].");
+ this.backup = backup;
+ }
+
+ /**
+ * <em>Adds</em> the logger passed as parameter to the list of loggers that we need to search for in case of appender
+ * failure.
+ */
+ @Override
+ public void setLogger(final Logger logger) {
+ LogLog.debug("FB: Adding logger [" + logger.getName() + "].");
+ if (loggers == null) {
+ loggers = new Vector();
+ }
+ loggers.addElement(logger);
+ }
+
+}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java
new file mode 100644
index 0000000..c7693e4
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+package org.apache.log4j.varia;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.helpers.OptionConverter;
+import org.apache.log4j.spi.Filter;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * Simple filter based on level matching.
+ *
+ * <p>
+ * The filter admits two options <b>LevelToMatch</b> and <b>AcceptOnMatch</b>. If there is an exact match between the
+ * value of the <b>LevelToMatch</b> option and the level of the {@link LoggingEvent}, then the {@link #decide} method
+ * returns {@link Filter#ACCEPT} in case the <b>AcceptOnMatch</b> option value is set to <code>true</code>, if it is
+ * <code>false</code> then {@link Filter#DENY} is returned. If there is no match, {@link Filter#NEUTRAL} is returned.
+ * </p>
+ *
+ * @since 1.2
+ */
+public class LevelMatchFilter extends Filter {
+
+ /**
+ * Do we return ACCEPT when a match occurs. Default is <code>true</code>.
+ */
+ boolean acceptOnMatch = true;
+
+ /**
+ */
+ Level levelToMatch;
+
+ /**
+ * Return the decision of this filter.
+ *
+ * Returns {@link Filter#NEUTRAL} if the <b>LevelToMatch</b> option is not set or if there is not match. Otherwise, if
+ * there is a match, then the returned decision is {@link Filter#ACCEPT} if the <b>AcceptOnMatch</b> property is set to
+ * <code>true</code>. The returned decision is {@link Filter#DENY} if the <b>AcceptOnMatch</b> property is set to false.
+ *
+ */
+ @Override
+ public int decide(final LoggingEvent event) {
+ if (this.levelToMatch == null) {
+ return Filter.NEUTRAL;
+ }
+
+ boolean matchOccured = false;
+ if (this.levelToMatch.equals(event.getLevel())) {
+ matchOccured = true;
+ }
+
+ if (matchOccured) {
+ if (this.acceptOnMatch) {
+ return Filter.ACCEPT;
+ }
+ return Filter.DENY;
+ }
+ return Filter.NEUTRAL;
+ }
+
+ public boolean getAcceptOnMatch() {
+ return acceptOnMatch;
+ }
+
+ public String getLevelToMatch() {
+ return levelToMatch == null ? null : levelToMatch.toString();
+ }
+
+ public void setAcceptOnMatch(final boolean acceptOnMatch) {
+ this.acceptOnMatch = acceptOnMatch;
+ }
+
+ public void setLevelToMatch(final String level) {
+ levelToMatch = OptionConverter.toLevel(level, null);
+ }
+}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java
new file mode 100644
index 0000000..fdd5c10
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+package org.apache.log4j.varia;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.spi.Filter;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * This is a very simple filter based on level matching, which can be used to reject messages with priorities outside a
+ * certain range.
+ * <p>
+ * The filter admits three options <b>LevelMin</b>, <b>LevelMax</b> and <b>AcceptOnMatch</b>.
+ * </p>
+ * <p>
+ * If the level of the {@link LoggingEvent} is not between Min and Max (inclusive), then {@link Filter#DENY} is
+ * returned.
+ * </p>
+ * <p>
+ * If the Logging event level is within the specified range, then if <b>AcceptOnMatch</b> is true, {@link Filter#ACCEPT}
+ * is returned, and if <b>AcceptOnMatch</b> is false, {@link Filter#NEUTRAL} is returned.
+ * </p>
+ * <p>
+ * If <code>LevelMin</code>w is not defined, then there is no minimum acceptable level (ie a level is never rejected for
+ * being too "low"/unimportant). If <code>LevelMax</code> is not defined, then there is no maximum acceptable level (ie
+ * a level is never rejected for beeing too "high"/important).
+ * </p>
+ * <p>
+ * Refer to the {@link org.apache.log4j.AppenderSkeleton#setThreshold setThreshold} method available to <code>all</code>
+ * appenders extending {@link org.apache.log4j.AppenderSkeleton} for a more convenient way to filter out events by
+ * level.
+ * </p>
+ */
+public class LevelRangeFilter extends Filter {
+
+ /**
+ * Do we return ACCEPT when a match occurs. Default is <code>false</code>, so that later filters get run by default
+ */
+ boolean acceptOnMatch;
+
+ Level levelMin;
+ Level levelMax;
+
+ /**
+ * Return the decision of this filter.
+ */
+ @Override
+ public int decide(final LoggingEvent event) {
+ if (this.levelMin != null) {
+ if (!event.getLevel().isGreaterOrEqual(levelMin)) {
+ // level of event is less than minimum
+ return Filter.DENY;
+ }
+ }
+
+ if (this.levelMax != null) {
+ if (event.getLevel().toInt() > levelMax.toInt()) {
+ // level of event is greater than maximum
+ // Alas, there is no Level.isGreater method. and using
+ // a combo of isGreaterOrEqual && !Equal seems worse than
+ // checking the int values of the level objects..
+ return Filter.DENY;
+ }
+ }
+
+ if (acceptOnMatch) {
+ // this filter set up to bypass later filters and always return
+ // accept if level in range
+ return Filter.ACCEPT;
+ }
+ // event is ok for this filter; allow later filters to have a look..
+ return Filter.NEUTRAL;
+ }
+
+ /**
+ * Get the value of the <code>AcceptOnMatch</code> option.
+ */
+ public boolean getAcceptOnMatch() {
+ return acceptOnMatch;
+ }
+
+ /**
+ * Get the value of the <code>LevelMax</code> option.
+ */
+ public Level getLevelMax() {
+ return levelMax;
+ }
+
+ /**
+ * Get the value of the <code>LevelMin</code> option.
+ */
+ public Level getLevelMin() {
+ return levelMin;
+ }
+
+ /**
+ * Set the <code>AcceptOnMatch</code> option.
+ */
+ public void setAcceptOnMatch(final boolean acceptOnMatch) {
+ this.acceptOnMatch = acceptOnMatch;
+ }
+
+ /**
+ * Set the <code>LevelMax</code> option.
+ */
+ public void setLevelMax(final Level levelMax) {
+ this.levelMax = levelMax;
+ }
+
+ /**
+ * Set the <code>LevelMin</code> option.
+ */
+ public void setLevelMin(final Level levelMin) {
+ this.levelMin = levelMin;
+ }
+}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/NullAppender.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/NullAppender.java
new file mode 100644
index 0000000..cf66475
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/NullAppender.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+package org.apache.log4j.varia;
+
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * A NullAppender never outputs a message to any device.
+ */
+public class NullAppender extends AppenderSkeleton {
+
+ private static final NullAppender INSTANCE = new NullAppender();
+
+ /**
+ * Whenever you can, use this method to retreive an instance instead of instantiating a new one with <code>new</code>.
+ */
+ public static NullAppender getNullAppender() {
+ return INSTANCE;
+ }
+
+ public NullAppender() {
+ // noop
+ }
+
+ /**
+ * There are no options to acticate.
+ */
+ @Override
+ public void activateOptions() {
+ // noop
+ }
+
+ /**
+ * Does not do anything.
+ */
+ @Override
+ protected void append(final LoggingEvent event) {
+ // noop
+ }
+
+ @Override
+ public void close() {
+ // noop
+ }
+
+ /**
+ * Does not do anything.
+ */
+ @Override
+ public void doAppend(final LoggingEvent event) {
+ // noop
+ }
+
+ /**
+ * Whenever you can, use this method to retreive an instance instead of instantiating a new one with <code>new</code>.
+ *
+ * @deprecated Use getNullAppender instead. getInstance should have been static.
+ */
+ @Deprecated
+ public NullAppender getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * NullAppenders do not need a layout.
+ */
+ @Override
+ public boolean requiresLayout() {
+ return false;
+ }
+}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java
new file mode 100644
index 0000000..a59d92c
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package org.apache.log4j.varia;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.spi.Configurator;
+import org.apache.log4j.spi.LoggerRepository;
+
+public class ReloadingPropertyConfigurator implements Configurator {
+
+ PropertyConfigurator delegate = new PropertyConfigurator();
+
+ public ReloadingPropertyConfigurator() {
+ }
+
+ /**
+ * @since 1.2.17
+ */
+ @Override
+ public void doConfigure(final InputStream inputStream, final LoggerRepository repository) {
+ // noop
+ }
+
+ @Override
+ public void doConfigure(final URL url, final LoggerRepository repository) {
+ // noop
+ }
+
+}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/StringMatchFilter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/StringMatchFilter.java
new file mode 100644
index 0000000..c84dbce
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/StringMatchFilter.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.log4j.varia;
+
+import org.apache.log4j.helpers.OptionConverter;
+import org.apache.log4j.spi.Filter;
+import org.apache.log4j.spi.LoggingEvent;
+
+/**
+ * Simple filter based on string matching.
+ *
+ * <p>
+ * The filter admits two options <b>StringToMatch</b> and <b>AcceptOnMatch</b>. If there is a match between the value of
+ * the StringToMatch option and the message of the {@link org.apache.log4j.spi.LoggingEvent}, then the
+ * {@link #decide(LoggingEvent)} method returns {@link org.apache.log4j.spi.Filter#ACCEPT} if the <b>AcceptOnMatch</b>
+ * option value is true, if it is false then {@link org.apache.log4j.spi.Filter#DENY} is returned. If there is no match,
+ * {@link org.apache.log4j.spi.Filter#NEUTRAL} is returned.
+ * </p>
+ *
+ * @since 0.9.0
+ */
+public class StringMatchFilter extends Filter {
+
+ /**
+ * @deprecated Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be
+ * removed in the <em>near</em> term.
+ */
+ @Deprecated
+ public static final String STRING_TO_MATCH_OPTION = "StringToMatch";
+
+ /**
+ * @deprecated Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be
+ * removed in the <em>near</em> term.
+ */
+ @Deprecated
+ public static final String ACCEPT_ON_MATCH_OPTION = "AcceptOnMatch";
+
+ boolean acceptOnMatch = true;
+ String stringToMatch;
+
+ /**
+ * Returns {@link Filter#NEUTRAL} is there is no string match.
+ */
+ @Override
+ public int decide(final LoggingEvent event) {
+ final String msg = event.getRenderedMessage();
+ if (msg == null || stringToMatch == null) {
+ return Filter.NEUTRAL;
+ }
+ if (msg.indexOf(stringToMatch) == -1) {
+ return Filter.NEUTRAL;
+ }
+ return acceptOnMatch ? Filter.ACCEPT : Filter.DENY;
+ }
+
+ public boolean getAcceptOnMatch() {
+ return acceptOnMatch;
+ }
+
+ /**
+ * @deprecated We now use JavaBeans introspection to configure components. Options strings are no longer needed.
+ */
+ @Deprecated
+ public String[] getOptionStrings() {
+ return new String[] {STRING_TO_MATCH_OPTION, ACCEPT_ON_MATCH_OPTION};
+ }
+
+ public String getStringToMatch() {
+ return stringToMatch;
+ }
+
+ public void setAcceptOnMatch(final boolean acceptOnMatch) {
+ this.acceptOnMatch = acceptOnMatch;
+ }
+
+ /**
+ * @deprecated Use the setter method for the option directly instead of the generic <code>setOption</code> method.
+ */
+ @Deprecated
+ public void setOption(final String key, final String value) {
+ if (key.equalsIgnoreCase(STRING_TO_MATCH_OPTION)) {
+ stringToMatch = value;
+ } else if (key.equalsIgnoreCase(ACCEPT_ON_MATCH_OPTION)) {
+ acceptOnMatch = OptionConverter.toBoolean(value, acceptOnMatch);
+ }
+ }
+
+ public void setStringToMatch(final String s) {
+ stringToMatch = s;
+ }
+}