[jbossws-commits] JBossWS SVN: r4914 - in stack/native/branches/rest: ant-import and 9 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Oct 29 09:14:59 EDT 2007


Author: heiko.braun at jboss.com
Date: 2007-10-29 09:14:58 -0400 (Mon, 29 Oct 2007)
New Revision: 4914

Added:
   stack/native/branches/rest/src/main/java/org/jboss/rs/
   stack/native/branches/rest/src/main/java/org/jboss/rs/MethodHTTP.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityModel.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityResolver.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoMethodException.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoResourceException.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/ResourceLocator.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceMethod.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModel.java
   stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModelFactory.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/
   stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/
   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/ResourceFactoryTestCase.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
   stack/native/branches/rest/src/test/resources/test-excludes-jboss423.txt
Modified:
   stack/native/branches/rest/ant-import-tests/build-testsuite.xml
   stack/native/branches/rest/ant-import/build-deploy.xml
   stack/native/branches/rest/ant-import/build-setup.xml
   stack/native/branches/rest/ant-import/build-thirdparty.xml
   stack/native/branches/rest/ant-import/macros-deploy-native.xml
   stack/native/branches/rest/ant.properties.example
   stack/native/branches/rest/build.xml
   stack/native/branches/rest/src/main/java/javax/xml/ws/WebServiceContext.java
Log:
runtime model and resource resolver, first cut

Modified: stack/native/branches/rest/ant-import/build-deploy.xml
===================================================================
--- stack/native/branches/rest/ant-import/build-deploy.xml	2007-10-29 13:12:16 UTC (rev 4913)
+++ stack/native/branches/rest/ant-import/build-deploy.xml	2007-10-29 13:14:58 UTC (rev 4914)
@@ -56,7 +56,8 @@
   
   <!-- Deploy jbossws to jboss422 -->
   <target name="deploy-jboss422" depends="jars-jboss42,undeploy-jboss422,deploy-jboss422-endorsed" description="Deploy jbossws to jboss422">
-    <macro-deploy-native422 stacklibs="${core.dir}/output/lib" thirdpartylibs="${core.dir}/thirdparty"/>
+    <fail message="Not available: ${jboss422.available.file}" unless="jboss422.available"/>
+    <macro-deploy-native422 jbosshome="${jboss422.home}" stacklibs="${core.dir}/output/lib" thirdpartylibs="${core.dir}/thirdparty"/>
     <macro-deploy-framework thirdpartylibs="${core.dir}/thirdparty" jbosshome="${jboss422.home}"/>
   </target>
   
@@ -66,12 +67,34 @@
   
   <!-- Remove jbossws from jboss422 -->
   <target name="undeploy-jboss422" depends="prepare,undeploy-jboss422-endorsed" description="Remove jbossws from jboss422">
-    <macro-undeploy-native422/>
+    <fail message="Not available: ${jboss422.available.file}" unless="jboss422.available"/>
+    <macro-undeploy-native422 jbosshome="${jboss422.home}"/>
     <macro-undeploy-framework jbosshome="${jboss422.home}"/>
   </target>
   <target name="undeploy-jboss422-endorsed" depends="prepare">
     <macro-undeploy-endorsed jbosshome="${jboss422.home}"/>
   </target>
+
+  <!-- Deploy jbossws to jboss423 -->
+  <target name="deploy-jboss423" depends="jars-jboss42,undeploy-jboss423,deploy-jboss423-endorsed" description="Deploy jbossws to jboss423">
+    <!--fail message="Not available: ${jboss422.available.file}" unless="jboss422.available"/-->
+    <macro-deploy-native422 jbosshome="${jboss423.home}" stacklibs="${core.dir}/output/lib" thirdpartylibs="${core.dir}/thirdparty"/>
+    <macro-deploy-framework thirdpartylibs="${core.dir}/thirdparty" jbosshome="${jboss423.home}"/>
+  </target>
+
+  <target name="deploy-jboss423-endorsed" depends="prepare" if="HAVE_JDK_1.6">
+    <macro-deploy-endorsed jbosshome="${jboss423.home}" stacklibs="${core.dir}/output/lib" thirdpartylibs="${core.dir}/thirdparty"/>
+  </target>
+
+  <!-- Remove jbossws from jboss423 -->
+  <target name="undeploy-jboss423" depends="prepare,undeploy-jboss423-endorsed" description="Remove jbossws from jboss423">
+    <!--fail message="Not available: ${jboss422.available.file}" unless="jboss422.available"/-->
+    <macro-undeploy-native422 jbosshome="${jboss423.home}"/>
+    <macro-undeploy-framework jbosshome="${jboss423.home}"/>
+  </target>
+  <target name="undeploy-jboss423-endorsed" depends="prepare">
+    <macro-undeploy-endorsed jbosshome="${jboss423.home}"/>
+  </target>
   
   <!-- Deploy jbossws to jboss500 -->
   <target name="deploy-jboss500" depends="jars-jboss50,undeploy-jboss500,deploy-jboss500-endorsed" description="Deploy jbossws to jboss500">

