http://localhost:9876/samplerestlet/file/{filename}
The idea is that it will retrieve and display {filename}, which is an instance of the "file" resource.
This was a nice way to wade into the Restlet framework; more than a Hello World app, lacking stuff we don't need (like Virtual Hosts), and requiring stuff we do (URL-based dispatching).
To see what I did, check out the following 'samplerestlet' module from SVN:
svn://www.hackystat.org/csdl/samplerestlet
To build and run it:
- Download Restlet-1.0, unzip, and point a RESTLET_HOME env variable at it.
- Build the system with "ant jar"
- Run the result with "java -jar samplerestlet.jar"
Try retrieving the following in your browser: http://localhost:9876/samplerestlet/file/build.xml
Now look through the following three files, each only about 50 LOC:
- build.xml, which shows what's needed to build the executable jar file.
- Server.java, which creates the server and dispatches to a FileResource instance to handle URLs satisfying the file/{filename} pattern.
- FileResource.java, which handles those GET requests by reading the file from disk and returning a string representation of it.
Next step is to add this kind of URL processing to SensorBase.
1 comment:
Post a Comment