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 ca...@apache.org on 2007/08/16 08:56:24 UTC
svn commit: r566511 - in
/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j:
rule/RuleFactory.java spi/LoggingEventFieldResolver.java
Author: carnold
Date: Wed Aug 15 23:56:21 2007
New Revision: 566511
URL: http://svn.apache.org/viewvc?view=rev&rev=566511
Log:
Bug 42102: Replace reflection with direct access to LikeRule
Modified:
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/RuleFactory.java
logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/RuleFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/RuleFactory.java?view=diff&rev=566511&r1=566510&r2=566511
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/RuleFactory.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/RuleFactory.java Wed Aug 15 23:56:21 2007
@@ -98,14 +98,7 @@
RULES.add(NOT_EQUALS_RULE);
RULES.add(EQUALS_RULE);
RULES.add(PARTIAL_TEXT_MATCH_RULE);
- try {
- Class.forName("org.apache.log4j.rule.LikeRule");
- RULES.add(LIKE_RULE);
- } catch (Exception e) {
- LogManager.getLogger(RuleFactory.class).info(
- "Like (regular expression) rule not supported");
- }
-
+ RULES.add(LIKE_RULE);
RULES.add(EXISTS_RULE);
RULES.add(LESS_THAN_RULE);
RULES.add(GREATER_THAN_RULE);
@@ -168,25 +161,8 @@
return PartialTextMatchRule.getRule(stack);
}
- //in order to avoid compile-time dependency on LikeRule,
- // call getRule(stack) using reflection
if (RULES.contains(LIKE_RULE) && LIKE_RULE.equalsIgnoreCase(symbol)) {
- String methodName = "getRule";
- try {
- Class likeClass = Class.forName("org.apache.log4j.rule.LikeRule");
- Method method =
- likeClass.getDeclaredMethod(methodName, new Class[]{Stack.class});
-
- return (Rule) method.invoke(null, new Object[]{stack});
- } catch (ClassNotFoundException cnfe) {
- throw new IllegalArgumentException("Invalid rule: " + symbol);
- } catch (NoSuchMethodException nsme) {
- throw new IllegalArgumentException("Invalid rule: " + symbol);
- } catch (IllegalAccessException iae) {
- throw new IllegalArgumentException("Invalid rule: " + symbol);
- } catch (InvocationTargetException iae) {
- throw new IllegalArgumentException("Invalid rule: " + symbol);
- }
+ return LikeRule.getRule(stack);
}
if (EXISTS_RULE.equalsIgnoreCase(symbol)) {
Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java?view=diff&rev=566511&r1=566510&r2=566511
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/spi/LoggingEventFieldResolver.java Wed Aug 15 23:56:21 2007
@@ -25,8 +25,7 @@
/**
* A singleton helper utility which accepts a field name
- * and a LoggingEvent and returns the
- * String value of that field.
+ * and a LoggingEvent and returns the value of that field.
*
* This class defines a grammar used in creation of an expression-based Rule.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org