Modified: stack/native/branches/rest/ant-import/build-setup.xml
===================================================================
--- stack/native/branches/rest/ant-import/build-setup.xml	2007-10-29 13:12:16 UTC (rev 4913)
+++ stack/native/branches/rest/ant-import/build-setup.xml	2007-10-29 13:14:58 UTC (rev 4914)
@@ -72,6 +72,7 @@
     <or>
       <equals arg1="${jbossws.integration.target}" arg2="jboss421"/>
       <equals arg1="${jbossws.integration.target}" arg2="jboss422"/>
+      <equals arg1="${jbossws.integration.target}" arg2="jboss423"/>
     </or>
   </condition>
   <condition property="jbossws.integration.jboss50" value="true">

Modified: stack/native/branches/rest/ant-import/build-thirdparty.xml
===================================================================
--- stack/native/branches/rest/ant-import/build-thirdparty.xml	2007-10-29 13:12:16 UTC (rev 4913)
+++ stack/native/branches/rest/ant-import/build-thirdparty.xml	2007-10-29 13:14:58 UTC (rev 4914)
@@ -164,6 +164,7 @@
         <pathelement location="${thirdparty.dir}/xmlsec.jar"/>
         <pathelement location="${thirdparty.dir}/xercesImpl.jar"/>
        <pathelement location="${thirdparty.dir}/jboss-jaxb-intros.jar"/>
+       <pathelement location="${thirdparty.dir}/jsr311-api.jar"/>
      </path>
 
   </target>

Modified: stack/native/branches/rest/ant-import/macros-deploy-native.xml
===================================================================
--- stack/native/branches/rest/ant-import/macros-deploy-native.xml	2007-10-29 13:12:16 UTC (rev 4913)
+++ stack/native/branches/rest/ant-import/macros-deploy-native.xml	2007-10-29 13:14:58 UTC (rev 4914)
@@ -309,15 +309,16 @@
   <macrodef name="macro-deploy-native422">
     <attribute name="stacklibs"/>
     <attribute name="thirdpartylibs"/>
+    <attribute name="jbosshome"/>
     <sequential>
-      <fail message="Not available: ${jboss422.available.file}" unless="jboss422.available"/>
       
+      
       <!-- BIN SCRIPTS -->
-      <unzip dest="${jboss422.home}/bin" src="@{stacklibs}/jbossws-core-scripts.zip"/>
-      <chmod dir="${jboss422.home}/bin" perm="+x" includes="*.sh"/>
+      <unzip dest="@{jbosshome}/bin" src="@{stacklibs}/jbossws-core-scripts.zip"/>
+      <chmod dir="@{jbosshome}/bin" perm="+x" includes="*.sh"/>
       
       <!-- CLIENT JARS -->
-      <copy todir="${jboss422.home}/client" overwrite="true">
+      <copy todir="@{jbosshome}/client" overwrite="true">
         <fileset dir="@{stacklibs}">
           <include name="jboss-jaxrpc.jar"/>
           <include name="jboss-jaxws.jar"/>
@@ -339,20 +340,21 @@
       </copy>
       
       <!-- SERVER JARS -->
-      <mkdir dir="${jboss422.home}/server/${jboss.server.instance}/deploy/jbossws.sar"/>
-      <unjar dest="${jboss422.home}/server/${jboss.server.instance}/deploy/jbossws.sar" src="@{stacklibs}/jbossws-native42.sar"/>
-      <mkdir dir="${jboss422.home}/server/${jboss.server.instance}/deploy/juddi-service.sar"/>
-      <unzip dest="${jboss422.home}/server/${jboss.server.instance}/deploy/juddi-service.sar" src="@{thirdpartylibs}/juddi-service.sar"/>
+      <mkdir dir="@{jbosshome}/server/${jboss.server.instance}/deploy/jbossws.sar"/>
+      <unjar dest="@{jbosshome}/server/${jboss.server.instance}/deploy/jbossws.sar" src="@{stacklibs}/jbossws-native42.sar"/>
+      <mkdir dir="@{jbosshome}/server/${jboss.server.instance}/deploy/juddi-service.sar"/>
+      <unzip dest="@{jbosshome}/server/${jboss.server.instance}/deploy/juddi-service.sar" src="@{thirdpartylibs}/juddi-service.sar"/>
     </sequential>
   </macrodef>
   
   <macrodef name="macro-undeploy-native422">
