GroovyRestlet, a simple DSL for constructing Restlet application easily

2008-02-26 Thread keke
Hi All,

I am working a simple Groovy
Builderhttp://groovy.codehaus.org/GroovyMarkupfor Restlet, which
intends to create a complex Restlet application using a
simple shortcutting syntax. Also this builder is trying to support smooth
Spring integration.

Here is a short example

 builder.component{
 current.servers.add(protocol.HTTP, 8182)


 application(uri:){
 router{

 def guard = guard(uri:/docs, scheme:challengeScheme.HTTP_BASIC,

 realm:Restlet Tutorials)
 guard.secrets.put(scott, tiger.toCharArray())

 guard.next = directory(root:, autoAttach:false)


 restlet(uri:/users/{user}, handle:{req,resp-

 resp.setEntity(Account of user 
 \${req.attributes.get('user')}\,

 mediaType.TEXT_PLAIN)
 })


 restlet(uri:/users/{user}/orders, handle:{req, resp-

 resp.setEntity(Orders or user 
 \${req.attributes.get('user')}\,

 mediaType.TEXT_PLAIN)
 })


 restlet(uri:/users/{user}/orders/{order}, handle:{req, resp-

 def attrs = req.attributes
 def message = Order \${attrs.get('order')}\ for User 
 \${attrs.get('user')}\

 resp.setEntity(message, mediaType.TEXT_PLAIN)

 })
 }
 }
 }.start()

 For more detail, please visit project site
http://code.google.com/p/groovy-restlet/. More examples are provided.

I am not sure whether this would be a nice idea, any comments and
suggestions are highly appreciated.

-- 
We paranoid love life


Re: MetadataService extension check blocks PUT to file://

2008-02-26 Thread Thierry Boileau
Hello Marc,

we are still considering your suggestion. The problem is that some
classes that inherit from Metadata have no concern with Variants.

best regards,
Thierry Boileau

On Mon, Feb 25, 2008 at 9:31 PM, Thierry Boileau [EMAIL PROTECTED] wrote:
 Hi Marc,

  Oops, I've made a mistake when I wrote the mail. There is no
  distinction between a file with no extension and a file with unknown
  extensions.
  At the end of the process, the variant must be completed with either
  its natural metadata or some default ones. That's what I wanted to
  say.


By the way: the instance-of checking on the subclass of Metadata is a
bit messy (not very OO/polimorfism) I would suggest refactoring to adding:
  Thanks for the suggestion!

  best regards,
  Thierry Boileau




  On Mon, Feb 25, 2008 at 8:55 PM, Marc Portier [EMAIL PROTECTED] wrote:
  
  
Thierry Boileau wrote:
 Hello Marc,

 thanks a lot for tracking this bug. The first path has been chosen
  
cool, and thx.
  
  
 because of symetry, and because there is a distinction between a file
 having no extensions and a file having extensions not registered by
 the metadataService.

  
OK, but I'm unsure if I understand the distinction now.
In the current situation: when a file does not have an extension, then
no metadata will get loaded in the updateMetadata in LocalClientHelper
(and thus the default will be added anyway.)
  
I'm perfectly happy with this solution, but if you _do_ want that to
have a no-extension mapping to be distinct from the 'default', then I
would suggest to insert at line 105 something that
  
 // checks for the no extension-case
  if (tokens.length == 1)
  {
// and makes the association from
current = getMetadata();
  
// and then applying the media-type to the variant
  }
  
  
By the way: the instance-of checking on the subclass of Metadata is a
bit messy (not very OO/polimorfism) I would suggest refactoring to adding:
  
public void applyTo(Variant variant) to the MetaData class
  
you can either make it abstract there, or let it do nothing
  
and then have the specific subclasses make the correct implementation.
  
Inside LocalClientHelper this would replace the complete set of
if-else current instanceof testing with a mere
  
current.applyTo(variant)
  
  
HTH,
  
regards,
-marc=
  
  
  
 best regards,
 Thierry Boileau

 On Mon, Feb 25, 2008 at 5:16 PM, Marc Portier [EMAIL PROTECTED] wrote:
 Hi,

  I'm looking for a way to allow PUT on
  - file:/// URI's
  - to resources that have no extension
  - by pushing entities of type application/octet-stream
  (or whatever would be the metadata-service's default-mime)

  Currently the file-client-helper checks the metadata-consistency of 
 the
  file being put.

  This check *always* fails when the file doesn't have an extension at 
 all.


  To resolve, I see two possible paths:

  [1] let consistency check pass when:
extension doesn't yield a mapped type
AND the type being put matches the default.

  Looking at the MetadataService I see it holding a defaultMediaType, 
 but
  that one isn't considered when doing the consistency check. (While the
  default-language is, so this would put both in sync more.)


  [2] allow to assign metadata to the  extension (empty string)

  I'm not entirely sure how the meaning of 'default' relates to the
  meaning of 'no extension', if those have different meaning, then I 
 think
  this would be the appropriate way out.


  I'm tempted to go for [2], but wanted to check here if I'm not
  overlooking possible conflicts or yet more elegant solutions, so 
 please
  comment.

  As before, I'll be happy to provide the patch for this.

  regards,
  -marc=


  



