@@ -0,0 +1,1997 @@
+%0Apackage forager.server;%0A%0Aimport java.lang.annotation.Annotation;%0Aimport java.lang.reflect.Method;%0A%0Aimport java.util.Arrays;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0A%0Aimport galileo.event.Event;%0Aimport galileo.event.EventHandler;%0Aimport galileo.event.EventTypeMap;%0A%0Apublic class EventMapper %7B%0A%0A    private static final Logger logger = Logger.getLogger(%22galileo%22);%0A%0A    private Class%3C?%3E handlerClass;%0A    private Object handlerObject;%0A    private Map%3CClass%3C?%3E, Method%3E classToMethod = new HashMap%3C%3E();%0A%0A    public EventMapper(Object handlerObject) %7B%0A        this.handlerClass = handlerObject.getClass();%0A        this.handlerObject = handlerObject;%0A    %7D%0A%0A    public %3CT extends Event%3E void map(EventTypeMap typeMap, Class%3CT%3E type) %7B%0A%0A    %7D%0A%0A    public void linkEventHandlers() %7B%0A        for (Method m : handlerClass.getMethods()) %7B%0A            for (Annotation a : m.getAnnotations()) %7B%0A                if (a.annotationType().equals(EventHandler.class)) %7B%0A                    /* This method is an event handler */%0A                    Class%3C?%3E%5B%5D params = m.getParameterTypes();%0A                    Class%3C?%3E eventClass = extractEventClass(params);%0A                    logger.log(Level.INFO,%0A                            %22Linking handler method %5B%7B0%7D%5D to class %5B%7B1%7D%5D%22,%0A                            new Object%5B%5D %7B m.getName(), eventClass.getName() %7D);%0A                    classToMethod.put(eventClass, m);%0A                    break;%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    private Class%3C?%3E extractEventClass(Class%3C?%3E%5B%5D parameters) %7B%0A        if (parameters.length %3C= 0) %7B%0A            //TODO throw new exception%0A        %7D%0A%0A        List%3CClass%3C?%3E%3E interfaces%0A            = Arrays.asList(parameters%5B0%5D.getInterfaces());%0A        if (interfaces.contains(Event.class) == false) %7B%0A            //TODO throw error%0A        %7D%0A%0A        return parameters%5B0%5D;%0A        //classToMethod.put(parameters%5B0%5D, m);%0A    %7D%0A%7D%0A

Add prototype annotation-based event mapper