// Path: src/main/java/com/antelink/sourcesquare/event/base/EventBus.java
// public class EventBus {
// 
//     private static final Log logger = LogFactory.getLog(EventBus.class);
// 
//     HashMap<ClientEventType<?>, List<? extends ClientEventHandler>> eventMap = new HashMap<ClientEventType<?>, List<? extends ClientEventHandler>>();
// 
//     @SuppressWarnings("unchecked")
//     public <T extends ClientEventHandler> void addHandler(ClientEventType<T> eventType, T handler) {
//         if (!this.eventMap.containsKey(eventType)) {
//             this.eventMap.put(eventType, new ArrayList<T>());
//         }
//         ((ArrayList<T>) this.eventMap.get(eventType)).add(0, handler);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public <T extends ClientEventHandler> void fireEvent(final ClientEvent<T> event) {
//         if (!this.eventMap.containsKey(event.getHandlerType())) {
//             return;
//         }
//         for (final ClientEventHandler handler : this.eventMap.get(event.getHandlerType())) {
//             try {
//                 Runnable runner = new Runnable() {
// 
//                     @Override
//                     public void run() { 
//                         event.dispatch((T) handler);
// 
//                     }
//                 };
// 
//                 Thread thread = new Thread(runner);
//                 thread.start();
// 
//                 logger.trace("event dispatched to the handler " + handler.getId());
//             } catch (Exception e) {
//                 logger.error("An event could not be dispatched to the handler " + handler.getId(), e);
//             }
//         }
//     }
// }
// 
// Path: src/main/java/com/antelink/sourcesquare/event/events/StartScanEvent.java
// public class StartScanEvent implements ClientEvent<StartScanEventHandler> {
// 
//     public static final ClientEventType<StartScanEventHandler> TYPE = new ClientEventType<StartScanEventHandler>();
// 
//     private final File toScan;
// 
//     public StartScanEvent(File toScan) {
//         this.toScan = toScan;
//     }
// 
//     @Override
//     public ClientEventType<StartScanEventHandler> getHandlerType() {
//         return TYPE;
//     }
// 
//     @Override
//     public void dispatch(StartScanEventHandler handler) {
//         handler.handle(this.toScan);
// 
//     }
// 
// }
// 
// Path: src/main/java/com/antelink/sourcesquare/event/handlers/StartScanEventHandler.java
// public interface StartScanEventHandler extends ClientEventHandler {
// 
//     public void handle(File toScan);
// 
// }


import com.antelink.sourcesquare.event.base.EventBus;
import com.antelink.sourcesquare.event.events.StartScanEvent;
import com.antelink.sourcesquare.event.handlers.StartScanEventHandler;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
 * Copyright (C) 2009-2012 Antelink SAS
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License Version 3 as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License Version 3
 * for more details.
 *
 * You should have received a copy of the GNU Affero General Public License Version
 * 3 along with this program. If not, see http://www.gnu.org/licenses/agpl.html
 *
 * Additional permission under GNU AGPL version 3 section 7
 *
 * If you modify this Program, or any covered work, by linking or combining it with
 * Eclipse Java development tools (JDT) or Jetty (or a modified version of these
 * libraries), containing parts covered by the terms of Eclipse Public License 1.0,
 * the licensors of this Program grant you additional permission to convey the
 * resulting work. Corresponding Source for a non-source form of such a combination
 * shall include the source code for the parts of Eclipse Java development tools
 * (JDT) or Jetty used as well as that of the covered work.
 */
package com.antelink.sourcesquare.server;




public class ServerController {

    public static final String URL = "http://localhost:" + EmbeddedServer.getPort() + "/index.jsp";
    private static final Log logger = LogFactory.getLog(ServerController.class);

