Author: heiko.braun(a)jboss.com
Date: 2007-10-29 13:03:50 -0400 (Mon, 29 Oct 2007)
New Revision: 4925
Added:
stack/native/branches/rest/rest.iml
Modified:
stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.java
stack/native/branches/rest/src/main/java/org/jboss/rs/model/RegexQualifier.java
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceResolver.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResolverTestCase.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/RunRegex.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Specification.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Widget.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/WidgetList.java
Log:
Improved resource resolver algorithm
Added: stack/native/branches/rest/rest.iml
===================================================================
--- stack/native/branches/rest/rest.iml (rev 0)
+++ stack/native/branches/rest/rest.iml 2007-10-29 17:03:50 UTC (rev 4925)
@@ -0,0 +1,655 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true"
type="JAVA_MODULE">
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager"
inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java"
isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test-framework/java"
isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java"
isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/xmlunit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-vfs.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jboss-xml-binding-sources.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/stax-ex.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/serializer.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/wstx.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-dependency.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/ant.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-remoting.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbossws-common.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/commons-collections.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/streambuffer.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jbossws-jboss42-resources.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jboss-common-core-sources.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-javaee.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-vfs-sources.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jboss-logging-log4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbosssx.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/xml-apis.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/resolver.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-deployers.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jsr311-api.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jaxb-impl.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/commons-logging.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-logging-spi.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-remoting-src.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/mail.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbossws-jboss421.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jbossws-jboss40-src.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/xmlsec.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbossws-common-src.zip!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbossws-spi-src.zip!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/stax-api.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/servlet-api.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbossws-framework.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jaxen.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-jaxb-intros.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/hibernate3.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/javassist.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/xalan.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbosssx-client.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/qdox.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jaxb-api.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/getopt.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jbossws-jboss40-resources.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-j2ee.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbossws-jboss40.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jboss-dependency-src.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jaxb-xjc.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/activation.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-container.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jaxws-rt.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbosssx-src.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-xml-binding.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jaxws-tools.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/concurrent.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jbossws-framework-src.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/xercesImpl.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jboss-deployers-src.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jbossws-jboss421-src.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/log4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss-common-core.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jbossws-spi.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/wsdl4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/wsdl4j-src.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/policy.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jboss-microcontainer-src.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/dom4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jbossws-framework-scripts.zip!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/thirdparty/jboss-microcontainer.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntryProperties />
+ </component>
+</module>
+
Modified:
stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.java
===================================================================
---
stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.java 2007-10-29
16:54:19 UTC (rev 4924)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.java 2007-10-29
17:03:50 UTC (rev 4925)
@@ -84,7 +84,7 @@
RegexQualifier qualifier = null;
Matcher matcher = regexPattern.matcher(input);
- if(! matcher.find() )
+ if(! matcher.matches() )
return qualifier;
String lastGroup = matcher.group( matcher.groupCount() );
@@ -98,7 +98,7 @@
}
qualifier = new RegexQualifier(
- matcher.groupCount(),
+ getMatchingGroups(matcher),
regexPattern.pattern().length(),
lastGroup
);
@@ -106,6 +106,17 @@
return qualifier;
}
+ private static int getMatchingGroups(Matcher m)
+ {
+ int matchingGroups = 0;
+ for(int i=1; i<=m.groupCount(); i++)
+ {
+ String s = m.group(i);
+ if(s!=null && !"".equals(s)) matchingGroups++;
+ }
+ return matchingGroups;
+ }
+
private String regexFromPathSegment(String tok)
{
return "(\\b"+tok+"\\b)";
Modified: stack/native/branches/rest/src/main/java/org/jboss/rs/model/RegexQualifier.java
===================================================================
---
stack/native/branches/rest/src/main/java/org/jboss/rs/model/RegexQualifier.java 2007-10-29
16:54:19 UTC (rev 4924)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/model/RegexQualifier.java 2007-10-29
17:03:50 UTC (rev 4925)
@@ -53,9 +53,17 @@
else if(to.numGroups >this.numGroups)
return 1;
else
- return 0;
+ {
+ // bigger pattern but same number of matching groups
+ // means it's less accurate
+ if(to.patternLength<this.patternLength)
+ return 1;
+ else if(to.patternLength>this.patternLength)
+ return -1;
+ else
+ return 0;
+ }
- // todo: compare by second key
}
public String toString()
Modified:
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceResolver.java
===================================================================
---
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceResolver.java 2007-10-29
16:54:19 UTC (rev 4924)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceResolver.java 2007-10-29
17:03:50 UTC (rev 4925)
@@ -59,17 +59,7 @@
while(it2.hasNext() && null==resourceMethod)
{
ResourceMatch rootResource = it2.next();
-
- // a root resource may be a final resource match already
- resourceMethod = resolveResourceMethod(rootResource,
rootResource.qualifier.nextUriToken);
-
- // root didn't match, so recurse locators to find a resource
- if(null == resourceMethod)
- {
- ResourceMatch subResource = resolveByLocator(rootResource);
- if(subResource!=null)
- resourceMethod = resolveResourceMethod(subResource,
rootResource.qualifier.nextUriToken);
- }
+ resourceMethod = dfsResourceMatch(rootResource);
}
if(null == resourceMethod)
@@ -79,6 +69,28 @@
return resourceMethod;
}
+ /**
+ * Recursive scan for resource methods.
+ * Inspect a resource match for methods and it fails try the locators.
+ *
+ * @param dfsEntry
+ * @return
+ */
+ private ResourceMethod dfsResourceMatch(ResourceMatch dfsEntry)
+ {
+ ResourceMethod resourceMethod = null;
+ resourceMethod = resolveResourceMethod(dfsEntry, dfsEntry.qualifier.nextUriToken);
+
+ // root didn't match, so recurse locators to find a resource
+ if(null == resourceMethod)
+ {
+ ResourceMatch subResource = resolveByLocator(dfsEntry);
+ if(subResource!=null)
+ resourceMethod = dfsResourceMatch(subResource);
+ }
+ return resourceMethod;
+ }
+
private ResourceMatch resolveByLocator(ResourceMatch<ResourceModel>
resourceMatch)
{
ResourceMatch match = null;
@@ -93,15 +105,12 @@
weightedResults.add( new ResourceMatch( bridge.field(), qualifier) );
}
- Collections.sort(weightedResults);
- ResourceMatch next = weightedResults.get(0);
- String nextUriToken = next.qualifier.nextUriToken;
-
- if("".equals(nextUriToken) || "/".equals(nextUriToken))
- match = next;
- else
- match = resolveByLocator(next);
-
+ if(!weightedResults.isEmpty())
+ {
+ Collections.sort(weightedResults);
+ match = weightedResults.get(0);
+ }
+
return match;
}
Modified:
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResolverTestCase.java
===================================================================
---
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResolverTestCase.java 2007-10-29
16:54:19 UTC (rev 4924)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResolverTestCase.java 2007-10-29
17:03:50 UTC (rev 4925)
@@ -54,7 +54,7 @@
ResourceMethod method = resolver.resolve(rootModels, "widgets/Id/spec");
assertNotNull(method);
- assertEquals(method.getUriTemplate(), "spec");
+ assertEquals("spec", method.getUriTemplate());
}
public void testRegexResolver2() throws Exception
@@ -64,7 +64,7 @@
ResourceMethod method = resolver.resolve(rootModels, "widgets/special");
assertNotNull(method);
- assertEquals(method.getUriTemplate(), "special");
+ assertEquals("special", method.getUriTemplate());
}
public void testRegexResolver3() throws Exception
@@ -74,7 +74,7 @@
ResourceMethod method = resolver.resolve(rootModels, "widgets/offers");
assertNotNull(method);
- assertEquals(method.getUriTemplate(), "offers");
+ assertEquals("offers", method.getUriTemplate());
assertTrue(method.getEntityModel().getImplementation().equals(WidgetList.class));
}
@@ -85,7 +85,7 @@
ResourceMethod method = resolver.resolve(rootModels,
"widgets/Id/spec/SpecName");
assertNotNull(method);
- assertEquals(method.getUriTemplate(), "spec/{name}");
+ assertEquals("spec/{name}", method.getUriTemplate());
assertTrue(method.getEntityModel().getImplementation().equals(Specification.class));
}
Modified: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/RunRegex.java
===================================================================
---
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/RunRegex.java 2007-10-29
16:54:19 UTC (rev 4924)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/RunRegex.java 2007-10-29
17:03:50 UTC (rev 4925)
@@ -32,19 +32,24 @@
{
public static void main(String[] args)
{
- String s = "special";
+ String s = "spec";
System.out.println("> " +s);
- Pattern p =
Pattern.compile("(\\bspec\\b)(/)?");//Pattern.compile("(.*?)(/.*)?");
+ Pattern p = Pattern.compile("(\\bspec\\b)(.*?)(/)?");
+ //Pattern p = Pattern.compile("(\\bspec\\b)(/)?");
Matcher m = p.matcher(s);
- System.out.println("? " + m.find());
- System.out.println("! "+m.groupCount());
- System.out.println("# " + s.substring(m.end()));
- for(int i=0; i<=m.groupCount(); i++)
+ System.out.println("? " + m.matches());
+
+ int matchingGroups = 0;
+ for(int i=1; i<=m.groupCount(); i++)
{
- System.out.println("g '" + m.group(i) + "'");
+ String s1 = m.group(i);
+ System.out.println("g '" + s1 + "'");
+ if(s1!=null && "".equals(s1)==false)
+ matchingGroups++;
}
+ System.out.println("! "+matchingGroups);
System.out.println("< "+m.group(m.groupCount()));
System.out.println("---");
Modified:
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Specification.java
===================================================================
---
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Specification.java 2007-10-29
16:54:19 UTC (rev 4924)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Specification.java 2007-10-29
17:03:50 UTC (rev 4925)
@@ -27,4 +27,14 @@
*/
public class Specification
{
+ public String name = "Unknown";
+
+ public Specification()
+ {
+ }
+
+ public Specification(String name)
+ {
+ this.name = name;
+ }
}
Modified: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Widget.java
===================================================================
---
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Widget.java 2007-10-29
16:54:19 UTC (rev 4924)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Widget.java 2007-10-29
17:03:50 UTC (rev 4925)
@@ -48,6 +48,6 @@
@UriTemplate("spec/{name}")
Specification getSpecByName(@UriParam("name")String name)
{
- return new Specification();
+ return new Specification(name);
}
}
Modified:
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/WidgetList.java
===================================================================
---
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/WidgetList.java 2007-10-29
16:54:19 UTC (rev 4924)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/WidgetList.java 2007-10-29
17:03:50 UTC (rev 4925)
@@ -24,6 +24,7 @@
import javax.ws.rs.GET;
import javax.ws.rs.UriParam;
import javax.ws.rs.UriTemplate;
+import javax.ws.rs.POST;
@UriTemplate("widgets")
public class WidgetList
@@ -34,7 +35,7 @@
return null;
}
- @GET
+ @POST
@UriTemplate("special")
void getDiscounted(Widget special) {