JPublish-RESTLET integration; a very first step.

4 views
Skip to first unread message

Florin

unread,
Mar 19, 2009, 4:39:18 PM3/19/09
to JPublish User Group
Hi,

I am pleased to let you know about the availability of a very simple
yet flexible integration between JPublish and the RESTLET framework:
http://www.restlet.org

The svn Rev230, contains a JPublish module that is able to transform
REST requests, such as...

/hello/{name}
/user/{name}/{id}
/user/{name}/order/{id}
/search/{keyword}
/info/{id}
...


... into JPublish action calls and page rendering.

For your convenience, a simple demo is provided, available:
http://jpublish.googlecode.com/files/jprestlet.war.zip

To start, build from svn or download the demo above. If you check your
jpublish.xml file, you will notice the new module, JPRestlet.

<module classname="org.jpublish.module.restlet.JPRestletModule">
<url>/rest/*</url>
<restlet-config>/WEB-INF/jprestlet-config.xml</restlet-
config>
<profilling>true</profilling>
<verbose>on</verbose>
<debug>true</debug>
</module>


The configuration above will initialize the RESTLET support for all
the requests on the path described by the <url/> tag: "rest/*" in this
case.

The RESTLET convertor will be initialized from the /WEB-INF/jprestlet-
config.xml file. In the jprestlet-config.xml, you can define your
resource mappings and a dedicated JPublish content repository:
"extended", in this example. The JPublish repositories are defined in
the jpublish.xml, but you should already know that.

In our example, we are supporting the following routes:

<jprestlet>
<repository name="extended"/>
<routes>
<route map="/hello/{name}" action="rest/Hello.bsh"/>
<route map="/user/{name}/{id}" page="user.html"/>
<route map="/action/info/{id}" action="rest/Info.bsh"
page="info.html"/>
<route map="/info/{id}" page="info.html"/>
</routes>
<debug>true</debug>
</jprestlet>


With the mappings declared above, a call like:

* http://localhost:8080/jprestlet/rest/hello/JPublish


will echo back to you the text: Hello JPublish!

This is enough to get you started if you are interested in learning
more about RESTful services. Also, if you don't want to use JPublish
but are a Java developer that wants to develop RESTful services,
please visit the RESTLET framework site. It's an amazing framework.

If you like the RESTful world, then please stay tuned. There is more
to come.

Thank you for using JPublish,
-florin

Alejandro Revilla

unread,
Mar 19, 2009, 4:40:55 PM3/19/09
to jpubli...@googlegroups.com
Thank you Florin! This is more than welcome!

Florin T.PATRASCU

unread,
Mar 19, 2009, 8:14:39 PM3/19/09
to jpubli...@googlegroups.com
You are very welcome Alejandro, I hope the new code will help you
implement future RESTful compliant services, if need be.

I forgot to mention a simple detail. If you want to fallback on the
RESTLET framework for implementing Restlets (see: http://www.restlet.org/documentation/1.1/api/org/restlet/Restlet.html)
, the current implementation already supports that too. The svn
example contains the following line in the jprestlet-config.xml file:

<route map="/hello/{name}"
restlet="org.jpublish.module.restlet.demo.HelloJPRestlet"/>

In the example above, when a request is matching the /hello/{name}
route, JPublish will delegate the request and the response to the
HelloJPRestlet object; a pure Restlet. The magic attribute there is:
"restlet".

I'll write soon more about all these.

Have fun!
-florin
Reply all
Reply to author
Forward
0 new messages