    public static void bind(final EventBus eventbus) {
        eventbus.addHandler(StartScanEvent.TYPE, new StartScanEventHandler() {

            @Override
            public String getId() {
// Path: src/main/java/com/antelink/sourcesquare/event/base/EventBus.java
// public class EventBus {
// 
//     private static final Log logger = LogFactory.getLog(EventBus.class);
// 
//     HashMap<ClientEventType<?>, List<? extends ClientEventHandler>> eventMap = new HashMap<ClientEventType<?>, List<? extends ClientEventHandler>>();
// 
//     @SuppressWarnings("unchecked")
//     public <T extends ClientEventHandler> void addHandler(ClientEventType<T> eventType, T handler) {
//         if (!this.eventMap.containsKey(eventType)) {
//             this.eventMap.put(eventType, new ArrayList<T>());
//         }
//         ((ArrayList<T>) this.eventMap.get(eventType)).add(0, handler);
//     }
// 
//     @SuppressWarnings("unchecked")
//     public <T extends ClientEventHandler> void fireEvent(final ClientEvent<T> event) {
//         if (!this.eventMap.containsKey(event.getHandlerType())) {
//             return;
//         }
//         for (final ClientEventHandler handler : this.eventMap.get(event.getHandlerType())) {
//             try {
//                 Runnable runner = new Runnable() {
// 
//                     @Override
//                     public void run() { 
//                         event.dispatch((T) handler);
// 
//                     }
//                 };
// 
//                 Thread thread = new Thread(runner);
//                 thread.start();
// 
//                 logger.trace("event dispatched to the handler " + handler.getId());
//             } catch (Exception e) {
//                 logger.error("An event could not be dispatched to the handler " + handler.getId(), e);
//             }
//         }
//     }
// }
// 
// Path: src/main/java/com/antelink/sourcesquare/event/events/StartScanEvent.java
// public class StartScanEvent implements ClientEvent<StartScanEventHandler> {
// 
//     public static final ClientEventType<StartScanEventHandler> TYPE = new ClientEventType<StartScanEventHandler>();
// 
//     private final File toScan;
// 
//     public StartScanEvent(File toScan) {
//         this.toScan = toScan;
//     }
// 
//     @Override
//     public ClientEventType<StartScanEventHandler> getHandlerType() {
//         return TYPE;
//     }
// 
//     @Override
//     public void dispatch(StartScanEventHandler handler) {
//         handler.handle(this.toScan);
// 
//     }
// 
// }
// 
// Path: src/main/java/com/antelink/sourcesquare/event/handlers/StartScanEventHandler.java
// public interface StartScanEventHandler extends ClientEventHandler {
// 
//     public void handle(File toScan);
// 
// }


// Path: src/main/java/com/antelink/sourcesquare/server/ServerController.java
import com.antelink.sourcesquare.event.base.EventBus;
import com.antelink.sourcesquare.event.events.StartScanEvent;
import com.antelink.sourcesquare.event.handlers.StartScanEventHandler;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Copyright (C) 2009-2012 Antelink SAS
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License Version 3 as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License Version 3
 * for more details.
 *
 * You should have received a copy of the GNU Affero General Public License Version
 * 3 along with this program. If not, see http://www.gnu.org/licenses/agpl.html
 *
 * Additional permission under GNU AGPL version 3 section 7
 *
 * If you modify this Program, or any covered work, by linking or combining it with
 * Eclipse Java development tools (JDT) or Jetty (or a modified version of these
 * libraries), containing parts covered by the terms of Eclipse Public License 1.0,
 * the licensors of this Program grant you additional permission to convey the
 * resulting work. Corresponding Source for a non-source form of such a combination
 * shall include the source code for the parts of Eclipse Java development tools
 * (JDT) or Jetty used as well as that of the covered work.
 */
package com.antelink.sourcesquare.server;




public class ServerController {

    public static final String URL = "http://localhost:" + EmbeddedServer.getPort() + "/index.jsp";
    private static final Log logger = LogFactory.getLog(ServerController.class);

    public static void bind(final EventBus eventbus) {
        eventbus.addHandler(StartScanEvent.TYPE, new StartScanEventHandler() {

            @Override
            public String getId() {
                return getClass().getCanonicalName() + ": " + StartScanEventHandler.class.getName();