Hi,

I have an app using Restlet in Google App Engine. I have warmup requests
enabled to theoretically do some heavy data loading before the first real
user request but it does not appear to work. The first real request does
all the loading which is not ideal!

http://code.google.com/appengine/docs/java/config/appconfig.html#Warmup_Requests

An example web.xml and Example.java class are shown below. I was expecting
when I set load-on-startup=1 in web.xml that Restlet would initialise all
the routes and call my init() method during the warmup request but this
does not appear to happen.

Ideally, I want my data loaded and as much of Restlet initialised during
the warmup request from App Engine.

I have read that I could create my own "warmup" servlet to load the data
but this does not load Restlet in any way but it would allow me to load my
data from the Datastore.

Can anyone point me in the right direction?

Cheers,
John



*****  extract from web.xml: *****

<servlet>
    <servlet-name>ExampleServlet</servlet-name>
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <init-param>
        <param-name>org.restlet.application</param-name>
        <param-value>my.app.Example</param-value>
    </init-param>
</servlet>



***** Example.java: *****

public class Example extends Application {

    public Example() {
        getStatusService().setEnabled(false); // this is needed to prevent
Restlet displaying its own custom error pages
    }



    /**
     * Initialise the app
     * @param context
     */
    private void init(Context context) {
        //
        // I do my heavy data loading from this method
        //
    }



    /**
     * Creates a root Restlet that will receive all incoming calls and
route the
     * requests to the appropriate resource handlers. This also attaches
different
     * authenticators depending on the resource being requested.
     *
     */
    @Override
    public Restlet createInboundRoot() {
        Context context = getContext();
        init(context); // call init to load the data before we handle the
request

        // NORMAL: user licence auth and routing
        Router userRouter = new Router(context);
        // ..... user routes

        // check the licence key for each request
        LicenceAuthenticator licenceAuth = new
LicenceAuthenticator(context, licences);
        licenceAuth.setNext(userRouter);


        // ADMIN: needs special auth
        Router adminRouter = new Router(context);
        // ..... admin routes

        // authenticate the admin
        AdminAuthenticator adminAuth = new AdminAuthenticator(context);
        adminAuth.setNext(adminRouter);

        // Create routes for regular and admin users that go through the
authenticators
        Router rootRouter = new Router(context);
        rootRouter.attach("/detect", licenceAuth);
        rootRouter.attach("/admin", adminAuth);
        return rootRouter;
    }
}

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2933568

Reply via email to