+    <attribute name="jbosshome"/>
     <sequential>
-      <fail message="Not available: ${jboss422.available.file}" unless="jboss422.available"/>
+      
       <delete>
         
         <!-- BIN SCRIPTS -->
-        <fileset dir="${jboss422.home}/bin">
+        <fileset dir="@{jbosshome}/bin">
           <include name="wsconsume.*"/>
           <include name="wsprovide.*"/>
           <include name="wsrunclient.*"/>
@@ -360,7 +362,7 @@
         </fileset>
         
         <!-- CLIENT JARS -->
-        <fileset dir="${jboss422.home}/client">
+        <fileset dir="@{jbosshome}/client">
           <include name="jaxb-api.jar"/>
           <include name="jaxb-impl.jar"/>
           <include name="jaxb-xjc.jar"/>
@@ -380,14 +382,14 @@
         </fileset>
         
         <!-- SERVER JARS -->
-        <fileset dir="${jboss422.home}/lib/endorsed">
+        <fileset dir="@{jbosshome}/lib/endorsed">
           <include name="jaxb-api.jar"/>
         </fileset>
-        <fileset dir="${jboss422.home}/lib">
+        <fileset dir="@{jbosshome}/lib">
           <!-- Remove only, do not deploy -->
           <include name="jbossws-integration.jar"/>
         </fileset>
-        <fileset dir="${jboss422.home}/server/${jboss.server.instance}/lib">
+        <fileset dir="@{jbosshome}/server/${jboss.server.instance}/lib">
           <include name="jboss-jaxrpc.jar"/>
           <include name="jboss-jaxws.jar"/>
           <include name="jboss-jaxws-ext.jar"/>
@@ -396,8 +398,8 @@
           <include name="jbossws-integration.jar"/>
         </fileset>
       </delete>
-      <delete dir="${jboss422.home}/server/${jboss.server.instance}/deploy/jbossws.sar"/>
-      <delete dir="${jboss422.home}/server/${jboss.server.instance}/deploy/juddi-service.sar"/>
+      <delete dir="@{jbosshome}/server/${jboss.server.instance}/deploy/jbossws.sar"/>
+      <delete dir="@{jbosshome}/server/${jboss.server.instance}/deploy/juddi-service.sar"/>
     </sequential>
   </macrodef>
   

Modified: stack/native/branches/rest/ant-import-tests/build-testsuite.xml
===================================================================
--- stack/native/branches/rest/ant-import-tests/build-testsuite.xml	2007-10-29 13:12:16 UTC (rev 4913)
+++ stack/native/branches/rest/ant-import-tests/build-testsuite.xml	2007-10-29 13:14:58 UTC (rev 4914)
@@ -48,6 +48,7 @@
       <pathelement location="${core.dir}/thirdparty/wstx.jar"/>
       <pathelement location="${core.dir}/thirdparty/xmlunit.jar"/>
       <pathelement location="${core.dir}/thirdparty/jboss-jaxb-intros.jar"/>
+      <pathelement location="${thirdparty.dir}/jsr311-api.jar"/>
     </path>
 
     <!-- The jBPM BPEL classpath -->

Modified: stack/native/branches/rest/ant.properties.example
===================================================================
--- stack/native/branches/rest/ant.properties.example	2007-10-29 13:12:16 UTC (rev 4913)
+++ stack/native/branches/rest/ant.properties.example	2007-10-29 13:14:58 UTC (rev 4914)
@@ -8,6 +8,7 @@
 #jboss405.home=/home/tdiesler/svn/jbossas/tags/JBoss_4_0_5_GA/build/output/jboss-4.0.5.GA
 #jboss421.home=/home/tdiesler/svn/jbossas/tags/JBoss_4_2_1_GA/build/output/jboss-4.2.1.GA
 #jboss422.home=/home/tdiesler/svn/jbossas/tags/JBoss_4_2_2_GA/build/output/jboss-4.2.2.GA
+#jboss423.home=/home/hbraun/dev/prj/jbossas/branches/Branch_4_2/build/output/jboss-4.2.3.GA/
 #jboss500.home=/home/tdiesler/svn/jbossas/trunk/build/output/jboss-5.0.0.Beta3
 
 # The JBoss server under test. This can be [jboss405|jboss405.no.ejb3|jboss421|jboss422|jboss500]

Modified: stack/native/branches/rest/build.xml
===================================================================
--- stack/native/branches/rest/build.xml	2007-10-29 13:12:16 UTC (rev 4913)
+++ stack/native/branches/rest/build.xml	2007-10-29 13:14:58 UTC (rev 4914)
@@ -74,6 +74,7 @@
       <include name="org/jboss/annotation/**"/>
       <include name="org/jboss/ws/**"/>
       <include name="org/jboss/wsf/stack/jbws/**"/>
