[
https://jira.jboss.org/jira/browse/JBSPRING-3?page=com.atlassian.jira.plu...
]
Luca Stancapiano updated JBSPRING-3:
------------------------------------
Description:
I'm triing spring deployer inside jboss 5.1.0.CR1 and JBoss 6.x from trunk. My
application is something as:
prova.spring
it
example
example1-context.xml
Example1.class
ext
example2-context.xml
Example2.class
META-INF
jboss-spring.xml
jboss-spring.xml is so:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN'
'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<import resource="classpath:it/example/example1-context.xml" />
<import resource="classpath*:it/example/ext/*-context.xml" />
</beans>
the first context is loaded correctly (example1-context.xml). The second context
(*-context.xml) is not loaded. I've seen inside the code and now I have many doubts on
org.springframework.util.AntPathMatcher class inside JBoss. This class compares a path
through a pattern. In our case we have:
pattern: *-context.xml
path: prova.spring/it/example/ext/example2-context.xml
theese values are wrong using AntPathMatcher class. AntPathMatcher need the same urls to
compare. Theese values should to be something as:
pattern: prova.spring/it/example/ext/*-context.xml
path: prova.spring/it/example/ext/example2-context.xml
or
pattern: *-context.xml
path: example2-context.xml
else it returns always false.
Because it seems impossible to create the whole URL for path and pattern, I wrote a
VFSPathMatcher rewriting the AntPathMatcher. This matcher takes theese two values and
modify path value working only with the last context. I suppose we don't need to
compare all subcontexts because they are controlled by the classloader. Using
VFSPathMatcher we will get always:
pattern: *-context.xml
path: example2-context.xml
Here there is the new class:
/*
* JBoss, Home of Professional Open Source.
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
package org.jboss.spring.io;
import org.springframework.util.AntPathMatcher;
/**
* PathMatcher implementation for Ant-style path patterns. Examples are provided
* below. It rewrites the parent class AntPathMatcher. It manages only one context
* instead of AntPathMatcher that compares all subcontext in path and pattern
*
* <p>
* Part of this mapping code has been kindly borrowed from <a
* href="http://ant.apache.org">Apache Ant</a>.
*
* <p>
* The mapping matches URLs using the following rules:<br>
* <ul>
* <li>? matches one character</li>
* <li>* matches zero or more characters</li>
* <li>** matches zero or more 'directories' in a path</li>
* </ul>
*
* <p>
* Some examples:<br>
* <ul>
* <li><code>/t?st.jsp</code> - matches
<code>/test.jsp</code> but also
* <code>/tast.jsp</code> or <code>/txst.jsp</code></li>
* <li><code>/*.jsp</code> - matches all <code>.jsp</code>
files in the
* <code>/</code> directory</li>
* <li><code>/test.jsp</code> - matches all
<code>test.jsp</code>
* files underneath the <code>/</code> path</li>
* <li><code>org/springframework/**/*.jsp</code> -
matches all
* <code>.jsp</code> files underneath the
<code>org/springframework</code> path</li>
* </ul>
*
* @author Luca Stancapiano
* @since 03.05.2009
*/
public class VFSPathMatcher extends AntPathMatcher {
private String pathSeparator = DEFAULT_PATH_SEPARATOR;
/**
* Actually match the given <code>path</code> against the given
* <code>pattern</code>.
*
* @param pattern
* the pattern to match against
* @param path
* the path String to test
* @param fullMatch
* whether a full pattern match is required (else a pattern match
* as far as the given base path goes is sufficient)
* @return <code>true</code> if the supplied <code>path</code>
matched,
* <code>false</code> if it didn't
*/
protected boolean doMatch(String pattern, String path, boolean fullMatch) {
if (path.startsWith(this.pathSeparator) != pattern
.startsWith(this.pathSeparator)) {
return false;
}
String pathDir = path.substring(path.lastIndexOf("/"));
// Match all elements up to the first **
if ("**".equals(pattern)) {
return true;
}
if (!matchStrings(pattern, pathDir)) {
return false;
}
return true;
}
/**
* Tests whether or not a string matches against a pattern. The pattern may
* contain two special characters:<br>
* '*' means zero or more characters<br>
* '?' means one and only one character
*
* @param pattern
* pattern to match against. Must not be <code>null</code>.
* @param str
* string which must be matched against the pattern. Must not be
* <code>null</code>.
* @return <code>true</code> if the string matches against the pattern, or
* <code>false</code> otherwise.
*/
private boolean matchStrings(String pattern, String str) {
char[] patArr = pattern.toCharArray();
char[] strArr = str.toCharArray();
int patIdxStart = 0;
int patIdxEnd = patArr.length - 1;
int strIdxStart = 0;
int strIdxEnd = strArr.length - 1;
char ch;
boolean containsStar = false;
for (int i = 0; i < patArr.length; i++) {
if (patArr[i] == '*') {
containsStar = true;
break;
}
}
if (!containsStar) {
// No '*'s, so we make a shortcut
if (patIdxEnd != strIdxEnd) {
return false; // Pattern and string do not have the same size
}
for (int i = 0; i <= patIdxEnd; i++) {
ch = patArr[i];
if (ch != '?') {
if (ch != strArr[i]) {
return false;// Character mismatch
}
}
}
return true; // String matches against pattern
}
if (patIdxEnd == 0) {
return true; // Pattern contains only '*', which matches anything
}
// Process characters before first star
while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd)
{
if (ch != '?') {
if (ch != strArr[strIdxStart]) {
return false;// Character mismatch
}
}
patIdxStart++;
strIdxStart++;
}
if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
// Process characters after last star
while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd)
{
if (ch != '?') {
if (ch != strArr[strIdxEnd]) {
return false;// Character mismatch
}
}
patIdxEnd--;
strIdxEnd--;
}
if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
// process pattern between stars. padIdxStart and patIdxEnd point
// always to a '*'.
while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
int patIdxTmp = -1;
for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
if (patArr[i] == '*') {
patIdxTmp = i;
break;
}
}
if (patIdxTmp == patIdxStart + 1) {
// Two stars next to each other, skip the first one.
patIdxStart++;
continue;
}
// Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd
int patLength = (patIdxTmp - patIdxStart - 1);
int strLength = (strIdxEnd - strIdxStart + 1);
int foundIdx = -1;
strLoop: for (int i = 0; i <= strLength - patLength; i++) {
for (int j = 0; j < patLength; j++) {
ch = patArr[patIdxStart + j + 1];
if (ch != '?') {
if (ch != strArr[strIdxStart + i + j]) {
continue strLoop;
}
}
}
foundIdx = strIdxStart + i;
break;
}
if (foundIdx == -1) {
return false;
}
patIdxStart = patIdxTmp;
strIdxStart = foundIdx + patLength;
}
// All characters in the string are used. Check if only '*'s are left
// in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
}
This class is called through the constructors of
org.jboss.spring.io.VFSResourcePatternResolver class:
public VFSResourcePatternResolver()
{
super(new VFSResourceLoader());
setPathMatcher(new VFSPathMatcher());
}
public VFSResourcePatternResolver(ClassLoader classLoader)
{
super(new VFSResourceLoader(classLoader));
setPathMatcher(new VFSPathMatcher());
}
was:
I'm triing spring deployer inside jboss 5.1.0.CR1 and JBoss 6.x from trunk. My
application is something as:
prova.spring
it
example
example1-context.xml
Example1.class
ext
example2-context.xml
Example2.class
META-INF
jboss-spring.xml
jboss-spring.xml is so:
[code]<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN'
'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<import resource="classpath:it/example/example1-context.xml" />
<import resource="classpath*:it/example/ext/*-context.xml" />
</beans>[/code]
the first context is loaded correctly (example1-context.xml). The second context
(*-context.xml) is not loaded. I've seen inside the code and now I have many doubts on
org.springframework.util.AntPathMatcher class inside JBoss. This class compares a path
through a pattern. In our case we have:
pattern: *-context.xml
path: prova.spring/it/example/ext/example2-context.xml
theese values are wrong using AntPathMatcher class. AntPathMatcher need the same urls to
compare. Theese values should to be something as:
pattern: prova.spring/it/example/ext/*-context.xml
path: prova.spring/it/example/ext/example2-context.xml
or
pattern: *-context.xml
path: example2-context.xml
else it returns always false.
Because it seems impossible to create the whole URL for path and pattern, I wrote a
VFSPathMatcher rewriting the AntPathMatcher. This matcher takes theese two values and
modify path value working only with the last context. I suppose we don't need to
compare all subcontexts because they are controlled by the classloader. Using
VFSPathMatcher we will get always:
pattern: *-context.xml
path: example2-context.xml
Here there is the new class:
/*
* JBoss, Home of Professional Open Source.
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
package org.jboss.spring.io;
import org.springframework.util.AntPathMatcher;
/**
* PathMatcher implementation for Ant-style path patterns. Examples are provided
* below. It rewrites the parent class AntPathMatcher. It manages only one context
* instead of AntPathMatcher that compares all subcontext in path and pattern
*
* <p>
* Part of this mapping code has been kindly borrowed from <a
* href="http://ant.apache.org">Apache Ant</a>.
*
* <p>
* The mapping matches URLs using the following rules:<br>
* <ul>
* <li>? matches one character</li>
* <li>* matches zero or more characters</li>
* <li>** matches zero or more 'directories' in a path</li>
* </ul>
*
* <p>
* Some examples:<br>
* <ul>
* <li><code>/t?st.jsp</code> - matches
<code>/test.jsp</code> but also
* <code>/tast.jsp</code> or <code>/txst.jsp</code></li>
* <li><code>/*.jsp</code> - matches all <code>.jsp</code>
files in the
* <code>/</code> directory</li>
* <li><code>/test.jsp</code> - matches all
<code>test.jsp</code>
* files underneath the <code>/</code> path</li>
* <li><code>org/springframework/**/*.jsp</code> -
matches all
* <code>.jsp</code> files underneath the
<code>org/springframework</code> path</li>
* </ul>
*
* @author Luca Stancapiano
* @since 03.05.2009
*/
public class VFSPathMatcher extends AntPathMatcher {
private String pathSeparator = DEFAULT_PATH_SEPARATOR;
/**
* Actually match the given <code>path</code> against the given
* <code>pattern</code>.
*
* @param pattern
* the pattern to match against
* @param path
* the path String to test
* @param fullMatch
* whether a full pattern match is required (else a pattern match
* as far as the given base path goes is sufficient)
* @return <code>true</code> if the supplied <code>path</code>
matched,
* <code>false</code> if it didn't
*/
protected boolean doMatch(String pattern, String path, boolean fullMatch) {
if (path.startsWith(this.pathSeparator) != pattern
.startsWith(this.pathSeparator)) {
return false;
}
String pathDir = path.substring(path.lastIndexOf("/"));
// Match all elements up to the first **
if ("**".equals(pattern)) {
return true;
}
if (!matchStrings(pattern, pathDir)) {
return false;
}
return true;
}
/**
* Tests whether or not a string matches against a pattern. The pattern may
* contain two special characters:<br>
* '*' means zero or more characters<br>
* '?' means one and only one character
*
* @param pattern
* pattern to match against. Must not be <code>null</code>.
* @param str
* string which must be matched against the pattern. Must not be
* <code>null</code>.
* @return <code>true</code> if the string matches against the pattern, or
* <code>false</code> otherwise.
*/
private boolean matchStrings(String pattern, String str) {
char[] patArr = pattern.toCharArray();
char[] strArr = str.toCharArray();
int patIdxStart = 0;
int patIdxEnd = patArr.length - 1;
int strIdxStart = 0;
int strIdxEnd = strArr.length - 1;
char ch;
boolean containsStar = false;
for (int i = 0; i < patArr.length; i++) {
if (patArr[i] == '*') {
containsStar = true;
break;
}
}
if (!containsStar) {
// No '*'s, so we make a shortcut
if (patIdxEnd != strIdxEnd) {
return false; // Pattern and string do not have the same size
}
for (int i = 0; i <= patIdxEnd; i++) {
ch = patArr[i];
if (ch != '?') {
if (ch != strArr[i]) {
return false;// Character mismatch
}
}
}
return true; // String matches against pattern
}
if (patIdxEnd == 0) {
return true; // Pattern contains only '*', which matches anything
}
// Process characters before first star
while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd)
{
if (ch != '?') {
if (ch != strArr[strIdxStart]) {
return false;// Character mismatch
}
}
patIdxStart++;
strIdxStart++;
}
if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
// Process characters after last star
while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd)
{
if (ch != '?') {
if (ch != strArr[strIdxEnd]) {
return false;// Character mismatch
}
}
patIdxEnd--;
strIdxEnd--;
}
if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
// process pattern between stars. padIdxStart and patIdxEnd point
// always to a '*'.
while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
int patIdxTmp = -1;
for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
if (patArr[i] == '*') {
patIdxTmp = i;
break;
}
}
if (patIdxTmp == patIdxStart + 1) {
// Two stars next to each other, skip the first one.
patIdxStart++;
continue;
}
// Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd
int patLength = (patIdxTmp - patIdxStart - 1);
int strLength = (strIdxEnd - strIdxStart + 1);
int foundIdx = -1;
strLoop: for (int i = 0; i <= strLength - patLength; i++) {
for (int j = 0; j < patLength; j++) {
ch = patArr[patIdxStart + j + 1];
if (ch != '?') {
if (ch != strArr[strIdxStart + i + j]) {
continue strLoop;
}
}
}
foundIdx = strIdxStart + i;
break;
}
if (foundIdx == -1) {
return false;
}
patIdxStart = patIdxTmp;
strIdxStart = foundIdx + patLength;
}
// All characters in the string are used. Check if only '*'s are left
// in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
}
This class is called through the constructors of
org.jboss.spring.io.VFSResourcePatternResolver class:
public VFSResourcePatternResolver()
{
super(new VFSResourceLoader());
setPathMatcher(new VFSPathMatcher());
}
public VFSResourcePatternResolver(ClassLoader classLoader)
{
super(new VFSResourceLoader(classLoader));
setPathMatcher(new VFSPathMatcher());
}
Resources are not well loaded
-----------------------------
Key: JBSPRING-3
URL:
https://jira.jboss.org/jira/browse/JBSPRING-3
Project: JBoss Spring Integration
Issue Type: Bug
Components: VFS
Environment: JBoss 5.1.0.CR1, JBoss 6.x from trunk
Reporter: Luca Stancapiano
Assignee: Marius Bogoevici
I'm triing spring deployer inside jboss 5.1.0.CR1 and JBoss 6.x from trunk. My
application is something as:
prova.spring
it
example
example1-context.xml
Example1.class
ext
example2-context.xml
Example2.class
META-INF
jboss-spring.xml
jboss-spring.xml is so:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN'
'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<import resource="classpath:it/example/example1-context.xml" />
<import resource="classpath*:it/example/ext/*-context.xml" />
</beans>
the first context is loaded correctly (example1-context.xml). The second context
(*-context.xml) is not loaded. I've seen inside the code and now I have many doubts on
org.springframework.util.AntPathMatcher class inside JBoss. This class compares a path
through a pattern. In our case we have:
pattern: *-context.xml
path: prova.spring/it/example/ext/example2-context.xml
theese values are wrong using AntPathMatcher class. AntPathMatcher need the same urls to
compare. Theese values should to be something as:
pattern: prova.spring/it/example/ext/*-context.xml
path: prova.spring/it/example/ext/example2-context.xml
or
pattern: *-context.xml
path: example2-context.xml
else it returns always false.
Because it seems impossible to create the whole URL for path and pattern, I wrote a
VFSPathMatcher rewriting the AntPathMatcher. This matcher takes theese two values and
modify path value working only with the last context. I suppose we don't need to
compare all subcontexts because they are controlled by the classloader. Using
VFSPathMatcher we will get always:
pattern: *-context.xml
path: example2-context.xml
Here there is the new class:
/*
* JBoss, Home of Professional Open Source.
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*/
package org.jboss.spring.io;
import org.springframework.util.AntPathMatcher;
/**
* PathMatcher implementation for Ant-style path patterns. Examples are provided
* below. It rewrites the parent class AntPathMatcher. It manages only one context
* instead of AntPathMatcher that compares all subcontext in path and pattern
*
* <p>
* Part of this mapping code has been kindly borrowed from <a
* href="http://ant.apache.org">Apache Ant</a>.
*
* <p>
* The mapping matches URLs using the following rules:<br>
* <ul>
* <li>? matches one character</li>
* <li>* matches zero or more characters</li>
* <li>** matches zero or more 'directories' in a path</li>
* </ul>
*
* <p>
* Some examples:<br>
* <ul>
* <li><code>/t?st.jsp</code> - matches
<code>/test.jsp</code> but also
* <code>/tast.jsp</code> or <code>/txst.jsp</code></li>
* <li><code>/*.jsp</code> - matches all <code>.jsp</code>
files in the
* <code>/</code> directory</li>
* <li><code>/test.jsp</code> - matches all
<code>test.jsp</code>
* files underneath the <code>/</code> path</li>
* <li><code>org/springframework/**/*.jsp</code> -
matches all
* <code>.jsp</code> files underneath the
<code>org/springframework</code> path</li>
* </ul>
*
* @author Luca Stancapiano
* @since 03.05.2009
*/
public class VFSPathMatcher extends AntPathMatcher {
private String pathSeparator = DEFAULT_PATH_SEPARATOR;
/**
* Actually match the given <code>path</code> against the given
* <code>pattern</code>.
*
* @param pattern
* the pattern to match against
* @param path
* the path String to test
* @param fullMatch
* whether a full pattern match is required (else a pattern match
* as far as the given base path goes is sufficient)
* @return <code>true</code> if the supplied <code>path</code>
matched,
* <code>false</code> if it didn't
*/
protected boolean doMatch(String pattern, String path, boolean fullMatch) {
if (path.startsWith(this.pathSeparator) != pattern
.startsWith(this.pathSeparator)) {
return false;
}
String pathDir = path.substring(path.lastIndexOf("/"));
// Match all elements up to the first **
if ("**".equals(pattern)) {
return true;
}
if (!matchStrings(pattern, pathDir)) {
return false;
}
return true;
}
/**
* Tests whether or not a string matches against a pattern. The pattern may
* contain two special characters:<br>
* '*' means zero or more characters<br>
* '?' means one and only one character
*
* @param pattern
* pattern to match against. Must not be <code>null</code>.
* @param str
* string which must be matched against the pattern. Must not be
* <code>null</code>.
* @return <code>true</code> if the string matches against the pattern, or
* <code>false</code> otherwise.
*/
private boolean matchStrings(String pattern, String str) {
char[] patArr = pattern.toCharArray();
char[] strArr = str.toCharArray();
int patIdxStart = 0;
int patIdxEnd = patArr.length - 1;
int strIdxStart = 0;
int strIdxEnd = strArr.length - 1;
char ch;
boolean containsStar = false;
for (int i = 0; i < patArr.length; i++) {
if (patArr[i] == '*') {
containsStar = true;
break;
}
}
if (!containsStar) {
// No '*'s, so we make a shortcut
if (patIdxEnd != strIdxEnd) {
return false; // Pattern and string do not have the same size
}
for (int i = 0; i <= patIdxEnd; i++) {
ch = patArr[i];
if (ch != '?') {
if (ch != strArr[i]) {
return false;// Character mismatch
}
}
}
return true; // String matches against pattern
}
if (patIdxEnd == 0) {
return true; // Pattern contains only '*', which matches anything
}
// Process characters before first star
while ((ch = patArr[patIdxStart]) != '*' && strIdxStart <=
strIdxEnd) {
if (ch != '?') {
if (ch != strArr[strIdxStart]) {
return false;// Character mismatch
}
}
patIdxStart++;
strIdxStart++;
}
if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
// Process characters after last star
while ((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd)
{
if (ch != '?') {
if (ch != strArr[strIdxEnd]) {
return false;// Character mismatch
}
}
patIdxEnd--;
strIdxEnd--;
}
if (strIdxStart > strIdxEnd) {
// All characters in the string are used. Check if only '*'s are
// left in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
// process pattern between stars. padIdxStart and patIdxEnd point
// always to a '*'.
while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
int patIdxTmp = -1;
for (int i = patIdxStart + 1; i <= patIdxEnd; i++) {
if (patArr[i] == '*') {
patIdxTmp = i;
break;
}
}
if (patIdxTmp == patIdxStart + 1) {
// Two stars next to each other, skip the first one.
patIdxStart++;
continue;
}
// Find the pattern between padIdxStart & padIdxTmp in str between
// strIdxStart & strIdxEnd
int patLength = (patIdxTmp - patIdxStart - 1);
int strLength = (strIdxEnd - strIdxStart + 1);
int foundIdx = -1;
strLoop: for (int i = 0; i <= strLength - patLength; i++) {
for (int j = 0; j < patLength; j++) {
ch = patArr[patIdxStart + j + 1];
if (ch != '?') {
if (ch != strArr[strIdxStart + i + j]) {
continue strLoop;
}
}
}
foundIdx = strIdxStart + i;
break;
}
if (foundIdx == -1) {
return false;
}
patIdxStart = patIdxTmp;
strIdxStart = foundIdx + patLength;
}
// All characters in the string are used. Check if only '*'s are left
// in the pattern. If so, we succeeded. Otherwise failure.
for (int i = patIdxStart; i <= patIdxEnd; i++) {
if (patArr[i] != '*') {
return false;
}
}
return true;
}
}
This class is called through the constructors of
org.jboss.spring.io.VFSResourcePatternResolver class:
public VFSResourcePatternResolver()
{
super(new VFSResourceLoader());
setPathMatcher(new VFSPathMatcher());
}
public VFSResourcePatternResolver(ClassLoader classLoader)
{
super(new VFSResourceLoader(classLoader));
setPathMatcher(new VFSPathMatcher());
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira