Hello Alex,

I think that the application need to be instantiated at least with the container's context (or maybe with the container itself - I don't remember if such constructor existed in b20).

Container con= new Container();
con.getServers().add(Protocol.HTTP,TEST_PORT);
con.getClients().add(Protocol.FILE);


Application app = new Application(con.getContext()){
        public Restlet createRoot()
        {
            String documentRoot = "file:///tmp";
            Directory dir = new Directory(getContext(), documentRoot){
                    public void handle(Request request, Response response) {
                        System.out.println("APP: Got called");
                        super.handle(request,response);
                    }
                };
            dir.setNegotiateContent(true);
            return dir;
        }
};

con.getDefaultHost().attach("",app);
con.start();

And then try to access it Thusly:

Request request = new Request(Method.GET, "http://localhost/blah";);
Response response = new Response(request);
con.handle(request, response);

I hope this will help you.

Best regards,
Thierry


Hey Jerome,
We're currently using beta 20.  Since I sent the message, I've made a little
progress, turns out instead of handling "http://localhost/blah";, it was
expecting just "/blah" in the URI.

However, hit another roadblock.  When I set up an application to be inside a
container (as was necessary in b20) thusly:

Application app = new Application(new Context()){
        public Restlet createRoot()
        {
            String documentRoot = "file:///tmp";
            Directory dir = new Directory(getContext(), documentRoot){
                    public void handle(Request request, Response response) {
                        System.out.println("APP: Got called");
                        super.handle(request,response);
                    }
                };
            dir.setNegotiateContent(true);
            return dir;
        }
};
Container con= new Container();
con.getServers().add(Protocol.HTTP,TEST_PORT);
con.getClients().add(Protocol.FILE);
con.getDefaultHost().attach("",app);
con.start();

And then try to access it Thusly:

Request request = new Request(Method.GET, "/blah");
Response response = new Response(request);
con.handle(request, response);

The overridden handle function in the Application never gets called, as nothing
shows up on STDOUT.  Am I setting this up wrong, or was this a bug that was
fixed in a later release?



Reply via email to