Dashboard > Groovy > ... > Modules > GroovyRestlet
GroovyRestlet Log In | Sign Up   View a printable version of the current page.

Added by Keke, Qi , last edited by Keke, Qi on May 17, 2008  (view change) show comment
Labels: 

Module Overview

GroovyRestlet is a simple DSL for constructing Restlet application in a simple, shortcuting syntax.

Download

Distributions

GroovyRestlet is distributed as a single jar.

Current release

GroovyRestlet 0.3-SNAPSHOT, donwload here
Changes

  • Upgrade to Restlet 1.1 M3
  • Upgrade to Spring 2.5.2
  • directory constructor now only accept root attribute as valid URI.
  • Bug fixes

Old releases

  • GroovyRestlet 0.2, download from here
  • GroovyRestlet 0.1, download from here for Restlet 1.1-SNAPSHOT

Pre-requisites

At current moment, GroovyRestlet depends following:

  • Groovy 1.5
  • Java 1.5
  • Restlet 1.1-SNAPSHOT
  • SLF4J 1.4.3 as logging tool
  • Spring 2.5 if spring integration is required
  • commons-lang 2.3

Installing

Drop GroovyRestlet and all dependencies in your Java classpath.

Documentation

Quick start

First, create an instance of GroovyRestlet first.

GroovyRestlet gr = new GroovyRestlet()

If you want Spring support, provide an instance of ApplicationContext as the constructor parameter.

GroovyRestlet gr = new GroovyRestlet(appCtx);

Then, prepare your Restlet building script using simple GroovyRestlet DSL syntax.
Calling GroovyRestlet.build(URI) then done.

Check GroovyRestlet User Guide for detail user information.

Examples

Here is one GroovyRestlet DSL example, inspired from Restlet tutorial 11.

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 examples:

Developers

Source Control

http://svn.codehaus.org/groovy-contrib/groovyrestlet/trunk

Building

GroovyRestlet uses Maven 2 as its building tool.

Contributing

Feel free to contribute.

Mailing List(s)

http://groovy.codehaus.org/Mailing+Lists

Issue tracker

http://code.google.com/p/groovy-restlet/issues/

Site running on a free Atlassian Confluence Open Source Project License granted to The Codehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.2 Build:#919 Nov 26, 2007) - Bug/feature request - Contact Administrators