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 "org.apache.wicket.util.watch" 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:
@Override
protected WebRequest newWebRequest(HttpServletRequest servletRequest) {
getResourceSettings().getResourceWatcher(true).start(getResourceSettings().getResourcePollFrequency());
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.
7 Comments:
Hi Lars. Nice work! I'll go ahead and try it out...
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");
//task.run(pollFrequency, 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
.hasNext();)
{
// Get next entry
final Entry entry = (Entry)iterator.next();
// 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
entry.listeners.notifyListeners();
// Update timestamp
entry.lastModifiedTime = modifiableLastModified;
}
}
// }
//});
}
public void destroy()
{
//if (task != null)
//{
// task.stop();
// task.interrupt();
//}
}
I know, its really fugly.
hi.
Could you publish the source of the ModificationWatcher that works on appengine?
thanks.
This comment has been removed by the author.
I've posted a version of the ModificationWatcher and detailed info on my blog: http://kimenye.blogspot.com/2009/06/google-app-engine-wicket.html
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
Post a Comment
<< Home