Re: restlet noob: getting the CLAP (right)

2008-07-14 Thread Matt Brennan
Rob Heittman rob.heittman at solertium.com writes:
 
 I enthusiastically recommend using a 1.1 milestone or snapshot for any new
development.  The javadoc for ServerServlet says how to set a custom Component.
 (just like setting a custom Application, basically)  But you can't do that in
1.0.  I think the need to add extra client connectors and such was exactly what
drove that improvement to ServerServlet.

Rob,
   thanks for your help. the switch to the milestone (1.1) builds did the trick

cheers,

  matt



restlet noob: getting the CLAP (right)

2008-07-09 Thread Matt Brennan
Hi there,
 I am just hacking up my first restlet app. I'm really impressed so 
far. 

In addition to some resources served RESTfully, i'd also like to serve some
static comment of the classpath... and so have been trying a bunch of things to
expose a dir on the classpath without success so far. Any help appreciated!

env: restlet as war in jetty container.

web.xml:

   !-- Application class name --
   context-param
  param-nameorg.restlet.application/param-name
  param-value
 au.com.internode.udr2d2.SimpleUsageApplication
  /param-value
   /context-param

   !-- Restlet adapter --
   servlet
  servlet-nameRestletServlet/servlet-name
  servlet-class
 com.noelios.restlet.ext.servlet.ServerServlet
  /servlet-class
   /servlet

   !-- Catch all requests --
   servlet-mapping
  servlet-nameRestletServlet/servlet-name
  url-pattern/*/url-pattern
   /servlet-mapping

Restlet:
 public synchronized Restlet createRoot() {

Router router = new Router(getContext());

// Defines a default route with the URL format.
router.attachDefault(UsageFormatResource.class);

// Create a directory able to expose a hierarchy of files
Directory directory = new Directory(getContext(), clap://images/);
router.attach(directory);

// And add the
Route route = router.attach(SimpleUsageResource.URI_FORMAT,
SimpleUsageResource.class);
route.getTemplate().setMatchingMode(Template.MODE_EQUALS);

return router;
  }

--

The basic behavior is that a request to load:

http://localhost:8280/udr2d2/images/ajax-loader.gif

returns the default UsageFormatResource.class.

I tried adding the Protocol.CLAP and got a message to the client and server
connector list (this was a bit mindless - i'm not sure which i need! certainly
not both). And got a log message about the classpath loader not being loaded.

I've googled around a fair bit, read through the tute, looked through the Java
doc and tried rearranging ordering when creating the router. And eventually
thought: time to post.

Any help appreciated! :-)

  mattb



Re: restlet noob: getting the CLAP (right)

2008-07-09 Thread Matt Brennan
Forgot to add: in the war, the images directory sits at the top like:

 + WEB-INF
 +++ WEB-INF/web.xml
 + images
 +++ images/ajax-loader.gif

cheers,

  matt

(sorry for a few typos in the post!)
 



Re: restlet noob: getting the CLAP (right)

2008-07-09 Thread Matt Brennan
Rob Heittman rob.heittman at solertium.com writes:
 
 Be sure to do this in your Component constructor or another appropriate spot:
 getClients().add(Protocol.CLAP);

Rob,
   thanks very much for your reply. At you'll note, I am extending Application
and launching this with ServletServlet. That is, I'm not explicitly creating a
Component. So I have two follow ups:

1. If I do create a Component, how do I set up web.xml to launch the Component.

alternately,

2. If I stick to Application and ServletServlet, where is the appropriate spot
to add the Protocol.CLAP... in the context directives of web.xml?
 
 Then you want something like:
 Directory directory = new Directory(getContext(), clap://system/images/);

Ok, thanks - I will experiment. And thanks too for the info on caching.

Still poring through the APIs, examples, recipies and googling. Hmmm...
 
BTW, I am using: 1.0.10 (vice testing or svn suck).

Thanks again!

  mattb





Re: restlet noob: getting the CLAP (right)

2008-07-09 Thread Rob Heittman
I enthusiastically recommend using a 1.1 milestone or snapshot for any new
development.  The javadoc for ServerServlet says how to set a custom
Component.  (just like setting a custom Application, basically)  But you
can't do that in 1.0.  I think the need to add extra client connectors and
such was exactly what drove that improvement to ServerServlet.

BTW, I am using: 1.0.10 (vice testing or svn suck).