Monday, April 13, 2009

Wicket on Google App Engine

Like many others I am using Wicket on Google App Engine re-writing one of my pet projects. Google App Engine does not allow for user applications to start new threads so in order to get Wicket working, you need to disable the ModificiationWatcher by setting the resource poll frequency to NULL. This has a huge disadvantage when you're in development mode, because you'd have to restart the servlet engine each and every time you make a change in one of your HTML or other resource files.
Well - I dug into the Wicket internals and found out the ModificationWatcher was NOT meant to be plugable.. Yikes!.. Well I tried different approaches but found one that worked like a charm and it was dead simple:

Create the "" package in your project, add a Class called ModificationWatcher and make it a copy of the ModificationWatcher from the original Wicket sources. Remove all threading but keep the base logic in the "start(Duration pollFrequency)" method.

Now override "newWebRequest" in your WebApplication class like this:

protected WebRequest newWebRequest(HttpServletRequest servletRequest) {
return super.newWebRequest(servletRequest);

and vupti you've got reload of resource files again, even on Google App Engine. Remember this is only for development, but I cant see any other ways of doing it.

And to the wicket developers - please make the ModificationWathcer extendable someway.


Blogger Morten said...

Hi Lars. Nice work! I'll go ahead and try it out...

16/4/09 23:15  
Blogger Trevor Kimenye said...

For those wondering how a stripped down version of ModificationWatcher would look like:

public void start(final Duration pollFrequency)
// Construct task with the given polling frequency
//task = new Task("ModificationWatcher");

//, new ICode()
// public void run(final Logger log)
// {
// Iterate over a copy of the list of entries to avoid
// concurrent
// modification problems without the associated liveness issues
// of holding a lock while potentially polling file times!
for (final Iterator iterator = new ArrayList(modifiableToEntry.values()).iterator(); iterator
// Get next entry
final Entry entry = (Entry);

// If the modifiable has been modified after the last known
// modification time
final Time modifiableLastModified = entry.modifiable.lastModifiedTime();

if (modifiableLastModified.after(entry.lastModifiedTime))
// Notify all listeners that the modifiable was modified

// Update timestamp
entry.lastModifiedTime = modifiableLastModified;
// }

public void destroy()
//if (task != null)
// task.stop();
// task.interrupt();

I know, its really fugly.

1/6/09 06:10  
Blogger   said...


Could you publish the source of the ModificationWatcher that works on appengine?


5/6/09 15:28  
Blogger Trevor Kimenye said...

This comment has been removed by the author.

6/6/09 04:28  
Blogger Trevor Kimenye said...

I've posted a version of the ModificationWatcher and detailed info on my blog:

7/6/09 08:22  
Blogger Nick Wiedenbrueck said...

The resource modification watching will be fixed as of Wicket 1.4.0-RC6. The Wicket guys introduced a replaceable IModificationWatcher interface.

2/7/09 08:17  
Anonymous Anonymous said...

I found this site using [url=][/url] And i want to thank you for your work. You have done really very good site. Great work, great site! Thank you!

Sorry for offtopic

8/11/09 18:31  
Anonymous Anonymous said...

This comment has been removed by a blog administrator.

14/11/09 22:08  
Blogger 123 123 said...

This comment has been removed by a blog administrator.

25/12/09 12:48  

Post a Comment

<< Home