diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java b/org.springframework.aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java index 66fb98dc60..2af676bf9d 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/support/AbstractRegexpMethodPointcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo /** Regular expressions to match */ private String[] patterns = new String[0]; - /** Regaular expressions not to match */ + /** Regular expressions not to match */ private String[] excludedPatterns = new String[0]; @@ -155,14 +155,22 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo /** * Subclasses must implement this to initialize regexp pointcuts. * Can be invoked multiple times. - *
This method will be invoked from the setPatterns method, + *
This method will be invoked from the {@link #setPatterns} method, * and also on deserialization. * @param patterns the patterns to initialize * @throws IllegalArgumentException in case of an invalid pattern */ protected abstract void initPatternRepresentation(String[] patterns) throws IllegalArgumentException; - protected abstract void initExcludedPatternRepresentation(String[] excludedPatterns) throws IllegalArgumentException; + /** + * Subclasses must implement this to initialize regexp pointcuts. + * Can be invoked multiple times. + *
This method will be invoked from the {@link #setExcludedPatterns} method,
+ * and also on deserialization.
+ * @param patterns the patterns to initialize
+ * @throws IllegalArgumentException in case of an invalid pattern
+ */
+ protected abstract void initExcludedPatternRepresentation(String[] patterns) throws IllegalArgumentException;
/**
* Does the pattern at the given index match this string?
@@ -197,12 +205,10 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
@Override
public int hashCode() {
int result = 27;
- for (int i = 0; i < this.patterns.length; i++) {
- String pattern = this.patterns[i];
+ for (String pattern : this.patterns) {
result = 13 * result + pattern.hashCode();
}
- for (int i = 0; i < this.excludedPatterns.length; i++) {
- String excludedPattern = this.excludedPatterns[i];
+ for (String excludedPattern : this.excludedPatterns) {
result = 13 * result + excludedPattern.hashCode();
}
return result;
@@ -214,18 +220,4 @@ public abstract class AbstractRegexpMethodPointcut extends StaticMethodMatcherPo
", excluded patterns " + ObjectUtils.nullSafeToString(this.excludedPatterns);
}
-
- //---------------------------------------------------------------------
- // Serialization support
- //---------------------------------------------------------------------
-
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- // Rely on default serialization; just initialize state after deserialization.
- ois.defaultReadObject();
-
- // Ask subclass to reinitialize.
- initPatternRepresentation(this.patterns);
- initExcludedPatternRepresentation(this.excludedPatterns);
- }
-
}
diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/support/JdkRegexpMethodPointcut.java b/org.springframework.aop/src/main/java/org/springframework/aop/support/JdkRegexpMethodPointcut.java
index 66339a9f00..d2a4fe1395 100644
--- a/org.springframework.aop/src/main/java/org/springframework/aop/support/JdkRegexpMethodPointcut.java
+++ b/org.springframework.aop/src/main/java/org/springframework/aop/support/JdkRegexpMethodPointcut.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 the original author or authors.
+ * Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,12 +42,12 @@ public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut {
/**
* Compiled form of the patterns.
*/
- private transient Pattern[] compiledPatterns = new Pattern[0];
+ private Pattern[] compiledPatterns = new Pattern[0];
/**
* Compiled form of the exclusion patterns.
*/
- private transient Pattern[] compiledExclusionPatterns = new Pattern[0];
+ private Pattern[] compiledExclusionPatterns = new Pattern[0];
/**
@@ -59,21 +59,21 @@ public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut {
}
/**
- * Returns true
if the {@link Pattern} at index patternIndex
- * matches the supplied candidate String
.
+ * Initialize exclusion {@link Pattern Patterns} from the supplied String[]
.
*/
@Override
- protected boolean matches(String pattern, int patternIndex) {
- Matcher matcher = this.compiledPatterns[patternIndex].matcher(pattern);
- return matcher.matches();
+ protected void initExcludedPatternRepresentation(String[] excludedPatterns) throws PatternSyntaxException {
+ this.compiledExclusionPatterns = compilePatterns(excludedPatterns);
}
/**
- * Initialize exclusion {@link Pattern Patterns} from the supplied String[]
.
+ * Returns true
if the {@link Pattern} at index patternIndex
+ * matches the supplied candidate String
.
*/
@Override
- protected void initExcludedPatternRepresentation(String[] excludedPatterns) throws IllegalArgumentException {
- this.compiledExclusionPatterns = compilePatterns(excludedPatterns);
+ protected boolean matches(String pattern, int patternIndex) {
+ Matcher matcher = this.compiledPatterns[patternIndex].matcher(pattern);
+ return matcher.matches();
}
/**
@@ -86,11 +86,12 @@ public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut {
return matcher.matches();
}
+
/**
* Compiles the supplied String[]
into an array of
* {@link Pattern} objects and returns that array.
*/
- private Pattern[] compilePatterns(String[] source) {
+ private Pattern[] compilePatterns(String[] source) throws PatternSyntaxException {
Pattern[] destination = new Pattern[source.length];
for (int i = 0; i < source.length; i++) {
destination[i] = Pattern.compile(source[i]);