Author: heiko.braun(a)jboss.com
Date: 2007-11-06 04:13:53 -0500 (Tue, 06 Nov 2007)
New Revision: 4992
Added:
stack/native/branches/rest/src/main/java/org/jboss/rs/media/EntityProviderRegistry.java
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ParameterBinding.java
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/ContextAdapterBuilder.java
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/DefaultInvocationBuilder.java
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/Invocation.java
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationBuilder.java
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationHandler.java
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationModel.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/Specification.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/Widget.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/WidgetList.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/invocation/
stack/native/branches/rest/src/test/java/org/jboss/test/rs/invocation/InvocationBuilderTestCase.java
Removed:
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
Modified:
stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java
stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.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/test/java/org/jboss/test/rs/model/ModelParserTestCase.java
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResolverTestCase.java
Log:
InvocaitonModel first cut
Modified: stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java 2007-11-05
21:51:45 UTC (rev 4991)
+++ stack/native/branches/rest/src/main/java/org/jboss/rs/ResourceRegistry.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -29,6 +29,8 @@
import java.util.Map;
/**
+ * Register root resources for webContext's.
+ *
* @author Heiko.Braun(a)jboss.com
* @version $Revision$
*/
@@ -36,20 +38,20 @@
{
private Map<String, List<ResourceModel>> webContextMapping = new
HashMap<String, List<ResourceModel>>();
- public void addResourceModelForContext(String context, ResourceModel model)
+ public void addResourceModelForContext(String webContext, ResourceModel model)
{
- if(null == webContextMapping.get(context))
- webContextMapping.put(context, new ArrayList<ResourceModel>());
+ if(null == webContextMapping.get(webContext))
+ webContextMapping.put(webContext, new ArrayList<ResourceModel>());
- webContextMapping.get(context).add(model);
+ webContextMapping.get(webContext).add(model);
}
- public List<ResourceModel> getResourceModelsForContext(String context)
+ public List<ResourceModel> getResourceModelsForContext(String webContext)
{
- if(null == webContextMapping.get(context))
- webContextMapping.put(context, new ArrayList<ResourceModel>());
+ if(null == webContextMapping.get(webContext))
+ webContextMapping.put(webContext, new ArrayList<ResourceModel>());
- return webContextMapping.get(context);
+ return webContextMapping.get(webContext);
}
}
Added:
stack/native/branches/rest/src/main/java/org/jboss/rs/media/EntityProviderRegistry.java
===================================================================
---
stack/native/branches/rest/src/main/java/org/jboss/rs/media/EntityProviderRegistry.java
(rev 0)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/media/EntityProviderRegistry.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -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.media;
+
+import javax.ws.rs.ext.EntityProvider;
+import javax.activation.MimeType;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class EntityProviderRegistry
+{
+ private List<EntityProvider> providers = new ArrayList<EntityProvider>();
+
+ public void addProvider(EntityProvider provider)
+ {
+ providers.add(provider);
+ }
+
+ public EntityProvider getProviderByMime(MimeType mime)
+ {
+ EntityProvider match = null;
+
+ for(EntityProvider p : providers)
+ {
+ //
+ }
+
+ return match;
+ }
+
+
+}
Property changes on:
stack/native/branches/rest/src/main/java/org/jboss/rs/media/EntityProviderRegistry.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-11-05
21:51:45 UTC (rev 4991)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/model/AbstractRegexResolveable.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -40,22 +40,37 @@
protected void initFromUriTemplate(String uriTemplate)
{
+ initFromUriTemplate(uriTemplate, null);
+ }
+
+ protected void initFromUriTemplate(String uriTemplate, UriParamHandler handler)
+ {
assert uriTemplate!=null;
assert !uriTemplate.startsWith("/");
StringTokenizer tokenizer = new StringTokenizer(uriTemplate, "/");
StringBuffer patternBuffer = new StringBuffer();
+ int groupIndex = 1; // matching regex groups start with 1
while(tokenizer.hasMoreTokens())
{
- String tok = tokenizer.nextToken();
+ String tok = tokenizer.nextToken();
if(isUriParam(tok))
{
+ if(handler != null)
+ {
+ // register uri param callback
+ String paramName = tok.substring(1, tok.length()-1);
+ handler.newUriParam(groupIndex, paramName);
+
+ }
patternBuffer.append( regexFromUriParam(tok) );
}
else
{
patternBuffer.append( regexFromPathSegment(tok) );
}
+
+ groupIndex++;
}
if(hasChildren())
@@ -135,5 +150,10 @@
abstract boolean hasChildren();
abstract void freeze();
+
+ public interface UriParamHandler
+ {
+ void newUriParam(int regexGroup, String paramName);
+ }
}
Added: stack/native/branches/rest/src/main/java/org/jboss/rs/model/ParameterBinding.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/model/ParameterBinding.java
(rev 0)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ParameterBinding.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -0,0 +1,186 @@
+/*
+ * 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.runtime.Invocation;
+import org.jboss.rs.runtime.InvocationModel;
+import org.jboss.rs.runtime.RuntimeContext;
+import org.jboss.rs.runtime.ContextAdapterBuilder;
+import org.jboss.rs.MethodHTTP;
+
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.UriParam;
+import javax.ws.rs.core.HttpContext;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Carries mapping information about
+ * <ul>
+ * <li>MatrixParam
+ * <li>QueryParam
+ * <li>UriParam
+ * <li>HttpContext
+ * <li>HeaderParam
+ * </ul>
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class ParameterBinding implements InvocationModel
+{
+ /* Pattenern of the owning ResourceMethod */
+ private final Pattern regex;
+
+ /* Pattern to strip prefix from runtime path */
+ private static final String PREFIX_PATTERN = "(.*?)";
+
+ /*the total number of parameters */
+ private int totalParameters = 0;
+
+ /*positions of the query parameters*/
+ Map<String, Integer> queryParam = new HashMap<String, Integer>();
+
+ /*positions of the header parameters*/
+ Map<String, Integer> headerParam = new HashMap<String, Integer>();
+
+ /*positions of the header parameters*/
+ Map<String, Integer> uriParam = new HashMap<String, Integer>();
+
+ /* maps regex groups to UriTemplate wildcards */
+ Map<String, Integer> regexMapping = new HashMap<String, Integer>();
+
+ Map<Class, Integer> contextParamter = new HashMap<Class, Integer>();
+
+ private Class entityBodyType = null;
+ private int entityBodyIndex = -1;
+
+ /* Parameter types except for entity body*/
+ Map<Integer, Class> parameterTypes = new HashMap<Integer, Class>();
+
+ public void accept(Invocation invocation)
+ {
+ RuntimeContext ctx = invocation.getContext();
+ String path = ctx.getPath();
+
+ Matcher matcher = regex.matcher(path);
+ boolean matches = matcher.matches();
+
+ if(!matches)
+ throw new RuntimeException("RuntimeContext doesn't match invocation
model");
+
+ // @UriParam
+ for(String param : uriParam.keySet())
+ {
+ int paramIndex = uriParam.get(param);
+ String paramValue = matcher.group(regexMapping.get(param) + 1);
+ invocation.insertParameterInstance(paramIndex, paramValue);
+ }
+
+ ContextAdapterBuilder builder = new ContextAdapterBuilder(ctx);
+
+ // TODO: @QueryParam and @MatrixParam
+
+ // TODO: @HeaderParam
+
+ // @HttpContext
+ for(Class paramType : contextParamter.keySet())
+ {
+ Object paramInstance = builder.buildTypedAdapter(paramType);
+ invocation.insertParameterInstance(contextParamter.get(paramType),
paramInstance);
+ }
+
+ // TODO: Entity body
+ if(entityBodyType != null)
+ {
+ boolean validRequestMethod = MethodHTTP.POST == ctx.getRequestMethod() ||
MethodHTTP.PUT == ctx.getRequestMethod();
+ if(!validRequestMethod)
+ throw new RuntimeException("No entity body with request type " +
ctx.getRequestMethod());
+
+ // unmarshall body
+ }
+ }
+
+ ParameterBinding(Pattern rootPattern)
+ {
+ // Extend pattern to strip root path, results in additional groups
+ this.regex = Pattern.compile(PREFIX_PATTERN +rootPattern.toString());
+ }
+
+ void registerRegexGroupForParam(int group, String paramName)
+ {
+ regexMapping.put(paramName, group);
+ }
+
+ void registerParameterAnnotations(Method method)
+ {
+ for (Annotation[] parameterAnnotations : method.getParameterAnnotations())
+ {
+ if (parameterAnnotations!=null)
+ {
+ for (Annotation annotation : parameterAnnotations)
+ {
+ if(annotation.annotationType() == UriParam.class)
+ {
+ UriParam p = (UriParam)annotation;
+ uriParam.put(p.value(), totalParameters);
+ }
+ else if(annotation.annotationType() == HeaderParam.class)
+ {
+ HeaderParam p = (HeaderParam)annotation;
+ headerParam.put(p.value(), totalParameters);
+ }
+ else if(annotation.annotationType() == HttpContext.class)
+ {
+ HttpContext p = (HttpContext)annotation;
+ int paramPosition = totalParameters > 0 ? totalParameters - 1 : 0;
+ Class httpContextType = method.getParameterTypes()[paramPosition];
+ int httpContextIndex = totalParameters;
+
+ if(null == contextParamter.get(httpContextType))
+ contextParamter.put(httpContextType, httpContextIndex);
+ else
+ throw new RuntimeException("HttpContext on more then one method
parameter: " + method.getName()+ "," +httpContextIndex);
+ }
+ }
+
+ }
+ else
+ {
+ // The value of an non-annotated parameter is mapped from the request entity
body
+ // Must not be more then one per method
+ if(entityBodyType!=null)
+ throw new RuntimeException("Method " + method.getName() + "
contains more then one possible entity body parameters");
+
+ entityBodyType = method.getParameterTypes()[totalParameters-1];
+ entityBodyIndex = totalParameters;
+
+ }
+
+ totalParameters++;
+ }
+ }
+
+}
Property changes on:
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ParameterBinding.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
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 2007-11-05
21:51:45 UTC (rev 4991)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceLocator.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -31,6 +31,15 @@
private String uriTemplate;
+ UriParamHandler paramHandler = new UriParamHandler()
+ {
+
+ public void newUriParam(int regexGroup, String paramName)
+ {
+ System.out.println("UriParam: group="+regexGroup +",
name="+paramName);
+ }
+ };
+
ResourceLocator(ResourceModel target)
{
this.uriTemplate = target.getUriTemplate();
@@ -55,6 +64,6 @@
void freeze()
{
- initFromUriTemplate(this.uriTemplate);
+ initFromUriTemplate(this.uriTemplate, paramHandler);
}
}
Modified: 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 2007-11-05
21:51:45 UTC (rev 4991)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/model/ResourceMethod.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -28,8 +28,11 @@
import javax.ws.rs.ProduceMime;
import javax.activation.MimeType;
import java.lang.reflect.Method;
+import java.lang.annotation.Annotation;
import java.util.List;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author Heiko.Braun(a)jboss.com
@@ -44,6 +47,10 @@
private List<MimeType> consumeMimeTypes = new ArrayList<MimeType>();
private List<MimeType> produceMimeTypes = new ArrayList<MimeType>();
+ private ParameterBinding parameterBinding;
+
+ private boolean frozen;
+
ResourceMethod(MethodHTTP method, String uriTemplate, Method invocationTarget)
{
this.uriTemplate = uriTemplate;
@@ -83,40 +90,73 @@
return produceMimeTypes;
}
- void freeze()
+ public ParameterBinding getParameterBinding()
{
- initFromUriTemplate(this.uriTemplate);
- initMimeTypes();
+ assert frozen;
+ return parameterBinding;
}
- private void initMimeTypes()
+ void freeze()
{
+ // We need to know which param belongs to what regex group
+ final Map<String, Integer> regexInfo = new HashMap<String, Integer>();
+ UriParamHandler collectRegexInfo = new UriParamHandler()
+ {
+ public void newUriParam(int regexGroup, String paramName)
+ {
+ regexInfo.put(paramName, regexGroup);
+ }
+ };
- // In the absence of either of these annotations,
- // support for any media type (“*/*”) is assumed.
+ // setup the regex stuff and push uriParam info to ParameterBinding
+ initFromUriTemplate(this.uriTemplate, collectRegexInfo);
- if(invocationTarget.isAnnotationPresent(ConsumeMime.class))
+ // parse the mime annotations
+ initMimeTypes();
+
+ // Create ParameterBindig
+ this.parameterBinding = new ParameterBinding(this.regexPattern);
+
+ // Annotations on method parameters
+ this.parameterBinding.registerParameterAnnotations(invocationTarget);
+
+ // Additional info abpout the regex binding
+ for(String paramName : regexInfo.keySet())
{
- ConsumeMime cm = invocationTarget.getAnnotation(ConsumeMime.class);
- consumeMimeTypes.addAll(Convert.annotationToMimeType(cm));
+ int group = regexInfo.get(paramName);
+ this.parameterBinding.registerRegexGroupForParam(group, paramName);
}
+
+ // Lock instance
+ this.frozen = true;
+ }
+
+ private void initMimeTypes()
+ {
+ // ConsumeMime
+ ConsumeMime consumeMime = (ConsumeMime)mimeFromMethodOrClass(ConsumeMime.class);
+ if(consumeMime != null)
+ consumeMimeTypes.addAll(Convert.annotationToMimeType(consumeMime));
else
- {
consumeMimeTypes.add( Convert.ANY_MIME );
- }
- if(invocationTarget.isAnnotationPresent(ProduceMime.class))
- {
- ProduceMime pm = invocationTarget.getAnnotation(ProduceMime.class);
- produceMimeTypes.addAll(Convert.annotationToMimeType(pm));
- }
+ // ProduceMime
+ ProduceMime produceMime = (ProduceMime)mimeFromMethodOrClass(ProduceMime.class);
+ if(produceMime != null)
+ produceMimeTypes.addAll(Convert.annotationToMimeType(produceMime));
else
- {
produceMimeTypes.add( Convert.ANY_MIME );
- }
}
+ private Annotation mimeFromMethodOrClass( Class type )
+ {
+ Annotation ann = invocationTarget.isAnnotationPresent(type) ?
+ invocationTarget.getAnnotation(type) :
+ invocationTarget.getDeclaringClass().getAnnotation(type);
+ return ann;
+ }
+
public String toString()
{
return "ResourceMethod {"+methodHTTP+"
uri="+uriTemplate+", regex="+regexPattern+"}";
Added:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/ContextAdapterBuilder.java
===================================================================
---
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/ContextAdapterBuilder.java
(rev 0)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/ContextAdapterBuilder.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -0,0 +1,165 @@
+/*
+ * 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.runtime;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Cookie;
+import java.util.List;
+import java.net.URI;
+
+/**
+ * Adopts 311 runtime interfaces to an internal runtime context.<br>
+ * This way typed subsets of runtime information can be exposed, i.e:
+ *
+ * <ul>
+ * <li>{@link javax.ws.rs.core.HttpHeaders}
+ * <li>{@link javax.ws.rs.core.UriInfo}
+ * </ul>
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class ContextAdapterBuilder
+{
+ private RuntimeContext context;
+
+ public ContextAdapterBuilder(RuntimeContext context)
+ {
+ this.context = context;
+ }
+
+ public Object buildTypedAdapter(Class type)
+ {
+ Object returnType = null;
+
+ if(HttpHeaders.class == type)
+ {
+ returnType = new HttpHeadersAdapter();
+ }
+ else if (UriInfo.class == type)
+ {
+ returnType = new UriInfoAdapter();
+ }
+
+ if(null==returnType)
+ throw new RuntimeException("Unknown type " + type);
+
+ return returnType;
+ }
+
+ public class HttpHeadersAdapter implements HttpHeaders
+ {
+
+ public MultivaluedMap<String, String> getRequestHeaders()
+ {
+ return null;
+ }
+
+ public List<MediaType> getAcceptableMediaTypes()
+ {
+ return null;
+ }
+
+ public MediaType getMediaType()
+ {
+ return null;
+ }
+
+ public String getLanguage()
+ {
+ return null;
+ }
+
+ public List<Cookie> getCookies()
+ {
+ return null;
+ }
+ }
+
+ public class UriInfoAdapter implements UriInfo
+ {
+
+ public String getPath()
+ {
+ return null;
+ }
+
+ public String getPath(boolean b)
+ {
+ return null;
+ }
+
+ public List<PathSegment> getPathSegments()
+ {
+ return null;
+ }
+
+ public List<PathSegment> getPathSegments(boolean b)
+ {
+ return null;
+ }
+
+ public URI getAbsolute()
+ {
+ return null;
+ }
+
+ public UriBuilder getBuilder()
+ {
+ return null;
+ }
+
+ public URI getBase()
+ {
+ return null;
+ }
+
+ public UriBuilder getBaseBuilder()
+ {
+ return null;
+ }
+
+ public MultivaluedMap<String, String> getTemplateParameters()
+ {
+ return null;
+ }
+
+ public MultivaluedMap<String, String> getTemplateParameters(boolean b)
+ {
+ return null;
+ }
+
+ public MultivaluedMap<String, String> getQueryParameters()
+ {
+ return null;
+ }
+
+ public MultivaluedMap<String, String> getQueryParameters(boolean b)
+ {
+ return null;
+ }
+ }
+}
Property changes on:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/ContextAdapterBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/DefaultInvocationBuilder.java
===================================================================
---
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/DefaultInvocationBuilder.java
(rev 0)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/DefaultInvocationBuilder.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -0,0 +1,36 @@
+/*
+ * 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.runtime;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class DefaultInvocationBuilder extends InvocationBuilder
+{
+
+ public Invocation build(RuntimeContext context)
+ {
+ // Possible runtime aspects here
+ return super.build(context);
+ }
+}
Property changes on:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/DefaultInvocationBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/Invocation.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/Invocation.java
(rev 0)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/Invocation.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -0,0 +1,72 @@
+/*
+ * 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.runtime;
+
+import java.util.List;
+import java.util.LinkedList;
+
+/**
+ * The visitor part of the pattern.
+ *
+ * @see org.jboss.rs.runtime.InvocationModel
+ *
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class Invocation
+{
+ private RuntimeContext context;
+
+ List parameterInstances = new LinkedList();
+
+ public Invocation(RuntimeContext context)
+ {
+ this.context = context;
+ }
+
+ public RuntimeContext getContext()
+ {
+ return context;
+ }
+
+ /**
+ * Convinience method to work with String parameter types
+ * @param index
+ * @param param
+ */
+ public void insertParameterInstance(int index, String param)
+ {
+ if(param.startsWith("/"))
+ param = param.substring(1);
+ parameterInstances.add(index, param);
+ }
+
+ public void insertParameterInstance(int index, Object param)
+ {
+ parameterInstances.add(index, param);
+ }
+
+ public List getParameterInstances()
+ {
+ return parameterInstances;
+ }
+}
Property changes on:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/Invocation.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationBuilder.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationBuilder.java
(rev 0)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationBuilder.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -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.runtime;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Gathers invocation models (both static and runtime)
+ * and builds an {@link org.jboss.rs.runtime.Invocation} instance that can be consumed
+ * by an {@link org.jboss.rs.runtime.InvocationHandler}
+ *
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public abstract class InvocationBuilder
+{
+ private List<InvocationModel> invocationModels = new
LinkedList<InvocationModel>();
+
+ /**
+ * Add invocaiton model to an order list.
+ *
+ * @param model
+ */
+ public void addInvocationModel(InvocationModel model )
+ {
+ invocationModels.add(model);
+ }
+
+ public Invocation build(RuntimeContext context)
+ {
+ Invocation invocation = new Invocation(context);
+
+ for(InvocationModel model : invocationModels)
+ {
+ model.accept(invocation);
+ }
+
+ return invocation;
+ }
+}
Property changes on:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationHandler.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationHandler.java
(rev 0)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationHandler.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -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.runtime;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public interface InvocationHandler
+{
+ Object invoke(Invocation invocation);
+}
Property changes on:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationModel.java
===================================================================
--- stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationModel.java
(rev 0)
+++
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationModel.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -0,0 +1,36 @@
+/*
+ * 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.runtime;
+
+/**
+ * An <code>InvocationModel</code> will be visited by an {@link
org.jboss.rs.runtime.Invocation}
+ * instance and supplies a certain aspect (i.e. Parameter mapping, injection, etc) to
it.
+ * <p>
+ * It's the visitable part of the pattern.
+ *
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public interface InvocationModel
+{
+ void accept(Invocation invocation);
+}
Property changes on:
stack/native/branches/rest/src/main/java/org/jboss/rs/runtime/InvocationModel.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: stack/native/branches/rest/src/test/java/org/jboss/test/rs/Specification.java
(from rev 4925,
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/Specification.java
(rev 0)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/Specification.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -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.test.rs;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class Specification
+{
+ public String name = "Unknown";
+
+ public Specification()
+ {
+ }
+
+ public Specification(String name)
+ {
+ this.name = name;
+ }
+}
Property changes on:
stack/native/branches/rest/src/test/java/org/jboss/test/rs/Specification.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: stack/native/branches/rest/src/test/java/org/jboss/test/rs/Widget.java (from rev
4942, 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/Widget.java
(rev 0)
+++ stack/native/branches/rest/src/test/java/org/jboss/test/rs/Widget.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -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;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.UriParam;
+import javax.ws.rs.UriTemplate;
+
+/**
+ * @author Heiko.Braun(a)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(name);
+ }
+}
Property changes on:
stack/native/branches/rest/src/test/java/org/jboss/test/rs/Widget.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: stack/native/branches/rest/src/test/java/org/jboss/test/rs/WidgetList.java (from
rev 4958,
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/WidgetList.java
(rev 0)
+++ stack/native/branches/rest/src/test/java/org/jboss/test/rs/WidgetList.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.UriParam;
+import javax.ws.rs.UriTemplate;
+import javax.ws.rs.POST;
+import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.ProduceMime;
+import javax.ws.rs.core.HttpContext;
+import javax.ws.rs.core.HttpHeaders;
+
+@UriTemplate("widgets")
+public class WidgetList
+{
+ @GET
+ @ProduceMime({"text/plain"})
+ String getDescription() {
+ return "A widgetlist";
+ }
+
+ @GET
+ @UriTemplate("offers")
+ WidgetList getDiscounted() {
+ return null;
+ }
+
+ @POST
+ @UriTemplate("special")
+ @ConsumeMime({"text/xml", "application/xml"})
+ void setDiscounted(
+ @HttpContext HttpHeaders headers,
+ 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/WidgetList.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/rest/src/test/java/org/jboss/test/rs/invocation/InvocationBuilderTestCase.java
===================================================================
---
stack/native/branches/rest/src/test/java/org/jboss/test/rs/invocation/InvocationBuilderTestCase.java
(rev 0)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/invocation/InvocationBuilderTestCase.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -0,0 +1,112 @@
+/*
+ * 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.invocation;
+
+import junit.framework.TestCase;
+import org.jboss.rs.ResourceRegistry;
+import org.jboss.rs.MethodHTTP;
+import org.jboss.rs.runtime.RuntimeContext;
+import org.jboss.rs.runtime.InvocationBuilder;
+import org.jboss.rs.runtime.DefaultInvocationBuilder;
+import org.jboss.rs.runtime.Invocation;
+import org.jboss.rs.runtime.InvocationHandler;
+import org.jboss.rs.model.ResourceModel;
+import org.jboss.rs.model.ResourceModelParser;
+import org.jboss.rs.model.ResourceResolver;
+import org.jboss.rs.model.ResourceMethod;
+import org.jboss.test.rs.WidgetList;
+
+import javax.ws.rs.core.HttpHeaders;
+import java.util.List;
+import java.net.URI;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ * @version $Revision$
+ */
+public class InvocationBuilderTestCase extends TestCase
+{
+ ResourceRegistry registry;
+ List<ResourceModel> rootModels;
+
+ protected void setUp() throws Exception
+ {
+ this.registry = new ResourceRegistry();
+ ResourceModel root = ResourceModelParser.newInstance().parse(WidgetList.class);
+ registry.addResourceModelForContext("/rest", root);
+ rootModels = registry.getResourceModelsForContext("/rest");
+ }
+
+ public void testUriParamBinding() throws Exception
+ {
+ URI uri = new
URI("http://jboss.com/widgets/Foo/spec/Bar");
+ RuntimeContext context = defaultRuntimeContext(MethodHTTP.GET, uri);
+ ResourceResolver resolver = ResourceResolver.newInstance(context);
+
+ ResourceMethod method = resolver.resolve();
+
+ assertNotNull(method);
+ assertEquals("spec/{name}", method.getUriTemplate());
+
+ // setup a builder
+ InvocationBuilder builder = new DefaultInvocationBuilder();
+ builder.addInvocationModel(method.getParameterBinding());
+
+ // create an Invocation instance
+ Invocation invocation = builder.build(context);
+ Object parameterInstance = invocation.getParameterInstances().get(0);
+ assertTrue(parameterInstance!=null);
+ assertTrue("Wildcard parameter {name} not bound",
parameterInstance.equals("Bar"));
+
+ }
+
+ public void testHttpContextParamBinding() throws Exception
+ {
+ URI uri = new
URI("http://jboss.com/widgets/special");
+ RuntimeContext context = defaultRuntimeContext(MethodHTTP.POST, uri);
+ context.parseContentTypeHeader("text/xml");
+ ResourceResolver resolver = ResourceResolver.newInstance(context);
+
+ ResourceMethod method = resolver.resolve();
+
+ assertNotNull(method);
+ assertEquals("special", method.getUriTemplate());
+
+ // setup a builder
+ InvocationBuilder builder = new DefaultInvocationBuilder();
+ builder.addInvocationModel(method.getParameterBinding());
+
+ // create an Invocation instance
+ Invocation invocation = builder.build(context);
+ Object parameterInstance = invocation.getParameterInstances().get(0);
+ assertTrue(parameterInstance!=null);
+ assertTrue("HttpContext parameter not bound", parameterInstance
instanceof HttpHeaders);
+
+ }
+
+ private RuntimeContext defaultRuntimeContext(MethodHTTP method, URI uri)
+ {
+ RuntimeContext context = new RuntimeContext(method, uri, rootModels );
+ context.parseAcceptHeader("*/*");
+ return context;
+ }
+}
Property changes on:
stack/native/branches/rest/src/test/java/org/jboss/test/rs/invocation/InvocationBuilderTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ModelParserTestCase.java
===================================================================
---
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ModelParserTestCase.java 2007-11-05
21:51:45 UTC (rev 4991)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ModelParserTestCase.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -26,6 +26,7 @@
import org.jboss.rs.model.ResourceModel;
import org.jboss.rs.model.ResourceMethod;
import org.jboss.rs.MethodHTTP;
+import org.jboss.test.rs.WidgetList;
/**
* @author Heiko.Braun(a)jboss.com
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-11-05
21:51:45 UTC (rev 4991)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/ResolverTestCase.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -29,6 +29,7 @@
import org.jboss.rs.model.ResourceModelParser;
import org.jboss.rs.model.ResourceResolver;
import org.jboss.rs.model.ResourceMethod;
+import org.jboss.test.rs.WidgetList;
import java.util.List;
import java.lang.reflect.Method;
Deleted:
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-11-05
21:51:45 UTC (rev 4991)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Specification.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -1,40 +0,0 @@
-/*
- * 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(a)jboss.com
- * @version $Revision$
- */
-public class Specification
-{
- public String name = "Unknown";
-
- public Specification()
- {
- }
-
- public Specification(String name)
- {
- this.name = name;
- }
-}
Deleted: 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-11-05
21:51:45 UTC (rev 4991)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/Widget.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -1,53 +0,0 @@
-/*
- * 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;
-
-/**
- * @author Heiko.Braun(a)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(name);
- }
-}
Deleted: 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-11-05
21:51:45 UTC (rev 4991)
+++
stack/native/branches/rest/src/test/java/org/jboss/test/rs/model/WidgetList.java 2007-11-06
09:13:53 UTC (rev 4992)
@@ -1,57 +0,0 @@
-/*
- * 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;
-import javax.ws.rs.POST;
-import javax.ws.rs.ConsumeMime;
-import javax.ws.rs.ProduceMime;
-
-@UriTemplate("widgets")
-public class WidgetList
-{
- @GET
- @ProduceMime({"text/plain"})
- String getDescription() {
- return "A widgetlist";
- }
-
- @GET
- @UriTemplate("offers")
- WidgetList getDiscounted() {
- return null;
- }
-
- @POST
- @UriTemplate("special")
- @ConsumeMime({"text/xml", "application/xml"})
- void setDiscounted(Widget special) {
- // TODO: Should return a new location
- }
-
- @UriTemplate("{id}")
- Widget findWidget(@UriParam("id") String id) {
- return new Widget(id);
- }
-}