In the absence of such a full walkthrough existing, here are some ad hoc
recommendations on classpath configuration.  I'm writing off-the-cuff here,
so I hope others will correct my mistakes as I go along.

One of the great strengths of Restlet is its ability to create uniform
RESTful applications that can run in many different client and server
environments, but the price of this flexibility is some extra thought when
it comes to deciding which bits you actually need for your environment.

1) API and RI

To do anything at all with Restlet, your classpath will minimally need to
contain org.restlet.jar (the API) and com.noelios.restlet.jar (the Reference
Implementation, or RI), which are found in the lib directory of the
distribution.

In a new Eclipse Java (not J2EE) project, the easiest way to do this is
simply to add these two JARs to the Build Path for that project.

In a J2EE project, you will want to put these files in the Web App
Dependencies by whatever your favorite means is -- referencing them
externally or copying them into WEB-INF/lib directly.

2) Connectors

Now you must decide which of the other JAR files (and their dependencies)
you wish to add for client and server support.  You have a lot of options
here.  In all cases you will add the com.noelios.restlet.ext.[something].jar
to the Build Path (Java) or Web App Dependencies (J2EE), and then must add
whatever the requirements are for that thing.  For example, if you want to
use Jetty as your embedded Web server, you would add
com.noelios.restlet.ext.jetty.jar, and also the relevant parts of Jetty:
jetty-util.jar, jetty.jar, jetty-ajp.jar, and jetty-https.jar, as documented
in the Jetty connector.

With Restlet 1.1, you can run HTTP server code (like the SimpleServer
example) in a Java project by adding com.noelios.restlet.ext.net.jar, which
will provide basic server services using a java.net socket and no external
dependencies.

To use the embedded server, remember to run your class (e.g.
SimpleServer.java) using Eclipse's "Run as Application" command and not with
the "Run on Server" command.

To run Restlet adapted under the Servlet API, inside Eclipse's copy of
Tomcat or some other application server, you will want to use
com.noelios.restlet.ext.servlet_2.5.jar in your Web App Dependencies.  You
must also configure your WEB-INF file accordingly, as documented here:
http://www.restlet.org/documentation/1.1/ext/com/noelios/restlet/ext/servlet/ServerServlet.html

When using the Servlet API, you will want to use the "Run on Server" command
instead to deploy your app to the local copy of Tomcat, or "Export WAR" to
produce a WAR file that can be deployed on an alternate J2EE server.

- Rob

Reply via email to