Hi Mark,
the TestServer is a very simple server-side application using only a
Restlet.
In this case, if you want to handle only, let's say, GET requests, you
have to test it by yourself and generate correctly the response in the
"handle(request, Response)" method.
I suggest you develop the server-side application with Resource. Here is
a pointer that will help you:
http://www.restlet.org/documentation/1.1/firstResource.
The list of allowed methods for a resource can be controlled via the
allow* methods and or the "modifiable"/"readable" properties.
You can see the javadocs for more details
("http://www.restlet.org/documentation/1.1/api/org/restlet/resource/Resource.html").
Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org <http://www.restlet.org/>
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
<http://www.noelios.com/>
Fantastic, Thierry. Thanks much.
Dumb question: how, or should, one integrate the notion of "allow
post"/"allow put", etc, in the TestServer code?
Mark
On Sep 11, 2008, at 3:03 AM, Thierry Boileau wrote:
Mail sent on the 09/02 and apparently lost.
---
Hello Mark,
it may be too late, but I send a you a very simple "application"
composed of two parts.
One part is developped with the gwt technology and aims at building a
simple HTML page. It integrates also a simple AJAX call to the server
part therefore it relies also on the "org.rest.gwt.jar" package which
is the integration of both GWT and Restlet (client only)
technologies. All sources and libraries (except GWT) are located in
the "gwt-Foo.zip" file attached to this mail. It contains only one
source file called "Foo.java".
The other part is the server part based exclusively on the Restlet
technology. It allows first to serve the files generated by GWT and
then to reply to the AJAX call. I just provide the code of the unique
class (TestServer). You will need 2 restlet packages
"org.restlet.jar" and com.noelios.restlet.jar".
I hope it will help you a little bit.
Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
<http://www.restlet.org/>
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
<http://www.noelios.com/>
NB : as said Rob, it is planned to add a more developped example
(http://restlet.tigris.org/issues/show_bug.cgi?id=541).
Good day. I'm new here, but not new to Java and its supporting
technologies.
I'm embarking on teaching myself GWT using Restlets, neither of
which I have programmed before, although I have read the
documentation for each. I know that at the time the Restlet-GWT
code was released, a whopping 6 weeks ago :-), there were no
examples illustrating its use. Perhaps there are snippets of
examples the community can share now, some weeks after the release.
If you have such examples, I would be quite grateful to study them,
as would be, I'm sure, other newcomers to these subjects. I am
particularly interested in running the server side using the Restlet
NET connector.
All the pieces are in front of me; at this point a few well placed
examples would help bring it all together.
Thank you.
<gwt-Foo.zip>package gwt;
import org.restlet.Component;
import org.restlet.Directory;
import org.restlet.Restlet;
import org.restlet.data.LocalReference;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Status;
import org.restlet.resource.StringRepresentation;
public class TestServer extends Component {
public static void main(String[] args) throws Exception {
Component server = new TestServer();
server.start();
}
public TestServer() {
super();
getServers().add(Protocol.HTTP, 8182);
getClients().add(Protocol.FILE);
Restlet restlet = new Restlet() {
@Override
public void handle(Request request, Response response) {
response.setEntity(new StringRepresentation("This is a
test",
MediaType.TEXT_PLAIN));
response.setStatus(Status.SUCCESS_OK);
}
};
// Path to the directory where are located the gwt client pages.
String gwtClientPagesDir =
"/home/thierry/workspace/restlet-1.1/Foo/www/com.example.foo.Foo";
// Simple Directory that serves the gwt client pages.
Directory directory = new
Directory(getContext().createChildContext(),
LocalReference.createFileReference(gwtClientPagesDir));
// Will be targeted from Internet browser (e.g.
// http://localhost:8182/testClient/Foo
getDefaultHost().attach("/testClient", directory);
// Will be targeted by the gwt sample page via AJAX request
getDefaultHost().attach("/testServer", restlet);
}