I think the main issue is that for the development mode you need to
disable resource polling, since that is using threads (which are not
supported in GAE). This is described here:
http://stronglytypedblog.blogspot.com/2009/04/wicket-on-google-app-engine.html

One "problem" with this is that this obviously disables the resource
reloading, which might be slightly annoying when developing. There
might be more elegant solutions to this, but in order to overcome this
I wrote my own ModificationWatcher implementation (see code below). My
own modificationwatcher does not use threads, instead you must
manually call it every now and then so that it will see if the
resources have been changed.

In order to use my StaticModificationWatcher, you need to include the
following stuff in your Wicket Application class.

@Override
protected void init() {
                super.init();
                // your standard init stuff goes here
                if("development".equalsIgnoreCase(getConfigurationType())) {
                        staticModificationWatcher = new 
StaticModificationWatcher();
                        
getResourceSettings().setResourceWatcher(staticModificationWatcher);
                        
getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
                        
getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(true);
                } else {
                        
getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(false);
                        getResourceSettings().setResourcePollFrequency(null);
}

@Override
public RequestCycle newRequestCycle(Request request, Response response) {
                // In deploymentmode we are not using the 
staticModificationWatcher
                if(staticModificationWatcher != null) {
                        staticModificationWatcher.RunCheck();
                }
                return super.newRequestCycle(request, response);
}       


And the  StaticModicationWatcher.java


import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.apache.wicket.util.listener.ChangeListenerSet;
import org.apache.wicket.util.listener.IChangeListener;
import org.apache.wicket.util.time.Duration;
import org.apache.wicket.util.time.Time;
import org.apache.wicket.util.watch.IModifiable;
import org.apache.wicket.util.watch.IModificationWatcher;

public class StaticModificationWatcher implements IModificationWatcher {

        private static StaticModificationWatcher instance;
        
        private static final class Entry {
                // The most recent lastModificationTime polled on the object
                Time lastModifiedTime;

                // The set of listeners to call when the modifiable changes
                final ChangeListenerSet listeners = new ChangeListenerSet();

                // The modifiable thing
                IModifiable modifiable;
        }
        
        private Map<IModifiable, Entry> listeners;

        /**
         * Call this method regularly
         */
        public void RunCheck() {                
                // Use a separate list to avoid concurrent modification 
exceptions (notifying
                // the listener might cause a call to the add -method of this 
class)
                Collection<ChangeListenerSet> toBeNotified = new
ArrayList<ChangeListenerSet>();
                for(Entry entry : listeners.values()) {
                        
if(entry.modifiable.lastModifiedTime().equals(entry.lastModifiedTime)
== false) {
                                toBeNotified.add(entry.listeners);
                                //      entry.listeners.notifyListeners();      
                        
                        }
                        entry.lastModifiedTime = 
entry.modifiable.lastModifiedTime();
                }
                for(ChangeListenerSet changeListenerSet : toBeNotified) {
                        changeListenerSet.notifyListeners();
                }
        }
        
        public StaticModificationWatcher() {
                listeners = Collections.synchronizedMap(
                        new HashMap<IModifiable, Entry>());
        }
        
        @Override
        public boolean add(IModifiable modifiable, IChangeListener listener) {
                boolean contains = listeners.containsKey(modifiable);
                if(contains == false) {
                        Entry entry = new Entry();
                        entry.modifiable = modifiable;
                        entry.lastModifiedTime = modifiable.lastModifiedTime();
                        listeners.put(modifiable, entry);
                }
                listeners.get(modifiable).listeners.add(listener);
                
                return contains;
        }

        @Override
        public void destroy() {
                // nothing to do

        }

        @Override
        public Set<IModifiable> getEntries() {
                return listeners.keySet();
        }

        @Override
        public IModifiable remove(IModifiable modifiable) {
                listeners.remove(modifiable);
                
                return modifiable;
        }

        @Override
        public void start(Duration duration) {
                // ignored
        }
}



On Thu, Apr 8, 2010 at 12:43 PM, nino martinez wael
<nino.martinez.w...@gmail.com> wrote:
> ery describing mail. But AFAIK, and my knowledge are rather
> limited you need to switch the session store. And then GAE has a
> couple of restrictions for java that you need to comply with. It's not
> so much Wicket and GAE, but JAVA and GAE that have issues.. Other than
> that search with google for Wicket and GAE, theres a couple of
> tutorials out there.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to