+      <include name="org/jboss/rs/**"/>
       <classpath path="${core.output.classes14.dir}"/>
       <classpath refid="thirdparty.classpath"/>
     </javac>
@@ -181,6 +182,7 @@
       <fileset dir="${core.output.classes.dir}">
         <include name="org/jboss/annotation/**"/>
         <include name="org/jboss/ws/**"/>
+        <include name="org/jboss/rs/**"/>
       </fileset>
       <fileset dir="${core.resources.dir}">
         <include name="schema/**"/>

Modified: stack/native/branches/rest/src/main/java/javax/xml/ws/WebServiceContext.java
===================================================================
--- stack/native/branches/rest/src/main/java/javax/xml/ws/WebServiceContext.java	2007-10-29 13:12:16 UTC (rev 4913)
+++ stack/native/branches/rest/src/main/java/javax/xml/ws/WebServiceContext.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -34,7 +34,7 @@
  *
  *  Typically a <code>WebServiceContext</code> is injected
  *  into an endpoint implementation class using the
- *  <code>Resource</code> annotation.
+ *  <code>ResourceModel</code> annotation.
  *
  *  @since JAX-WS 2.0
  *

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/MethodHTTP.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/MethodHTTP.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/MethodHTTP.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public enum MethodHTTP
+{
+   GET, POST, PUT, DELETE, HEAD;
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/MethodHTTP.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs;
+
+import org.jboss.rs.model.ResourceModel;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class ResourceRegistry
+{
+   private Map<String, List<ResourceModel>> webContextMapping = new HashMap<String, List<ResourceModel>>();
+
+   public void addResourceModelForContext(String context, ResourceModel model)
+   {
+      if(null == webContextMapping.get(context))
+         webContextMapping.put(context, new ArrayList<ResourceModel>());
+
+      webContextMapping.get(context).add(model);
+   }
+
+   public List<ResourceModel> getResourceModelsForContext(String context)
+   {
+      if(null == webContextMapping.get(context))
+         webContextMapping.put(context, new ArrayList<ResourceModel>());
+
+      return webContextMapping.get(context);
+   }
+   
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: 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	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+import java.util.StringTokenizer;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public abstract class AbstractRegexResolveable
+{
+   public final String URI_PARAM_PATTERN        = "(.*?)";
+   public final String CHILD_SUFFIX_PATTERN     = "(/.*)?";
+   public final String CHILDLESS_SUFFIX_PATTERN = "(/)?";
+
+   protected Pattern regexPattern;
+   private boolean isCompiled;   
+
+   protected void initFromUriTemplate(String uriTemplate)
+   {
+      assert uriTemplate!=null;
+      assert !uriTemplate.startsWith("/");
+      
+      StringTokenizer tokenizer = new StringTokenizer(uriTemplate, "/");
+      StringBuffer patternBuffer = new StringBuffer();
+      while(tokenizer.hasMoreTokens())
+      {
+         String tok = tokenizer.nextToken();
+         if(isUriParam(tok))
+         {
+            patternBuffer.append( regexFromUriParam(tok) );
+         }
+         else
+         {
+            patternBuffer.append( regexFromPathSegment(tok) );
+         }
+      }
+
+      if(hasChildren())
+         patternBuffer.append(CHILD_SUFFIX_PATTERN);
+      else
+         patternBuffer.append(CHILDLESS_SUFFIX_PATTERN);
+
+
+      String patternString = patternBuffer.toString();
+      
+      this.regexPattern = Pattern.compile(patternString);
+      this.isCompiled = true;
+   }
+
+   /**
+    *  
+    * @param input a URI string
+    * @return a comparable or <code>null</code> if no match
+    */
+   public RegexQualifier resolve(String input)
+   {      
+      assert isCompiled;
+      assert input != null;
+      assert !input.startsWith("/");
+
+      RegexQualifier qualifier = null;
+
+      Matcher matcher = regexPattern.matcher(input);
+      if(! matcher.find() )
+         return qualifier;
+
+      String lastGroup = matcher.group( matcher.groupCount() );
+      if(null == lastGroup)
+      {
+         lastGroup = "";
+      }
+      else if(lastGroup.startsWith("/"))
+      {
+         lastGroup = lastGroup.substring(1);         
+      }
+      
+      qualifier = new RegexQualifier(
+        matcher.groupCount(),
+        regexPattern.pattern().length(),
+        lastGroup
+      );
+
+      return qualifier;
+   }
+
+   private String regexFromPathSegment(String tok)
+   {
+      return "(\\b"+tok+"\\b)";  
+   }
+
+   private String regexFromUriParam(String tok)
+   {
+      return URI_PARAM_PATTERN;
+   }
+
+   private boolean isUriParam(String token)
+   {
+      return token.startsWith("{") && token.endsWith("}");
+   }
+
+   abstract boolean hasChildren();
+
+   abstract void freeze();
+ 
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityModel.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityModel.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityModel.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class EntityModel
+{
+   Class implementation;
+
+   public EntityModel(Class implementation)
+   {
+      this.implementation = implementation;
+   }
+
+   public Class getImplementation()
+   {
+      return implementation;
+   }
+
+
+   public String toString()
+   {
+      return "EntityModel {impl="+implementation+"}";
+   }
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityModel.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityResolver.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityResolver.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityResolver.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+import java.util.List;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class EntityResolver
+{
+   List<ResourceModel> resourceModels;
+
+   public EntityResolver(List<ResourceModel> resourceModels)
+   {
+      this.resourceModels = resourceModels;
+   }
+
+   public EntityModel resolveEntityModel(String uri)
+   {
+      assert !uri.startsWith("/");
+
+      
+      return null;
+   }
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/EntityResolver.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoMethodException.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoMethodException.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoMethodException.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class NoMethodException extends Exception
+{
+
+   public NoMethodException(String message)
+   {
+      super(message);
+   }
+
+   public NoMethodException(String message, Throwable cause)
+   {
+      super(message, cause);    
+   }
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoMethodException.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoResourceException.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoResourceException.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoResourceException.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class NoResourceException extends Exception
+{
+
+   public NoResourceException(String message)
+   {
+      super(message);
+   }
+
+   public NoResourceException(String message, Throwable cause)
+   {
+      super(message, cause);    
+   }
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/NoResourceException.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: 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	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/RegexQualifier.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class RegexQualifier implements Comparable
+{
+   public final int numGroups;
+   public final int patternLength;
+   public final String nextUriToken;
+
+   public RegexQualifier(int matchingGroups, int patternLenght, String uriToken)
+   {
+      this.numGroups = matchingGroups;
+      this.patternLength = patternLenght;
+
+      if(null == uriToken)
+         throw new IllegalArgumentException("Null UriToken");
+      
+      this.nextUriToken = uriToken;
+   }
+
+   public int compareTo(Object o)
+   {
+      if(! (o instanceof RegexQualifier) )
+         throw new IllegalArgumentException("Cannot compare RegexQualifier.class to " + o.getClass());
+
+      RegexQualifier to = (RegexQualifier)o;
+      if(to.numGroups <this.numGroups)
+         return -1;
+      else if(to.numGroups >this.numGroups)
+         return 1;
+      else
+         return 0;
+
+      // todo: compare by second key 
+   }
+
+   public String toString()
+   {
+      return "RegexQualifier{groups="+ numGroups +", patternLength="+patternLength+"}";
+   }
+}
\ No newline at end of file


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/RegexQualifier.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceLocator.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceLocator.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceLocator.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class ResourceLocator extends AbstractRegexResolveable
+{
+   ResourceModel target;
+
+   private String uriTemplate;
+
+   public ResourceLocator(ResourceModel target)
+   {
+      this.uriTemplate = target.getUriTemplate();
+      this.target = target;          
+   }
+
+   public String getUriTemplate()
+   {
+      return uriTemplate;
+   }
+
+   public ResourceModel field()
+   {
+      return target;
+   }
+
+   boolean hasChildren()
+   {
+      // always append '(/.*)?' to the regex
+      return true;
+   }
+
+   void freeze()
+   {
+      initFromUriTemplate(this.uriTemplate);
+   }
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceLocator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceMethod.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceMethod.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceMethod.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+import org.jboss.rs.MethodHTTP;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class ResourceMethod extends AbstractRegexResolveable
+{
+   private EntityModel entityModel;
+   private MethodHTTP methodHTTP;
+   private String uriTemplate;
+
+   public ResourceMethod(MethodHTTP method, String uriTemplate, EntityModel entityModel)
+   {
+      this.uriTemplate = uriTemplate;
+      this.methodHTTP = method;
+      this.entityModel = entityModel;
+
+   }
+
+   public MethodHTTP getMethodHTTP()
+   {
+      return methodHTTP;
+   }
+
+
+   public EntityModel getEntityModel()
+   {
+      return entityModel;
+   }
+
+   public String getUriTemplate()
+   {
+      return this.uriTemplate;
+   }
+
+   boolean hasChildren()
+   {
+      // always append '(/)?' to the regex
+      return false;  
+   }
+
+   void freeze()
+   {
+      initFromUriTemplate(this.uriTemplate);     
+   }
+
+
+   public String toString()
+   {
+      return "ResourceMethod {"+methodHTTP+" uri="+uriTemplate+", regex="+regexPattern+", entity="+entityModel+"}";
+   }
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceMethod.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModel.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModel.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModel.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class ResourceModel extends AbstractRegexResolveable
+{
+   private ResourceModel parent = null;
+
+   private String uriTemplate;
+   private Class implementation;
+
+   /*TODO : parse resource methods = no UriTemplatem but HttpMethod annotation */
+   private List<ResourceMethod> resourceMethods = new ArrayList<ResourceMethod>();
+   private List<ResourceMethod> subResourceMethods = new ArrayList<ResourceMethod>();
+   private List<ResourceLocator> resourceLocators = new ArrayList<ResourceLocator>();
+
+   public ResourceModel(String uriTemplate, Class implementation)
+   {
+      this(null, uriTemplate, implementation);
+   }
+
+   public ResourceModel(ResourceModel parent, String uriTemplate, Class implementation)
+   {
+      this.parent = parent;
+      this.uriTemplate = uriTemplate;
+      this.implementation = implementation;      
+   }
+
+   /**
+    * Locks the resource model for further modifications    
+    */
+   void freeze()
+   {
+      initFromUriTemplate(this.uriTemplate);     
+   }
+
+   public void addSubResourceMethod(ResourceMethod srm)
+   {
+      subResourceMethods.add(srm);
+   }
+
+   public void addSubResourceLocator(ResourceLocator srl)
+   {
+      resourceLocators.add(srl);
+   }
+
+   public boolean hasSubResources()
+   {
+      return !subResourceMethods.isEmpty() || !resourceLocators.isEmpty();
+   }
+
+   ResourceModel getParent()
+   {
+      return parent;
+   }
+
+   public Class getImplementation()
+   {
+      return implementation;
+   }
+
+   public String getUriTemplate()
+   {
+      return uriTemplate;
+   }
+
+
+   List<ResourceMethod> getSubResourceMethods()
+   {
+      return subResourceMethods;
+   }
+
+   List<ResourceLocator> getResourceLocator()
+   {
+      return resourceLocators;
+   }
+
+   boolean hasChildren()
+   {
+      return hasSubResources(); 
+   }
+
+   public String toString()
+   {
+      return "ResourceModel {uri=" + uriTemplate + ", regex=" + regexPattern + ", impl=" + implementation + "}";      
+   }
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModel.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModelFactory.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModelFactory.java	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModelFactory.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+import org.jboss.rs.MethodHTTP;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.UriTemplate;
+import java.lang.reflect.Method;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class ResourceModelFactory
+{
+   public static ResourceModel createModel(Class bean)
+   {
+      assert bean.isAnnotationPresent(UriTemplate.class);
+
+      // the root resource
+      UriTemplate rootUri = (UriTemplate)bean.getAnnotation(UriTemplate.class);
+      ResourceModel rootResource = new ResourceModel(rootUri.value(), bean);
+
+      System.out.println("Creating resource model from bean: " + bean);
+
+      parseMetaData(rootResource);
+
+      return rootResource;
+   }
+
+   private static void parseMetaData(ResourceModel resource)
+   {
+      String parent = resource.getParent()!=null ? resource.getParent().getImplementation().getName() : "";
+      
+      for( Method m : resource.getImplementation().getDeclaredMethods() )
+      {
+         // handle subresources
+         if(m.isAnnotationPresent(UriTemplate.class))
+         {
+            UriTemplate uri = m.getAnnotation(UriTemplate.class);
+            Class<?> returnType = m.getReturnType();
+
+            // TODO: extend to other http methods
+            if(m.isAnnotationPresent(GET.class))
+            {
+               // sub resource method
+               GET http = (GET)m.getAnnotation(GET.class);
+               ResourceMethod resourceMethod = new ResourceMethod(
+                 MethodHTTP.valueOf("GET"), uri.value(), new EntityModel(returnType)
+               );
+               resource.addSubResourceMethod(resourceMethod);
+            }
+            else
+            {
+               // locator
+               ResourceModel subResource = new ResourceModel(resource, uri.value(), returnType);
+               ResourceLocator locator = new ResourceLocator(subResource);
+               locator.freeze();
+               resource.addSubResourceLocator(locator);
+
+               // recursive
+               parseMetaData(subResource);
+            }
+         }
+
+      }
+
+      // freeze resource
+      resource.freeze();
+
+      System.out.println("---");
+      System.out.println(resource);
+
+      // freeze sub resource methods
+      for(ResourceMethod srm : resource.getSubResourceMethods())
+      {
+         srm.freeze();
+         System.out.println(srm);
+      }
+      
+      System.out.println("---");
+   }
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceModelFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: 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	                        (rev 0)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceResolver.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.rs.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class ResourceResolver
+{
+   public ResourceMethod resolve(List<ResourceModel> rootResources, String uri)
+     throws NoResourceException, NoMethodException
+   {
+      ResourceMethod resourceMethod = null;
+
+      // Filter the set of resource classes by rejecting those whose
+      // regular expression does not match uri
+      List<ResourceMatch> includedResources = new ArrayList<ResourceMatch>();
+      Iterator<ResourceModel> it1 = rootResources.iterator();
+      while(it1.hasNext())
+      {
+         ResourceModel model = it1.next();
+         RegexQualifier qualifier = model.resolve(uri);
+         if(qualifier!=null)
+            includedResources.add( new ResourceMatch(model, qualifier) );
+      }
+
+      if(includedResources.isEmpty())
+         throw new NoResourceException("No resource matches URI '"+uri+"'");
+            
+      Collections.sort(includedResources);
+
+      // DFS by locator, should result in a resource match
+      Iterator<ResourceMatch> it2 = includedResources.iterator();
+      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);
+         }
+      }
+
+      if(null == resourceMethod)
+         throw new NoMethodException("No method for URI '"+uri);
+
+      // gotcha
+      return resourceMethod;
+   }
+
+   private ResourceMatch resolveByLocator(ResourceMatch<ResourceModel> resourceMatch)
+   {
+      ResourceMatch match = null;
+
+      List<ResourceMatch> weightedResults = new ArrayList<ResourceMatch>();
+      Iterator<ResourceLocator> locators = resourceMatch.model.getResourceLocator().iterator();
+      while(locators.hasNext())
+      {
+         ResourceLocator bridge = locators.next();
+         RegexQualifier qualifier = bridge.resolve(resourceMatch.qualifier.nextUriToken);
+         if(qualifier!=null)
+            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);
+
+      return match;
+   }
+
+   private ResourceMethod resolveResourceMethod(ResourceMatch<ResourceModel> methodTarget, String uriToken)
+   {
+      ResourceMethod match = null;
+
+      List<ResourceMatch<ResourceMethod>> matches = new ArrayList<ResourceMatch<ResourceMethod>>();
+      List<ResourceMethod> methods = methodTarget.model.getSubResourceMethods();
+      Iterator<ResourceMethod> it = methods.iterator();
+      while(it.hasNext())
+      {
+         ResourceMethod method = it.next();
+         RegexQualifier qualifier = method.resolve(uriToken);
+         if(qualifier!=null && ("".equals(qualifier.nextUriToken) || "/".equals(qualifier.nextUriToken)))
+         {
+            matches.add(
+              new ResourceMatch<ResourceMethod>(method, qualifier)
+            );            
+         }
+      }
+
+      if(!matches.isEmpty())
+      {
+         Collections.sort(matches);
+         match = matches.get(0).model;
+      }
+      
+      return match;
+   }
+
+   class ResourceMatch<T> implements Comparable
+   {
+      final T model;
+      final RegexQualifier qualifier;
+
+      public ResourceMatch(T model, RegexQualifier weight)
+      {
+         this.model = model;
+         this.qualifier = weight;
+      }
+
+      public int compareTo(Object o)
+      {
+         return qualifier.compareTo(((ResourceMatch<T>)o).qualifier);
+      }
+
+      public String toString()
+      {
+         return "ResourceMatch {model="+model+", weight="+ qualifier +"}";
+      }
+   }
+
+}


Property changes on: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceResolver.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: 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	                        (rev 0)
+++ stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResolverTestCase.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.rs.model;
+
+import junit.framework.TestCase;
+import org.jboss.rs.ResourceRegistry;
+import org.jboss.rs.model.ResourceModel;
+import org.jboss.rs.model.ResourceModelFactory;
+import org.jboss.rs.model.ResourceResolver;
+import org.jboss.rs.model.ResourceMethod;
+
+import java.util.List;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class ResolverTestCase extends TestCase
+{
+
+   ResourceRegistry registry;
+   List<ResourceModel> rootModels;
+
+   protected void setUp() throws Exception
+   {
+      this.registry = new ResourceRegistry();
+      ResourceModel root = ResourceModelFactory.createModel(WidgetList.class);
+      registry.addResourceModelForContext("/rest", root);
+      rootModels = registry.getResourceModelsForContext("/rest");
+   }
+
+   public void testRegexResolver1() throws Exception
+   {
+      ResourceResolver resolver = new ResourceResolver();
+      ResourceMethod method = resolver.resolve(rootModels, "widgets/Id/spec");
+
+      assertNotNull(method);
+      assertEquals(method.getUriTemplate(), "spec");
+   }
+
+   public void testRegexResolver2() throws Exception
+   {
+      ResourceResolver resolver = new ResourceResolver();
+
+      ResourceMethod method = resolver.resolve(rootModels, "widgets/special");
+
+      assertNotNull(method);
+      assertEquals(method.getUriTemplate(), "special");
+   }
+
+   public void testRegexResolver3() throws Exception
+   {
+      ResourceResolver resolver = new ResourceResolver();
+
+      ResourceMethod method = resolver.resolve(rootModels, "widgets/offers");
+
+      assertNotNull(method);
+      assertEquals(method.getUriTemplate(), "offers");
+      assertTrue(method.getEntityModel().getImplementation().equals(WidgetList.class));
+   }
+
+   public void testRegexResolver4() throws Exception
+   {
+      ResourceResolver resolver = new ResourceResolver();
+
+      ResourceMethod method = resolver.resolve(rootModels, "widgets/Id/spec/SpecName");
+
+      assertNotNull(method);                 
+      assertEquals(method.getUriTemplate(), "spec/{name}");
+      assertTrue(method.getEntityModel().getImplementation().equals(Specification.class));
+   }
+
+}


Property changes on: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResolverTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResourceFactoryTestCase.java
===================================================================
--- stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResourceFactoryTestCase.java	                        (rev 0)
+++ stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResourceFactoryTestCase.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.rs.model;
+
+import junit.framework.TestCase;
+import org.jboss.rs.model.ResourceModelFactory;
+import org.jboss.rs.model.ResourceModel;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class ResourceFactoryTestCase extends TestCase
+{
+   public void testParseMetaModel() throws Exception
+   {
+      ResourceModel root = ResourceModelFactory.createModel(WidgetList.class);
+   }
+
+   private void dumpModel(ResourceModel model)
+   {
+            
+   }
+}


Property changes on: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResourceFactoryTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: 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	                        (rev 0)
+++ stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/RunRegex.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.rs.model;
+
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class RunRegex
+{
+   public static void main(String[] args)
+   {
+      String s = "special";
+      System.out.println("> " +s);
+      Pattern p = Pattern.compile("(\\bspec\\b)(/)?");//Pattern.compile("(.*?)(/.*)?");
+      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("g '" + m.group(i) + "'");
+      }
+
+      System.out.println("< "+m.group(m.groupCount()));
+      System.out.println("---");
+
+
+   }
+}


Property changes on: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/RunRegex.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: 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	                        (rev 0)
+++ stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Specification.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.rs.model;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class Specification
+{
+}


Property changes on: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Specification.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: 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	                        (rev 0)
+++ stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Widget.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.rs.model;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.UriTemplate;
+import javax.ws.rs.UriParam;
+
+/**
+ * @author Heiko.Braun at jboss.com
+ * @version $Revision$
+ */
+public class Widget
+{
+   String id;
+
+   public Widget(String id)
+   {
+      this.id = id;
+   }
+
+   @GET
+   @UriTemplate("spec")
+   Specification[] getSpecification() {
+      return new Specification[]{ new Specification() };
+   }
+
+   @GET
+   @UriTemplate("spec/{name}")
+   Specification getSpecByName(@UriParam("name")String name)
+   {
+      return new Specification();
+   }
+}


Property changes on: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Widget.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: 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	                        (rev 0)
+++ stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/WidgetList.java	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.rs.model;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.UriParam;
+import javax.ws.rs.UriTemplate;
+
+ at UriTemplate("widgets")
+public class WidgetList
+{
+   @GET
+   @UriTemplate("offers")
+   WidgetList getDiscounted() {
+      return null;
+   }
+
+   @GET
+   @UriTemplate("special")
+   void getDiscounted(Widget special) {
+      
+   }
+
+   @UriTemplate("{id}")
+   Widget findWidget(@UriParam("id") String id) {
+      return new Widget(id);
+   }
+}


Property changes on: stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/WidgetList.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: stack/native/branches/rest/src/test/resources/test-excludes-jboss423.txt
===================================================================
--- stack/native/branches/rest/src/test/resources/test-excludes-jboss423.txt	                        (rev 0)
+++ stack/native/branches/rest/src/test/resources/test-excludes-jboss423.txt	2007-10-29 13:14:58 UTC (rev 4914)
@@ -0,0 +1,7 @@
+# EJB3/Injection excludes
+org/jboss/test/ws/jaxws/samples/webserviceref/**
+org/jboss/test/ws/jaxws/webserviceref/**
+
+# [JBWS-1797] Setting .NET friendly Endpoint in web.xml
+org/jboss/test/ws/jaxws/jbws1797/**
+


Property changes on: stack/native/branches/rest/src/test/resources/test-excludes-jboss423.txt
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbossws-commits mailing list