RE: GroovyRestlet, a simple DSL for constructing Restlet application easily

2008-02-26 Thread Jerome Louvel

Hi keke!

This is excellent and will remind to some long Restlet users an experience
that was made on fluent builders early in API design. Lars are you around?
:) 

It seems to me that Groovy DSL are much more capable of supporting this
style of programming (DSL) than what we initially achieved with a pure Java
fluent API.

I have added Guillaume Laforge (Groovy manager) in copy. I remember a
presentation on DSL that he made recently to me and a group of open source
fellows. He might be interested in hosting your project as a Groovy
module... :-)

I've had a look at your converted tutorial examples and they look pretty
nice and compact:
http://code.google.com/p/groovy-restlet/wiki/RestletTutorialExample

Great work!

Best regards,
Jerome  

 -Message d'origine-
 De : keke [mailto:[EMAIL PROTECTED] 
 Envoyé : mardi 26 février 2008 09:56
 À : discuss@restlet.tigris.org
 Objet : GroovyRestlet, a simple DSL for constructing Restlet 
 application easily
 
 Hi All,
 
 I am working a simple Groovy Builder 
 http://groovy.codehaus.org/GroovyMarkup  for Restlet, which 
 intends to create a complex Restlet application using a 
 simple shortcutting syntax. Also this builder is trying to 
 support smooth Spring integration.
 
 Here is a short example
 
 
   builder.component{
   
   current.servers.add(protocol.HTTP, 8182)
   
   
   application(uri:){
   router{
   
   def guard = guard(uri:/docs, 
 scheme:challengeScheme.HTTP_BASIC, 
   
   
   realm:Restlet Tutorials)
   guard.secrets.put(scott, tiger.toCharArray())
   
   
   guard.next = directory(root:, autoAttach:false)
   
   
   
   restlet(uri:/users/{user}, handle:{req,resp-
   
   
   resp.setEntity(Account of user 
 \${req.attributes.get('user')}\,
   
   mediaType.TEXT_PLAIN)
   })
   
   
   restlet(uri:/users/{user}/orders, 
 handle:{req, resp-
   
   
   resp.setEntity(Orders or user 
 \${req.attributes.get('user')}\,
   
   mediaType.TEXT_PLAIN)
   })
   
   
   restlet(uri:/users/{user}/orders/{order}, 
 handle:{req, resp-
   
   
   def attrs = req.attributes
   def message = Order 
 \${attrs.get('order')}\ for User \${attrs.get('user')}\
   
   
   resp.setEntity(message, mediaType.TEXT_PLAIN)
   
   })
   }
   }
   }.start()
 
 For more detail, please visit project site 
 http://code.google.com/p/groovy-restlet/. More examples are provided.
 
 I am not sure whether this would be a nice idea, any comments 
 and suggestions are highly appreciated.
 
 -- 
 We paranoid love life 
 



Re: GroovyRestlet, a simple DSL for constructing Restlet application easily

2008-02-26 Thread Lars Heuer
Hi Jerome,

 This is excellent and will remind to some long Restlet users an experience
 that was made on fluent builders early in API design. Lars are you around?

:)

Nice project keke! :)

Best regards,
Lars
-- 
http://www.semagia.com



Re: Congratulation!Restlet: Official Developer's Guide to RESTful Web Applications in Java will be out!

2008-02-26 Thread Avi Flax
This is great news! I've pre-ordered five copies for Arc90. I'm really
looking forward to the book!

Avi

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

On 2/25/08, Jerome Louvel [EMAIL PROTECTED] wrote:
  For those wanting to pre-order, I've added an affiliated link on our books
  page:
  http://www.restlet.org/documentation/books


Re: First steps page

2008-02-26 Thread Leshek Fiedorowicz
Looks to me like in 1.1 HelloWorldResource missing is import for :
org.restlet.resource.ResourceException
  or
org.restlet.resource.*






First Steps - problems

2008-02-26 Thread Leshek
What am I doing wrong? 

I am trying to get the First Steps sample to work.  I am working from within 
IBM's RAD 7.0 environment, but that should be okay right
Working with Restlet 1.1 and 
http://www.restlet.org/documentation/1.1/firstSteps.  I am trying to get it 
to work in Application server container.  


