Re: SpringBean router not discovering any routes

2009-04-24 Thread Paul Austin
Give you bean an id in addition to the name. I think there was a bug in the
1.1.x series which required there to be an id.

bean name=/services id=services 

Paul


On Fri, Apr 24, 2009 at 1:43 AM, Stephane Nicoll
stephane.nic...@gmail.comwrote:

 Hi,

 I am trying to use the spring based config in 1.1.4 with Spring 2.5.6 and I
 just can't get it working.

 My Application adds additional filters, one of them being my main router as
 a SpringBeanRouter class.

 I have a set of resources and restlet defined in the same application
 context file and I can see through the debugger they are loaded and
 discovered by the Spring Bean router.

 In the 'postProcessBeanFactory' method of the SpringBeanRouter, the
 resolveUri always returns null because the aliases returned by the factory
 is an empty String. I honestly don't get it!

 Here's is one entry in my spring config file

  bean name=/services autowire=byName scope=prototype
  class=com.foo.service.ServicesResource
property name=context ref=restletContext/
/bean

 -

 Any idea? Is the autowire byName mandatory?

 Is there a sample somewhere?

 Thanks,
 Stéphane

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1888396


--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1893627

Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping SpringBeanRouter to /

2009-04-09 Thread Paul Austin
Rhett,

I agree on the setAttachment semantics. I'd still like to see  
something like the setDefaultAttachment method (e.g. setNoPath  
attachment) without using the setAttachments method as it is a lot  
simpler to configure. For all other cases the current router works fine.

