You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2004/06/12 07:18:20 UTC
cvs commit: logging-log4j/src/java/org/apache/log4j/rule RuleFactory.java
sdeboy 2004/06/11 22:18:20
Modified: src/java/org/apache/log4j/rule RuleFactory.java
Log:
rule factory now behaves as if the 'like' (regular expression) rule doesn't exist if the Perl5Compiler ORO class is not available.
Revision Changes Path
1.4 +13 -3 logging-log4j/src/java/org/apache/log4j/rule/RuleFactory.java
Index: RuleFactory.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/rule/RuleFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RuleFactory.java 27 Feb 2004 16:47:34 -0000 1.3
+++ RuleFactory.java 12 Jun 2004 05:18:20 -0000 1.4
@@ -20,9 +20,12 @@
import java.util.LinkedList;
import java.util.Stack;
+import org.apache.log4j.helpers.LogLog;
+
/**
* A Factory class which, given a string representation of the rule, and a context stack, will
- * return a Rule ready for evaluation against events.
+ * return a Rule ready for evaluation against events. If an operator is requested that isn't supported,
+ * or if a LIKE rule is requested and the ORO package is not available, an IllegalArgumentException is thrown.
*
* @author Scott Deboy <sd...@apache.org>
*/
@@ -41,6 +44,7 @@
private static final String GREATER_THAN_RULE = ">";
private static final String LESS_THAN_EQUALS_RULE = "<=";
private static final String GREATER_THAN_EQUALS_RULE = ">=";
+
static {
rules.add(AND_RULE);
rules.add(OR_RULE);
@@ -48,7 +52,13 @@
rules.add(NOT_EQUALS_RULE);
rules.add(EQUALS_RULE);
rules.add(PARTIAL_TEXT_MATCH_RULE);
- rules.add(LIKE_RULE);
+ try {
+ Class.forName("org.apache.oro.text.regex.Perl5Compiler");
+ rules.add(LIKE_RULE);
+ } catch (Exception e) {
+ LogLog.info("ORO classes not found - Like rule not supported");
+ }
+
rules.add(EXISTS_RULE);
rules.add(LESS_THAN_RULE);
rules.add(GREATER_THAN_RULE);
@@ -91,7 +101,7 @@
return PartialTextMatchRule.getRule(stack);
}
- if (LIKE_RULE.equalsIgnoreCase(symbol)) {
+ if (rules.contains(LIKE_RULE) && LIKE_RULE.equalsIgnoreCase(symbol)) {
return LikeRule.getRule(stack);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org