I am getting:

[2/25/08 16:11:30:890 PST] 0022 WebAppA   SRVE0181I: 
[RestTestEAR#RestTestWar.war] [/RestTestWar] [Servlet.LOG]: RestletServlet: 
[Noelios Restlet Engine] - The ServerServlet couldn't invoke the constructor 
of the target class. Please check this class has a constructor with a single 
parameter of type Context. The empty constructor and the context setter will 
be used instead.: java.lang.NoSuchMethodException: 
com.ljf.restletTest.FirstStepsApplication.init(org.restlet.Context)
   at java.lang.Class.throwNoSuchMethodException(Class.java:275)
   at java.lang.Class.getConstructor(Class.java:315)
   at com.noelios.restlet.ext.servlet.ServerServlet.createApplication
(ServerServlet.java:166)
   at com.noelios.restlet.ext.servlet.ServerServlet.getApplication
(ServerServlet.java:313)
   at com.noelios.restlet.ext.servlet.ServerServlet.init
(ServerServlet.java:418)
   at javax.servlet.GenericServlet.init(GenericServlet.java:256)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.init
(ServletWrapper.java:185)
   at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.init
(ServletWrapper.java:316)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest
(ServletWrapper.java:341)
   at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest
(ServletWrapper.java:463)
   at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
   at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
   at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
   at com.ibm.ws.wswebcontainer.WebContainer.handleRequest
(WebContainer.java:1433)
   at com.ibm.ws.webcontainer.channel.WCChannelLink.ready
(WCChannelLink.java:93)
   at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination
(HttpInboundLink.java:465)
   at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation
(HttpInboundLink.java:394)
   at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready
(HttpInboundLink.java:274)
   at 
com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminato
rs(NewConnectionInitialReadCallback.java:214)
   at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete
(NewConnectionInitialReadCallback.java:113)
   at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted
(AioReadCompletionListener.java:152)
   at com.ibm.io.async.AbstractAsyncFuture.invokeCallback
(AbstractAsyncFuture.java:213)
   at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions
(AbstractAsyncFuture.java:195)
   at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
   at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
   at com.ibm.io.async.ResultHandler.runEventProcessingLoop
(ResultHandler.java:741)
   at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
   at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)

[2/25/08 16:11:30:937 PST] 0022 ServiceLogger I 
com.ibm.ws.ffdc.IncidentStreamImpl initialize FFDC0009I: FFDC opened incident 
stream file C:\RAD7\runtimes\base_v61\profiles\AppSrv01
\logs\ffdc\server1_35fa35fa_08.02.25_16.11.30_0.txt
[2/25/08 16:11:30:984 PST] 0022 ServiceLogger I 
com.ibm.ws.ffdc.IncidentStreamImpl resetIncidentStream FFDC0010I: FFDC closed 
incident stream file C:\RAD7\runtimes\base_v61\profiles\AppSrv01
\logs\ffdc\server1_35fa35fa_08.02.25_16.11.30_0.txt
[2/25/08 16:11:31:015 PST] 0022 ServletWrappe E   SRVE0100E: Did not 
realize  init() exception thrown by servlet RestletServlet: 
java.lang.NullPointerException
   at java.util.concurrent.CopyOnWriteArrayList.init
(CopyOnWriteArrayList.java:84)
   at org.restlet.Connector.init(Connector.java:69)
   at org.restlet.Client.init(Client.java:49)
   at com.noelios.restlet.ext.servlet.ServletWarClient.init
(ServletWarClient.java:52)
   at com.noelios.restlet.ext.servlet.ServerServlet.createApplication
(ServerServlet.java:215)
   at com.noelios.restlet.ext.servlet.ServerServlet.getApplication
(ServerServlet.java:313)
   at com.noelios.restlet.ext.servlet.ServerServlet.init
(ServerServlet.java:418)
   at javax.servlet.GenericServlet.init(GenericServlet.java:256)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.init
(ServletWrapper.java:185)
   at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.init
(ServletWrapper.java:316)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest
(ServletWrapper.java:341)
   at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest
(ServletWrapper.java:463)
   at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
   at 

Response Object Threadpool issue

2008-02-26 Thread code dude
Hi All,
We have recently migrated from SOAP webservices to RESTlet based Rest
architecture , where we get parameters via post , make api calls/ do
processing in threadpool and return/write back to response object
.but when i write results to send object in thread pool
thread ( response.setEntity) user get no outcome in browser or http client
...I dont know why .can anybody pl suggest me why its
happening orther wise it works perfectly


Regards,
cd