Another option would be where you could specify a more regular  
expresssion like pattern. You could then match this case using ^$ as  
the path (i.e beginning and end of line with no content or to match /  
and  it would be ^/?$? Not sure how we'd get the template params in  
there as java regex doesn't allow you to name groups of matches.

Paul

On 8-Apr-09, at 4:18 PM, Rhett Sutphin wrote:

 Hi Paul,

 On Apr 8, 2009, at 10:18 AM, Paul Austin wrote:

 Jerome,

 Here is an implementation which extends SpringBeanRouter, it could
 easily be integrated into the super class.

 Thanks for the suggestion.  I've added something similar in
 SpringBeanRouter in trunk r4711, but I only added an attachments
 property (a la SpringRouter).

 Reasoning:  I don't think that setAttachment makes sense as a bean
 property, since it is actually adding another attachment instead of
 replacing anything.  Restlet's main Router class also has the concept
 of a default restlet.  The semantics in Router are a bit different
 than what you have here (its default is the restlet that receives all
 requests that don't map to something else, not the top-level resource
 -- depending on the routing mode these might be different things),  
 so  
 I left it out.  You should still be able to map the top-level route
 using the attachments property like so:

 property name=attachments
   map
 entry key=valuetopLevelResource/value/entry
   /map
 /property

 I haven't tried this, though, so if it doesn't work please let me
 know.  (We can come up with a different property name if necessary.)

 Thanks again,
 Rhett


 import java.util.Map;
 import java.util.Map.Entry;

 import org.restlet.Finder;
 import org.restlet.ext.spring.SpringBeanRouter;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.BeanFactoryAware;

 public class SpringRouter extends SpringBeanRouter implements
 BeanFactoryAware {
  private BeanFactory beanFactory;

  public void setAttachment(String uriPattern, String beanName) {
Finder finder = createFinder(beanFactory, beanName);
attach(uriPattern, finder);
  }

  public void setAttachments(MapString, String attachments) {
for (EntryString, String attachment : attachments.entrySet()) {
  String uriPattern = attachment.getKey();
  String beanName = attachment.getValue();
  setAttachment(uriPattern, beanName);

}
  }

  public void setBeanFactory(BeanFactory beanFactory) throws
 BeansException {
this.beanFactory = beanFactory;
  }

  public void setDefaultAttachment(String beanName) {
String uriPattern = ;
setAttachment(uriPattern, beanName);
  }
 }

 Paul


 On Wed, Apr 8, 2009 at 4:12 AM, Jerome Louvel jerome.lou...@noelios.com
 wrote:
 Paul,

 The problem is that the URI without the trailing slash isn't
 equivalent to the one with it. It's true that in many cases, people
 assume it is equivalent but it doesn't have to.

 Also, relative URIs can be expressed in the same way if the ends
 with a slash or not, leading to further routing issues. The only way
 we found to clean that is to force the client to redirect itself to
 the URI with a slash. However, it isn't something we should do
 automatically.

 BTW, there is a related RFE:

 Improve matching of directory URIs
 http://restlet.tigris.org/issues/show_bug.cgi?id=532

 Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com



 De : Paul Austin [mailto:mail-li...@revolsys.com]
 Envoyé : mardi 7 avril 2009 21:58
 À : discuss@restlet.tigris.org
 Objet : Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping
 SpringBeanRouter to /

 Here is a class which fixes the issue. Probably a better solution
 would be to change the Route class so that if the remainingPart is
  it sets it to / before doing the regex matching. On a related
 note is it possible to force exact matching so that say /apps would
 be mapped but not /apps/xyz?

 public class RootSpringBeanRouter extends SpringBeanRouter {
 @Override
 public void handle(Request request, Response response) {
 Reference resourceRef = request.getResourceRef();
 if (resourceRef.getRemainingPart().equals()) {
 resourceRef.addSegment();
 }
 super.handle(request, response);
 }
 }


 On Tue, Apr 7, 2009 at 12:27 PM, Paul Austin mail-
 li...@revolsys.com wrote:
 In my project I am deploying an application as a war file. The root
 of the web application /* is mapped to the RestletFrameworkServlet
 so that all handling is performed by Restlet.

 servlet
 servlet-namebpf/servlet-name
 servlet

Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping SpringBeanRouter to /

2009-04-08 Thread Paul Austin
Jerome,

The one problem in the case I described is that it is not possible to use 
as the resource path in this case as you cannot specify an empty bean alias
in the spring mapping file.

One approach around this would be to have a
SpringBeanRouter.setDefaultAttachment(String beanName) method which would
allow me to set the default restlet. Could you also have a
setAttachment(String path, String beanName) method and
setAttachments(ListString beanNames)

bean
  id=router
  class=...SpringBeanRouter
  p:defaultAttachment=myRootResource
/

BTW setXXX methods are easier to work with in Spring than using methods such
as attach.

Paul

On Wed, Apr 8, 2009 at 4:12 AM, Jerome Louvel jerome.lou...@noelios.comwrote:

  Paul,

 The problem is that the URI without the trailing slash isn't equivalent to
 the one with it. It's true that in many cases, people assume it is
 equivalent but it doesn't have to.

 Also, relative URIs can be expressed in the same way if the ends with a
 slash or not, leading to further routing issues. The only way we found to
 clean that is to force the client to redirect itself to the URI with a
 slash. However, it isn't something we should do automatically.

 BTW, there is a related RFE:

 Improve matching of directory URIs
 http://restlet.tigris.org/issues/show_bug.cgi?id=532

  Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com



  --
 *De :* Paul Austin [mailto:mail-li...@revolsys.com]
 *Envoyé :* mardi 7 avril 2009 21:58
 *À :* discuss@restlet.tigris.org
 *Objet :* Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping
 SpringBeanRouter to /

 Here is a class which fixes the issue. Probably a better solution would be
 to change the Route class so that if the remainingPart is  it sets it to
 / before doing the regex matching. On a related note is it possible to
 force exact matching so that say /apps would be mapped but not /apps/xyz?

 public class RootSpringBeanRouter extends SpringBeanRouter {
 @Override
 public void handle(Request request, Response response) {
 Reference resourceRef = request.getResourceRef();
 if (resourceRef.getRemainingPart().equals()) {
 resourceRef.addSegment();
 }
 super.handle(request, response);
 }
 }


 On Tue, Apr 7, 2009 at 12:27 PM, Paul Austin mail-li...@revolsys.comwrote:

 In my project I am deploying an application as a war file. The root of the
 web application /* is mapped to the RestletFrameworkServlet so that all
 handling is performed by Restlet.

 servlet
 servlet-namebpf/servlet-name

 servlet-classcom.noelios.restlet.ext.spring.RestletFrameworkServlet/servlet-class
 /servlet

 servlet-mapping
 servlet-namebpf/servlet-name
 url-pattern/*/url-pattern
 /servlet-mapping

 The root restlet is a SpringBeanRouter and I have a mapping for / to a
 resource as shown below.

 bean id=root class=org.restlet.ext.spring.SpringBeanRouter /

 bean
 name=/
 id=rootResource
 scope=prototype
 class=myResourceClass
 /

 The war is deployed to /ws on my server.

 If I access /ws I get an Restlet status page error saying The server has
 not found anything matching the request URI but if I use /ws/ it works
 correctly.

 I tried mapping to  to see if that would work and it gives the same
 behaviour.

 Is it possible to modify the router so that the root resource does not
 need the trailing slash?

 Cheers,
 Paul




--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1597319

Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping SpringBeanRouter to /

2009-04-08 Thread Paul Austin
Jerome,

Here is an implementation which extends SpringBeanRouter, it could easily be
integrated into the super class.

import java.util.Map;
import java.util.Map.Entry;

import org.restlet.Finder;
import org.restlet.ext.spring.SpringBeanRouter;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

public class SpringRouter extends SpringBeanRouter implements
BeanFactoryAware {
  private BeanFactory beanFactory;

  public void setAttachment(String uriPattern, String beanName) {
Finder finder = createFinder(beanFactory, beanName);
attach(uriPattern, finder);
  }

  public void setAttachments(MapString, String attachments) {
for (EntryString, String attachment : attachments.entrySet()) {
  String uriPattern = attachment.getKey();
  String beanName = attachment.getValue();
  setAttachment(uriPattern, beanName);

}
  }

  public void setBeanFactory(BeanFactory beanFactory) throws BeansException
{
this.beanFactory = beanFactory;
  }

  public void setDefaultAttachment(String beanName) {
String uriPattern = ;
setAttachment(uriPattern, beanName);
  }
}

Paul


On Wed, Apr 8, 2009 at 4:12 AM, Jerome Louvel jerome.lou...@noelios.comwrote:

  Paul,

 The problem is that the URI without the trailing slash isn't equivalent to
 the one with it. It's true that in many cases, people assume it is
 equivalent but it doesn't have to.

 Also, relative URIs can be expressed in the same way if the ends with a
 slash or not, leading to further routing issues. The only way we found to
 clean that is to force the client to redirect itself to the URI with a
 slash. However, it isn't something we should do automatically.

 BTW, there is a related RFE:

 Improve matching of directory URIs
 http://restlet.tigris.org/issues/show_bug.cgi?id=532

  Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com



  --
 *De :* Paul Austin [mailto:mail-li...@revolsys.com]
 *Envoyé :* mardi 7 avril 2009 21:58
 *À :* discuss@restlet.tigris.org
 *Objet :* Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping
 SpringBeanRouter to /

 Here is a class which fixes the issue. Probably a better solution would be
 to change the Route class so that if the remainingPart is  it sets it to
 / before doing the regex matching. On a related note is it possible to
 force exact matching so that say /apps would be mapped but not /apps/xyz?

 public class RootSpringBeanRouter extends SpringBeanRouter {
 @Override
 public void handle(Request request, Response response) {
 Reference resourceRef = request.getResourceRef();
 if (resourceRef.getRemainingPart().equals()) {
 resourceRef.addSegment();
 }
 super.handle(request, response);
 }
 }


 On Tue, Apr 7, 2009 at 12:27 PM, Paul Austin mail-li...@revolsys.comwrote:

 In my project I am deploying an application as a war file. The root of the
 web application /* is mapped to the RestletFrameworkServlet so that all
 handling is performed by Restlet.

 servlet
 servlet-namebpf/servlet-name

 servlet-classcom.noelios.restlet.ext.spring.RestletFrameworkServlet/servlet-class
 /servlet

 servlet-mapping
 servlet-namebpf/servlet-name
 url-pattern/*/url-pattern
 /servlet-mapping

 The root restlet is a SpringBeanRouter and I have a mapping for / to a
 resource as shown below.

 bean id=root class=org.restlet.ext.spring.SpringBeanRouter /

 bean
 name=/
 id=rootResource
 scope=prototype
 class=myResourceClass
 /

 The war is deployed to /ws on my server.

 If I access /ws I get an Restlet status page error saying The server has
 not found anything matching the request URI but if I use /ws/ it works
 correctly.

 I tried mapping to  to see if that would work and it gives the same
 behaviour.

 Is it possible to modify the router so that the root resource does not
 need the trailing slash?

 Cheers,
 Paul




--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1597991

[1.1.3] Tomcat + RestletFrameworkServlet mapping SpringBeanRouter to /

2009-04-07 Thread Paul Austin
In my project I am deploying an application as a war file. The root of the
web application /* is mapped to the RestletFrameworkServlet so that all
handling is performed by Restlet.

  servlet
servlet-namebpf/servlet-name

servlet-classcom.noelios.restlet.ext.spring.RestletFrameworkServlet/servlet-class
  /servlet

  servlet-mapping
servlet-namebpf/servlet-name
url-pattern/*/url-pattern
  /servlet-mapping

The root restlet is a SpringBeanRouter and I have a mapping for / to a
resource as shown below.

 bean id=root class=org.restlet.ext.spring.SpringBeanRouter /

  bean
name=/
id=rootResource
scope=prototype
class=myResourceClass
  /

The war is deployed to /ws on my server.

If I access /ws I get an Restlet status page error saying The server has
not found anything matching the request URI but if I use /ws/ it works
correctly.

I tried mapping to  to see if that would work and it gives the same
behaviour.

Is it possible to modify the router so that the root resource does not need
the trailing slash?

Cheers,
Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1582399

Re: Restlet 1.2 M2 released [throw previous email away]

2009-04-07 Thread Paul Austin
Jerome,

I would be happy if users can choose to either use the extensions or the
mime-type where the extension is currently used. Consider a web service
which is designed to be used either from a web browser when the media=
parameter is used or from a Java client where the accept header can be set.
In the documentation for this web service it would be useful to be able to
list only the mime types. Rather than saying, if you use the media parameter
use the keyword xhtml or if you use the accept header use
application/xhtml+xml.

Another thing to consider is if you describe your service using WADL you
would be using the mime types so the client using the media= parameter would
need to know the mapping to/from mime type to media type. i.e. you need a
public extensions registry.

Just some thoughts,
Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1581398

Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping SpringBeanRouter to /

2009-04-07 Thread Paul Austin
Here is a class which fixes the issue. Probably a better solution would be
to change the Route class so that if the remainingPart is  it sets it to
/ before doing the regex matching. On a related note is it possible to
force exact matching so that say /apps would be mapped but not /apps/xyz?

public class RootSpringBeanRouter extends SpringBeanRouter {
  @Override
  public void handle(Request request, Response response) {
Reference resourceRef = request.getResourceRef();
if (resourceRef.getRemainingPart().equals()) {
  resourceRef.addSegment();
}
super.handle(request, response);
  }
}


On Tue, Apr 7, 2009 at 12:27 PM, Paul Austin mail-li...@revolsys.comwrote:

 In my project I am deploying an application as a war file. The root of the
 web application /* is mapped to the RestletFrameworkServlet so that all
 handling is performed by Restlet.

   servlet
 servlet-namebpf/servlet-name

 servlet-classcom.noelios.restlet.ext.spring.RestletFrameworkServlet/servlet-class
   /servlet

   servlet-mapping
 servlet-namebpf/servlet-name
 url-pattern/*/url-pattern
   /servlet-mapping

 The root restlet is a SpringBeanRouter and I have a mapping for / to a
 resource as shown below.

  bean id=root class=org.restlet.ext.spring.SpringBeanRouter /

   bean
 name=/
 id=rootResource
 scope=prototype
 class=myResourceClass
   /

 The war is deployed to /ws on my server.

 If I access /ws I get an Restlet status page error saying The server has
 not found anything matching the request URI but if I use /ws/ it works
 correctly.

 I tried mapping to  to see if that would work and it gives the same
 behaviour.

 Is it possible to modify the router so that the root resource does not need
 the trailing slash?

 Cheers,
 Paul


--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1582838

Easy way to serve static content

2009-04-06 Thread Paul Austin
Is there an easy way to configure the SpringBeanRouter to use files within a
war file? For example /css would be mapped to /css/* resources within the
war file.

I was trying the following but I could not get hold of the ServletContext

public class StaticWarResource extends Resource {
  private static final ListVariant VARIANTS = Arrays.asList(new
Variant(MediaType.ALL));

  public StaticWarResource() {
setVariants(VARIANTS);
  }

  @Override
  public Representation represent(Variant variant) throws ResourceException
{

ServletContextAdapter context = (ServletContextAdapter)getContext();
ServletContext servletContext = context.getServletContext();

MediaType mediaType = variant.getMediaType();
Request request = getRequest();

Reference reference = request.getResourceRef();
String path = reference.getRelativePart(true);
ServletWarEntity entity = new ServletWarEntity(servletContext, path);
return entity.getRepresentation(mediaType, 1);
  }

}

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1562306

Re: Restlet 1.1.3 + Spring + servlet resource is being re-used

2009-04-06 Thread Paul Austin
Paul Austin
President/CEO
Revolution Systems Inc.

+1 (604) 288-4304 x201
www.revolsys.com


On Mon, Apr 6, 2009 at 9:44 AM, Paul Austin paul.aus...@revolsys.comwrote:

 I am using the RestletFrameworkServlet with the SpringBeanRouter to serve
 up resources. The resource in question will return a static file within a
 web application.

 I noticed that the images on a web page served by this resource return the
 incorrect image. So added a log statement in the init method and in the
 represent method. This debug prints out the instance of the resource and the
 image being requested. As you can see from below the same resource instance
 is being used multiple times (@99bc71) and in the last few you can see that
 there is a threading issue as two requests overlap and the request for the
 blu_top.gif image is actually returning the crumbs.gif image.

 According to the docs resources are not shared so don't have to be thread
 safe (i.e. can contain state).

 Does restlet re-use the same resource instance for multiple requests in the
 same thread? What happens if the browser uses a persistent HTTP connection?

 com.revolsys.restlet.staticwarresou...@e9df24:
 http://localhost:8080/ws/css/bcgov.css
 com.revolsys.restlet.staticwarresou...@38e7bb:
 http://localhost:8080/ws/scripts/ws.js
 com.revolsys.restlet.staticwarresou...@e9df24:/css/bcgov.css
 com.revolsys.restlet.staticwarresou...@38e7bb:/scripts/ws.js
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/bc_sun_logo_horiz.gif
 com.revolsys.restlet.staticwarresou...@99bc71
 :/images/bc_sun_logo_horiz.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/icon_help.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/icon_help.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/left_blue_arrow.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/left_blue_arrow.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/nav_grey_bottom.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/nav_grey_bottom.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/blue_top.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/crumbs.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/crumbs.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/crumbs.gif




 Paul Austin
 President/CEO
 Revolution Systems Inc.

 +1 (604) 288-4304 x201
 www.revolsys.com


--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1563029

Re: Restlet 1.1.3 + Spring + servlet resource is being re-used

2009-04-06 Thread Paul Austin
Actually ignore this one I forgot to set the scope on the spring beans to
prototype.

Paul

On Mon, Apr 6, 2009 at 9:45 AM, Paul Austin mail-li...@revolsys.com wrote:


 Paul Austin
 President/CEO
 Revolution Systems Inc.

 +1 (604) 288-4304 x201
 www.revolsys.com


 On Mon, Apr 6, 2009 at 9:44 AM, Paul Austin paul.aus...@revolsys.comwrote:

 I am using the RestletFrameworkServlet with the SpringBeanRouter to serve
 up resources. The resource in question will return a static file within a
 web application.

 I noticed that the images on a web page served by this resource return the
 incorrect image. So added a log statement in the init method and in the
 represent method. This debug prints out the instance of the resource and the
 image being requested. As you can see from below the same resource instance
 is being used multiple times (@99bc71) and in the last few you can see that
 there is a threading issue as two requests overlap and the request for the
 blu_top.gif image is actually returning the crumbs.gif image.

 According to the docs resources are not shared so don't have to be thread
 safe (i.e. can contain state).

 Does restlet re-use the same resource instance for multiple requests in
 the same thread? What happens if the browser uses a persistent HTTP
 connection?

 com.revolsys.restlet.staticwarresou...@e9df24:
 http://localhost:8080/ws/css/bcgov.css
 com.revolsys.restlet.staticwarresou...@38e7bb:
 http://localhost:8080/ws/scripts/ws.js
 com.revolsys.restlet.staticwarresou...@e9df24:/css/bcgov.css
 com.revolsys.restlet.staticwarresou...@38e7bb:/scripts/ws.js
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/bc_sun_logo_horiz.gif
 com.revolsys.restlet.staticwarresou...@99bc71
 :/images/bc_sun_logo_horiz.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/icon_help.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/icon_help.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/left_blue_arrow.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/left_blue_arrow.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/nav_grey_bottom.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/nav_grey_bottom.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/blue_top.gif
 com.revolsys.restlet.staticwarresou...@99bc71:
 http://localhost:8080/ws/images/crumbs.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/crumbs.gif
 com.revolsys.restlet.staticwarresou...@99bc71:/images/crumbs.gif




 Paul Austin
 President/CEO
 Revolution Systems Inc.

 +1 (604) 288-4304 x201
 www.revolsys.com




--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1563066

Wrap a representation

2009-04-03 Thread Paul Austin
Is there an easy way to create a filter which would take the representation
returned from all resources and if it had a specific media type it would
wrap the representation with header and footer content.

What I want to be able to do with my web services is create a navigable HTML
view of all resources. So if the media type was HTML the representation
would be a HTML document without the header and footer. The filter then
could wrap this is an application specific template which gives the
branding.

Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1536704

Re: Restlet 1.2 M2 released [throw previous email away]

2009-04-02 Thread Paul Austin
An alternative would be to have a MimeType class  which had String constant
values for all the common MediaTypes, then you would only need to use
strings if you had a non common media type.

One other thing I've noticed that in some places the mime type is shortened
(e.g. xml instead of text/xml). Is it possible to use the full mime type
across the API if required?

Paul

On Thu, Apr 2, 2009 at 9:13 AM, Stephan Koops stephan.ko...@web.de wrote:

 Stephan Koops schrieb:
  Jonathan Hall schrieb:
 
  Shame you can't have @Get(MediaType.TEXT_HTML). I don't know.
 
  Would it work to change MediaType from class to an enum? That could
  work, but I'm not sure

 While sending the email I remembered: You can't add new MediaTypes this
 way, so we could forget my previous idea.

 best regards
   Stephan

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1520779


--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1520903

Principal from HttpServletRequest

2009-03-20 Thread Paul Austin
Is it possible to get the Princpal object from the HttpServletRequest
without getting access to the HttpServletRequest itself. I'm using spring
security as my authentication layer which sets a Principal in a wrapper of
the request.

Cheers,
Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1366843

Re: Set content-location header ??

2009-03-16 Thread Paul Austin
You also have so set the downloadable flag

Paul

On 14-Mar-09, at 3:42 PM, Ty wrote:

 Hi,
 Restlet (1.2M) is refusing to set the content-location header and I  
 can't seem to find a method that will let me set it.  Does anyone  
 know how to set the content-location header?

 Here's the code that I have tried:

 // *** Try setting the Content-Location header: restlet refuses with  
 a log warning! ***
 SeriesParameter headers = new Form();
 headers.add(Content-Location, request.getOriginalRef().toString());
 response.getAttributes().put(org.restlet.http.headers, headers);

 // Set the location header: this works
 response.setLocationRef(locaationURI);

 It seems like my code is working but restlet doesn't want to let me  
 set the content-location header.  It wants me to use an API method;  
 but I can't find one.  Any suggestions?

 Thanks,
 T

 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1323618

Paul Austin
President/CEO
Revolution Systems Inc.

+1 (604) 288-4304 x201
www.revolsys.com

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1326815


Re: Managing a JPA/Hibernate session

2009-03-06 Thread Paul Austin
Jerome,

Thanks, did you add it in a finally block so that it always gets  
executed even if there is an exception.

Paul

On 6-Mar-09, at 10:36 AM, Jerome Louvel wrote:

 Hi Paul,

 You made a good point regarding the afterSend and beforeSend method.  
 So, I
 decided to change their behavior. Those methods are now invoked all  
 the
 time, even if there is no entity sent (null will be passed).

 Changes in SVN trunk.

 Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com


 -Message d'origine-
 De : blackh...@collab.net [mailto:blackh...@collab.net]
 Envoyé : jeudi 26 février 2009 17:31
 À : discuss@restlet.tigris.org
 Objet : RE: Re: Managing a JPA/Hibernate session

 I have been looking more into the issue and have found some more  
 additional
 issues.

 1. As you suggested filters do not work as they are completed before  
 the
 response is sent to the client.
 2. The ConnectorService also does not work as the afterSend method  
 is only
 called if there was an entity and there were no IO exceptions in  
 streaming
 the result to the client. The result of this that you will have  
 dangling
 EntityManagers as they are not closed.

 What is required is an interceptor/filter which can wrap the entire  
 call to
 the restlet chain which wraps the handle and commit calls. This  
 would allow
 you to do setup before the restlet calls and cleanup after the  
 response has
 been committed. The developer then can include a finally block so  
 that the
 cleanup is also performed after any exceptions.

 Paul

 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=12337
 13

 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1278438

Paul Austin
President/CEO
Revolution Systems Inc.

+1 (604) 288-4304 x201
www.revolsys.com

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1278453


Re: Restlet 1.1.3

2009-02-28 Thread Paul Austin
Jerome,

It might just be the maven pom. See in bold below.

cat org.restlet.ext.spring-1.1.3.pom
project
modelVersion4.0.0/modelVersion
groupIdorg.restlet/groupId
artifactIdorg.restlet.ext.spring/artifactId
version1.1.3/version
dependencies
   dependency
  groupIdorg.restlet/groupId
  artifactIdorg.restlet/artifactId
  version1.1.3/version
   /dependency
   dependency
  groupIdorg.springframework/groupId
  artifactIdspring-core/artifactId
  version2.5/version
   /dependency
   dependency
  groupIdorg.springframework/groupId
  artifactIdspring-context/artifactId
  version2.5/version
   /dependency
   dependency
  groupIdorg.springframework/groupId
  artifactIdspring-beans/artifactId
  version2.5/version
   /dependency
   dependency
  groupIdorg.springframework/groupId
  artifactIdspring-web/artifactId
  version2.5/version
   /dependency
   dependency
  groupIdorg.springframework/groupId
  artifactIdspring-webmvc/artifactId
  version2.5/version
   /dependency
/dependencies

nameSpring support/name
descriptionIntegration with Spring Framework./description
licenses
   license
  nameCDDL license/name
  urlhttp://www.opensource.org/licenses/cddl1.php/url
   /license
   license
  nameLGPL license/name
  url
 http://www.opensource.org/licenses/lgpl-license.php
  /url
   /license
/licenses
/projectc

On 28-Feb-09, at 8:28 AM, Jerome Louvel wrote:

 Hi Paul,

 We already upgraded to Spring 2.5.6 in 1.1.2 :)

 Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com


 -Message d'origine-
 De : Paul Austin [mailto:paul.aus...@revolsys.com]
 Envoyé : jeudi 26 février 2009 21:43
 À : discuss@restlet.tigris.org
 Objet : Re: Restlet 1.1.3

 For the next release can you upgrade spring to 2.5.6?

 Thanks,
 Paul

 On 26-Feb-09, at 12:31 PM, Thierry Boileau wrote:

 Hello all,

 Restlet 1.1.3 has been released and is available at this address
 http://www.restlet.org/downloads/.
 The public maven repository has also been updated.
 Javadocs, user guide, etc. are available from this address:
 http://www.restlet.org/documentation/1.1/

 Best regards,
 Thierry Boileau

 ps:
 Here is the list of changes:

   - Bugs fixed
  - Fixed Regex issue in Template with fixed variables.
Contributed by Bruno Dumon.
  - Fixed bug in ReadableRepresentation preventing channel from
closing. Reported by Janne Husberg.
  - Fixed bug with jSSLutils integration. Reported by Dan Noble
and fixed by Bruno Harbulot.
  - Handler is now capable of discovering allowed methods, even
in protected Handler subclasses. Reported by Leigh Klotz.
  - Fixed the inclusion test of media types when one contains a
*+.
  - Fixed wrong computed content-length header when encoding
representations using the Encoder. Reported by Tamas
Cservenak.
  - Fixed wrong computed content-location header generated by
the DirectoryResource. Reported by David Fogel.
  - Fixed potential bug with EncodeRepresentation when only
Identity applies.
   - Misc
- Upgraded JAXB to version 2.1.9.
- Upgraded Grizzly to version 1.9.5.

 --
 http://restlet.tigris.org/ds/viewMessage.do? 
 dsForumId=4447dsMessageId
 =1234715

 Paul Austin
 President/CEO
 Revolution Systems Inc.

 +1 (604) 288-4304 x201
 www.revolsys.com

 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=12347
 58

 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1245546

Paul Austin
President/CEO
Revolution Systems Inc.

+1 (604) 288-4304 x201
www.revolsys.com

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1248042

Re: Restlet WADL samples

2009-02-20 Thread Paul Austin
Here is an example of adding parameters

  protected void describePost(MethodInfo info) {
super.describePost(info);

info.addRequestRepresentation(new
Variant(MediaType.MULTIPART_FORM_DATA));

info.addRequestParameter(numRequests, false, xsd:long,
  ParameterStyle.QUERY,
  The number of requests to be processed in this Batch Job);
info.addRequestParameter(
  inputDataContentType,
  true,
  xsd:string,
  ParameterStyle.QUERY,
  The MIME type of the input data specified by an inputData or
inputDataUrl parameter);
info.addRequestParameter(inputDataUrl, false, xsd:anyURI,
  ParameterStyle.QUERY, The URL to the input data);
info.addRequestParameter(inputData, false, xsd:base64Binary,
  ParameterStyle.QUERY, The inline input data);
}

So basically you override the method, call the super class version of the
method and then modify the object with your extensions.

Paul

On Fri, Feb 20, 2009 at 11:12 AM, John Wismar john.wis...@autozone.comwrote:

 Are there any samples available that show how to use WadlApplication and
 WadlResource to generate a customized WADL document?  I have the bare
 minimum implemented, where I derive from these classes, and get a minimal
 WADL doc that describes the URIs, and mentions the GET operations for a
 resource, but I don't understand the API well enough to customize the
 output, for example, by specifying possible error returns.

 For example, if I have a resource that can return HTML messages for errors
 (400, 401 or 404), or XML for redirection (300 or 303), or a normal 200,
 what steps do I need to do?  Clearly I need to override
 WadlResource.describeGet(), but beyond that, I get somewhat lost.

 Thanks for any pointers!

 
 John Wismar
 john.wis...@autozone.com

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1200079


--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1200094

Re: Warning and SocketException when using 1.1.2, built-in server, and FreeMarker

2009-02-19 Thread Paul Austin
Avi,

I found the same issue the other day and have reported a bug.

http://restlet.tigris.org/issues/show_bug.cgi?id=71
Paul

On Thu, Feb 19, 2009 at 7:54 PM, Avi Flax a...@arc90.com wrote:

 Hello all,

 When I start up my app, and make the first request to it, I'm seeing
 this in my console:

 
 Feb 19, 2009 10:37:40 PM com.noelios.restlet.http.StreamServerCall complete
 WARNING: Unable to shutdown server socket
 java.net.SocketException: Socket is not connected
at sun.nio.ch.SocketChannelImpl.shutdown(Native Method)
at
 sun.nio.ch.SocketChannelImpl.shutdownInput(SocketChannelImpl.java:583)
at sun.nio.ch.SocketAdaptor.shutdownInput(SocketAdaptor.java:360)
at
 com.noelios.restlet.http.StreamServerCall.complete(StreamServerCall.java:102)
at
 com.noelios.restlet.http.HttpServerConverter.commit(HttpServerConverter.java:414)
at
 com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:148)
at
 com.noelios.restlet.http.StreamServerHelper$ConnectionHandler.run(StreamServerHelper.java:86)
at
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
at
 java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at
 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:613)
 

 I've confirmed that this only occurs when using the built-in server
 and returning a TemplateRepresentation. When I return a
 StringRepresentation the warning does not occur. When I switch to
 Jetty the warning does not occur. And again, this only occurs for the
 first request. Subsequent requests do not cause a warning to occur.

 Here's the Groovy test case I've got it boiled down to:

 
 class HelloNameRestlet extends Restlet
 {
public void handle(Request request, Response response)
{
def data = [name:world]
response.entity = new
 TemplateRepresentation('hello_name.txt.fm', new Configuration(), data,
 MediaType.TEXT_PLAIN)
}
 }

 new Server(Protocol.HTTP, 3000, new HelloNameRestlet()).start()
 

 Not sure if it matters, but I'm running my tests on an Intel Mac
 running OS X 10.5.6 and all updates. I've duplicated this issue with
 Java 1.5/32 and 1.6/64, and with Groovy 1.5.6 and 1.6.0.

 I'm thinking this might be pointing to a minor bug somewhere, but I
 couldn't begin to pinpoint where. I'm hoping someone else can!

 Thanks,
 Avi

 --
 Avi Flax » Lead Technologist » Partner » Arc90 » http://arc90.com

 --

 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1196234


--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1196249

Re: Managing a JPA/Hibernate session

2009-02-18 Thread Paul Austin
Below is my solution which is based on a similar ServletFilter from the
SpringFramework. You will need to set the entityManagerFactory before using
this. I normall have that configured in spring and get a reference to this
filter bean from the context.

package com.revolsys.restlet;

import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceException;

import org.apache.log4j.Logger;
import org.restlet.Filter;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.orm.jpa.EntityManagerFactoryUtils;
import org.springframework.orm.jpa.EntityManagerHolder;
import
org.springframework.transaction.support.TransactionSynchronizationManager;

public class OpenEntityManagerFilter extends Filter {
  private static final Logger logger =
Logger.getLogger(OpenEntityManagerFilter.class);

  private EntityManagerFactory entityManagerFactory;



  protected int beforeHandle(Request request, Response response) {

if (TransactionSynchronizationManager.hasResource(entityManagerFactory))
{
  request.getAttributes().put(this.toString(), Boolean.TRUE);
} else {
  logger.debug(Opening JPA EntityManager in OpenEntityManagerFilter);
  try {
EntityManager em = entityManagerFactory.createEntityManager();
TransactionSynchronizationManager.bindResource(entityManagerFactory,
  new EntityManagerHolder(em));
  } catch (PersistenceException ex) {
throw new DataAccessResourceFailureException(
  Could not create JPA EntityManager, ex);
  }
}
return super.beforeHandle(request, response);
  }

  protected void afterHandle(Request request, Response response) {
MapString, Object attributes = request.getAttributes();
if (attributes.get(this.toString()) != Boolean.TRUE) {
  EntityManagerHolder emHolder =
(EntityManagerHolder)TransactionSynchronizationManager.unbindResource(entityManagerFactory);
  logger.debug(Closing JPA EntityManager in OpenEntityManagerFilter);

EntityManagerFactoryUtils.closeEntityManager(emHolder.getEntityManager());
}
  }

  public EntityManagerFactory getEntityManagerFactory() {
return entityManagerFactory;
  }

  public void setEntityManagerFactory(EntityManagerFactory
entityManagerFactory) {
this.entityManagerFactory = entityManagerFactory;
  }
}



On Wed, Feb 18, 2009 at 6:45 AM, Jerome Louvel jerome.lou...@noelios.comwrote:

 Hi guys,

 This is such a hook available. See the ConnectorService#afterSend method:

 http://www.restlet.org/documentation/snapshot/api/org/restlet/service/ConnectorService.html#afterSend(org.restlet.resource.Representhttp://www.restlet.org/documentation/snapshot/api/org/restlet/service/ConnectorService.html#afterSend%28org.restlet.resource.Represent
 ation)

 Hope this helps!

 Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com


 -Message d'origine-
 De : Michael Terrington [mailto:mich...@terrington.id.au]
 Envoye : mercredi 18 fevrier 2009 12:23
 A : discuss@restlet.tigris.org
 Objet : Re: Managing a JPA/Hibernate session

 Hi Peter,

 I recently encountered this problem myself.  I ended up creating a
 Representation wrapper that would close my EM after the call to write.
  The code [1] is part of restlet-jpa [2].

 Regards,
 Michael.

 [1] -
 http://trac.sarugo.org/restlet-jpa/browser/trunk/src/main/java/org/sarugo/restlet/jpa/TransactionFilter.java

 [2] - http://trac.sarugo.org/restlet-jpa/

 On Wed, Feb 18, 2009 at 10:22 AM, Peter Becker pbec...@itee.uq.edu.au
 wrote:
  Hello,
 
  I'm using Restlet above a JPA persistence layer with Hibernate as
 provider.
  That works reasonably well, but unfortunately I haven't found a way to
  handle the persistence sessions properly.
 
  What I would like to see is that a new session is opened whenever needed
 and
  is closed after all request processing is done. This is my current
 attempt:
 
  public class EntityManagerFilter extends Filter implements
  EntityManagerSource {
 
 private final EntityManagerFactory emf;
 private final ThreadLocalEntityManager entityManagerTL = new
  ThreadLocalEntityManager();
 
 public EntityManagerFilter(Context context, Restlet next,
  EntityManagerFactory emf) {
 super(context, next);
 this.emf = emf;
 }
 
 public EntityManagerFilter(Context context, EntityManagerFactory emf)
 {
 super(context);
 this.emf = emf;
 }
 
 public EntityManagerFilter(EntityManagerFactory emf) {
 this.emf = emf;
 }
 
 public EntityManager getEntityManager() {
 // we lazily initialize in case the entity manager is not actually
  needed
 // by a request
 EntityManager entityManager = entityManagerTL.get();
 if(entityManager == 

[Restlet] ?media= only available for registered types

2009-02-17 Thread Paul Austin
I've been looking at the TunnerlFilter and have noticed that the
?media=mediaType query string extension only works if the media type is
registered as a MetadataExtension with the the MetadataService. Is this by
design?Or would it be possible if a metadata entry was not found to set the
mediaType based on the value passed in?

Cheers,
Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1179945

Re: Plugable JAXBContext

2009-01-28 Thread Paul Austin
Jerome,

Thanks, when I get back from my vacation I'll start the discussion on  
the dev list.

Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1063257


Re: JAX-RS @Context for HttpServletRequest

2009-01-28 Thread Paul Austin
I've added the issue.

http://restlet.tigris.org/issues/show_bug.cgi?id=722

Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1063195

JAX-RS @Context for HttpServletRequest

2009-01-27 Thread Paul Austin
The Restlet JAX-RS implementation throws an exception for the following when
a POST request is performed against it. As far as I can see from the spec
this should be allowed. If the @Context is omitted then a 415 response is
returned instead.

@POST
@Path(/a/path)
public Response post(@Context HttpServletRequest request)

Jan 27, 2009 9:35:27 AM
org.restlet.ext.jaxrs.internal.wrappers.ResourceClass
initResourceMethodsAndLocators
WARNING: Ignore method public javax.ws.rs.core.Response
ca.bc.gov.bpf.cxf.BpfService.postJob(javax.servlet.http.HttpServletRequest):
An annotated parameter of the resource method public
javax.ws.rs.core.Response
ca.bc.gov.bpf.cxf.BpfService.postJob(javax.servlet.http.HttpServletRequest)
is has an illegal type
org.restlet.ext.jaxrs.internal.exceptions.IllegalMethodParamTypeException:
interface javax.servlet.http.HttpServletRequest must not be annotated with
@Context
at
org.restlet.ext.jaxrs.internal.wrappers.params.ContextInjector.getInjectObject(ContextInjector.java:303)
at
org.restlet.ext.jaxrs.internal.wrappers.params.ParameterList.init(ParameterList.java:917)
at
org.restlet.ext.jaxrs.internal.wrappers.params.ParameterList.init(ParameterList.java:1046)
at
org.restlet.ext.jaxrs.internal.wrappers.AbstractMethodWrapper.init(AbstractMethodWrapper.java:107)
at
org.restlet.ext.jaxrs.internal.wrappers.ResourceMethod.init(ResourceMethod.java:140)
at
org.restlet.ext.jaxrs.internal.wrappers.ResourceClass.initResourceMethodsAndLocators(ResourceClass.java:384)
at
org.restlet.ext.jaxrs.internal.wrappers.ResourceClass.init(ResourceClass.java:159)
at
org.restlet.ext.jaxrs.internal.wrappers.RootResourceClass.init(RootResourceClass.java:131)
at
org.restlet.ext.jaxrs.internal.wrappers.PerRequestRootResourceClass.init(PerRequestRootResourceClass.java:73)
at
org.restlet.ext.jaxrs.internal.wrappers.ResourceClasses.getRootClassWrapper(ResourceClasses.java:227)
at
org.restlet.ext.jaxrs.internal.wrappers.ResourceClasses.addRootClass(ResourceClasses.java:102)
at org.restlet.ext.jaxrs.JaxRsRestlet.addClass(JaxRsRestlet.java:256)
at org.restlet.ext.jaxrs.JaxRsApplication.add(JaxRsApplication.java:194)
at org.restlet.ext.jaxrs.JaxRsApplication.add(JaxRsApplication.java:142)

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1059669

Re: Restlet vs other 'rest' frameworks questions/views

2009-01-23 Thread Paul Austin
Matt,

When you send a HTTP error response you can include an XML body as  
well. So you get the best of both worlds.

Paul
On 22-Jan-09, at 10:32 AM, postmas...@tigris.org wrote:

 Hi Paul

 Thanks for the advice. You can easily to the 'content type' with the  
 TunnelService and it works just fabulous. I got that. We are not  
 100% if we are going to use WADL and I think they is some TOS  
 requirement to be in every response. That was the entire 'wrapper'  
 things. Also. As far as errors go there was a desire to have it in  
 the xml if the error was say a missing param or or something. The  
 desire was to have something like

 errors
  error
 code999/code
 messagestart date is before end date/message
  /error
 /errors

 There was totally some desire to have the easiest and most verbose  
 way to manage errors for the user as these 'restful' requests are  
 going to have many many many optional params and some might conflict  
 with eachother so the messages have to have some easy and quick  
 visual rep to the user. This is not my ideal but I am not writing  
 the recs. I will look into returning http error response as well!

 Thanks for the advice.

 matt

 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1043422

Paul Austin
President/CEO
Revolution Systems Inc.

+1 (604) 288-4304 x201
www.revolsys.com

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1044878


Plugable JAXBContext

2009-01-23 Thread Paul Austin
Would it be possible to modify the JaxbRepresentation to support passing the
a JAXB_CONTEXT_FACTORY property with the name of the factory to create the
context. That class must have the following method.

public static JAXBContext createContext(String, ClassLoader) throws
JAXBException;

This way you can easily plug-in say Jersey's JSONJAXContext to get
Object-JSON mapping.

Behind the scenes you would need to modify the getContext methods to
maintain a separate cache for each context factory.

Another alternate method would be to modify the class to have a static
method to set the context factory to be used for a specific MIME type. With
this approach when you use the MimeType, Object constructor it would use the
appropriate JaxbContext factory for that mime type.

Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1044973

Re: Restlet vs other 'rest' frameworks questions/views

2009-01-22 Thread Paul Austin
Matt,

You can use JAX-RS on top of Restlet, so you get similar functionality  
as Jersey but with the benefit of being able to write a Restlet for  
any unusual cases.

In terms of selecting different response formats you can use the  
accept HTTP header to allow users to specify the MIME type (e.g. text/ 
plain) and the Restlet or JAX-RS can do content negotiation. I think  
there is a way where the accept can be specified as a query string  
parameter for clients who can't set HTTP headers.

I'd personally avoid using a wrapper, if there is an error return a  
HTTP error response. For the terms of use add that to a WADL document  
describing the resources and then just include the body direct in the  
response.

Paul


On 22-Jan-09, at 10:02 AM, postmas...@tigris.org wrote:

 Hi There

 This is more of a holistic ?? on restlet. I have been using it for  
 months and now we have a 'restful' project at work. I.e. our first  
 one. I am pushing hard for restlet but we also have some people who  
 want to try jersey or even write some layer on top of spring mvc or  
 look at struts 2...

 Here are my requirements.

 1) All our responses will have some 'envelope' in terms of the  
 response data. I.e. if we serve xml all responses would have a  
 simliar format. e.g.

 company
  tos TERM OF SERVICE FOR ALL RESPONSES /tos
  error codes
  Here would be error codes like 'param not found'
  error codes
 response
   // concrete data here based on java object type
 /response
 /company

 I did this quite easily by creating a 'template' resources that  
 handles a lot of the uniform plumbing (error catching, creating  
 response object) and subclassed with concrete resources that would  
 return the 'real data' via some template method. This worked lovely.  
 I also used spring which was great as I could have state in my  
 resources...

 Another desire is to parse the return type based on some uri param.  
 i.e.

 //mywsite/cars/123 - return xml default
 //mywsite/cars/123?format=txt - return txt if supported by  
 resource.. and NOT
 //mywsite/cars/123.xml


 Once again this shined with the great tunnel service.. I also used  
 jibx on my domain models and once again used the Jibx Representation  
 and it shined.

 The one down side my co-workers see is the lack of binding url  
 params to some kind of bean element (like Struts, spring mvc etc)  
 and that we would have to write our own.

 They are also curious about the 'scale' of restlet (if for example  
 as a stand alone app) and the number of concurrent requests we can  
 take at any given time. I will poke around at the code too see if i  
 can dig up anything.

 Anyways.. This was a long rant but if anybody has some thoughts  
 about how to convince my work to use RESTLET over others that would  
 be great.

 In advance, thanks.

 matt

 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1043393

Paul Austin
President/CEO
Revolution Systems Inc.

+1 (604) 288-4304 x201
www.revolsys.com

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1043403


WADL and JAX-RS

2009-01-15 Thread Paul Austin
I was wondering if there are any plans to add auto WADL generation for JAX-RS 
applications? Or is this already implemented in a newer version than 1.1?

In general what is the current status of the JAX-RS support is it experimental 
or more ready for prime time?

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1027511