Restlet web.xml config for new component

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Restlet web.xml config for new component

Peter Hiesmair
I have set up an App Engine Restlet Project (v 2.2.2) which returns a html or json response (web or android client) and different data from a db for different users. I have implemented HTTP basic authentication. It all works quite well.

my basic setup atm (I have simplified it ofc):
public class MyApplication extends Application {

    private ChallengeAuthenticator authenticatior;
    private ChallengeAuthenticator createAuthenticator() {...}
    public boolean authenticate(Request request, Response response) {...}

    public Restlet createInboundRoot() {
        this.authenticatior = createAuthenticator();        
        Router router = new Router(getContext());
        return authenticatior;
public class MyRestlet extends ServerResource {

        public Representation getJSON() {
            MyApplication app = (MyApplication) getApplication();
                if (!app.authenticate(getRequest(), getResponse())) {
                    // Not authenticated
                    return null;
                else {
                    return data;    

        public String getHTML() {...}

<?xml ...>




Now I want to add encryption and created keys/certificates. My guide was this tutorial ( I wanted to try to add a simple component first, stay with HTTP and change the port to 8183 as done in this tutorial ( I have now played around quite a bit and cannot seem to get my component to work. So my question is: Where would I put this main-Method (the following code is taken from the tutorial)? Into which class should I insert it or should I create a seperate server-class and what exactly would the required changes to the web.xml look like (I did not find much concerning this and I suspect that this is the central problem)? Any help is appreciated!

public static void main(String[] args) throws Exception {
    // Create a new Restlet component and add a HTTP server connector to it
    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8182);

    // Then attach it to the local host
    component.getDefaultHost().attach("/trace", Part05.class);

    // Now, let's start the component!
    // Note that the HTTP server connector is also automatically started.