created FlowProgrammer module and implemented FlowPusher and FlowSynchronizer as services, also modified FlowManager to use the service exported by FlowProgrammer
diff --git a/conf/onos-embedded.properties b/conf/onos-embedded.properties
index 777ff2b..e280e41 100644
--- a/conf/onos-embedded.properties
+++ b/conf/onos-embedded.properties
@@ -9,6 +9,7 @@
 net.floodlightcontroller.ui.web.StaticWebRoutable,\
 net.onrc.onos.datagrid.HazelcastDatagrid,\
 net.onrc.onos.ofcontroller.flowmanager.FlowManager,\
+net.onrc.onos.ofcontroller.flowprogrammer.FlowProgrammer,\
 net.onrc.onos.ofcontroller.topology.TopologyManager,\
 net.onrc.onos.registry.controller.ZookeeperRegistry
 net.floodlightcontroller.restserver.RestApiServer.port = 8080
diff --git a/conf/onos.properties b/conf/onos.properties
index e858adb..f7bffb2 100644
--- a/conf/onos.properties
+++ b/conf/onos.properties
@@ -9,6 +9,7 @@
 net.floodlightcontroller.ui.web.StaticWebRoutable,\
 net.onrc.onos.datagrid.HazelcastDatagrid,\
 net.onrc.onos.ofcontroller.flowmanager.FlowManager,\
+net.onrc.onos.ofcontroller.flowprogrammer.FlowProgrammer,\
 net.onrc.onos.ofcontroller.topology.TopologyManager,\
 net.onrc.onos.registry.controller.ZookeeperRegistry
 net.floodlightcontroller.restserver.RestApiServer.port = 8080
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
index de24b53..bd5ba43 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -2,7 +2,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.Map;
@@ -18,7 +17,6 @@
 import net.floodlightcontroller.core.module.IFloodlightModule;
 import net.floodlightcontroller.core.module.IFloodlightService;
 import net.floodlightcontroller.restserver.IRestApiService;
-import net.floodlightcontroller.util.OFMessageDamper;
 import net.onrc.onos.datagrid.IDatagridService;
 import net.onrc.onos.graph.GraphDBOperation;
 import net.onrc.onos.ofcontroller.core.INetMapStorage;
@@ -26,13 +24,11 @@
 import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
 import net.onrc.onos.ofcontroller.floodlightlistener.INetworkGraphService;
 import net.onrc.onos.ofcontroller.flowmanager.web.FlowWebRoutable;
-import net.onrc.onos.ofcontroller.flowprogrammer.FlowPusher;
+import net.onrc.onos.ofcontroller.flowprogrammer.IFlowPusherService;
 import net.onrc.onos.ofcontroller.topology.ITopologyNetService;
 import net.onrc.onos.ofcontroller.topology.Topology;
-import net.onrc.onos.ofcontroller.topology.TopologyElement;
 import net.onrc.onos.ofcontroller.util.*;
 
-import org.openflow.protocol.OFType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -57,8 +53,7 @@
     protected FloodlightModuleContext context;
     protected FlowEventHandler flowEventHandler;
 
-    protected FlowPusher pusher;
-    private static final int NUM_PUSHER_THREAD = 1;
+    protected IFlowPusherService pusher;
     
 //	LEGACY
 //    protected OFMessageDamper messageDamper;
@@ -467,8 +462,8 @@
 //					    EnumSet.of(OFType.FLOW_MOD),
 //					    OFMESSAGE_DAMPER_TIMEOUT);
 
-	pusher = new FlowPusher(NUM_PUSHER_THREAD);
-	pusher.init(null, floodlightProvider.getOFMessageFactory(), null);
+	pusher = context.getServiceImpl(IFlowPusherService.class);
+
 	this.init("");
 
 	mapReaderScheduler = Executors.newScheduledThreadPool(1);
@@ -509,8 +504,6 @@
 
 	// Initialize the Flow Entry ID generator
 	nextFlowEntryIdPrefix = randomGenerator.nextInt();
-
-	pusher.start();
 	
 	//
 	// Create the Flow Event Handler thread and register it with the
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowProgrammer.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowProgrammer.java
new file mode 100644
index 0000000..87a4767
--- /dev/null
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowProgrammer.java
@@ -0,0 +1,69 @@
+package net.onrc.onos.ofcontroller.flowprogrammer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import net.floodlightcontroller.core.IFloodlightProviderService;
+import net.floodlightcontroller.core.module.FloodlightModuleContext;
+import net.floodlightcontroller.core.module.FloodlightModuleException;
+import net.floodlightcontroller.core.module.IFloodlightModule;
+import net.floodlightcontroller.core.module.IFloodlightService;
+
+public class FlowProgrammer implements IFloodlightModule {
+    protected volatile IFloodlightProviderService floodlightProvider;
+
+    protected FlowPusher pusher;
+    private static final int NUM_PUSHER_THREAD = 1;
+
+    protected FlowSynchronizer synchronizer;
+        
+    public FlowProgrammer() {
+	pusher = new FlowPusher(NUM_PUSHER_THREAD);
+	synchronizer = new FlowSynchronizer();
+    }
+    
+    @Override
+    public void init(FloodlightModuleContext context)
+	    throws FloodlightModuleException {
+	floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
+	pusher.init(null, floodlightProvider.getOFMessageFactory(), null);
+	synchronizer.init(context);
+    }
+
+    @Override
+    public void startUp(FloodlightModuleContext context) {
+	pusher.start();
+	synchronizer.startUp(context);
+    }
+
+    @Override
+    public Collection<Class<? extends IFloodlightService>> getModuleServices() {
+	Collection<Class<? extends IFloodlightService>> l = 
+		new ArrayList<Class<? extends IFloodlightService>>();
+	l.add(IFlowPusherService.class);
+	l.add(IFlowSyncService.class);
+	return l;
+    }
+
+    @Override
+    public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
+	Map<Class<? extends IFloodlightService>,
+	    IFloodlightService> m =
+	    new HashMap<Class<? extends IFloodlightService>,
+	    IFloodlightService>();
+	m.put(IFlowPusherService.class, pusher);
+	m.put(IFlowSyncService.class, synchronizer);	
+	return m;
+    }
+
+    @Override
+    public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
+	Collection<Class<? extends IFloodlightService>> l =
+		new ArrayList<Class<? extends IFloodlightService>>();
+	l.add(IFloodlightProviderService.class);
+	return l;
+    }
+    
+
+}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
index 5655dfa..e87f631 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
@@ -38,7 +38,7 @@
  * @author Naoki Shiota
  *
  */
-public class FlowPusher {
+public class FlowPusher implements IFlowPusherService {
     private final static Logger log = LoggerFactory.getLogger(FlowPusher.class);
 
     // NOTE: Below are moved from FlowManager.
@@ -236,6 +236,7 @@
 	 * Suspend processing a queue related to given switch.
 	 * @param sw
 	 */
+	@Override
 	public boolean suspend(IOFSwitch sw) {
 		SwitchQueue queue = getQueue(sw);
 		
@@ -255,6 +256,7 @@
 	/**
 	 * Resume processing a queue related to given switch.
 	 */
+	@Override
 	public boolean resume(IOFSwitch sw) {
 		SwitchQueue queue = getQueue(sw);
 		
@@ -271,6 +273,7 @@
 		}
 	}
 	
+	@Override
 	public boolean isSuspended(IOFSwitch sw) {
 		SwitchQueue queue = getQueue(sw);
 		
@@ -313,6 +316,7 @@
 	 * @param sw
 	 * @param msg
 	 */
+	@Override
 	public boolean add(IOFSwitch sw, OFMessage msg) {
 		FlowPusherProcess proc = getProcess(sw);
 		SwitchQueue queue = proc.queues.get(sw);
@@ -342,6 +346,7 @@
 	 * @param flowEntryObj
 	 * @return
 	 */
+	@Override
 	public boolean add(IOFSwitch sw, IFlowPath flowObj, IFlowEntry flowEntryObj) {
 		log.debug("sending : {}, {}", sw, flowObj);
 		String flowEntryIdStr = flowEntryObj.getFlowEntryId();
@@ -646,6 +651,7 @@
 		return true;
 	}
 	
+	@Override
 	public boolean add(IOFSwitch sw, FlowPath flowPath, FlowEntry flowEntry) {
 		//
 		// Create the OpenFlow Flow Modification Entry to push
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowSynchronizer.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
similarity index 88%
rename from src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowSynchronizer.java
rename to src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
index 8e12a46..370918a 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowSynchronizer.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowSynchronizer.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.ofcontroller.flowmanager;
+package net.onrc.onos.ofcontroller.flowprogrammer;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -37,6 +37,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.Lists;
+import com.tinkerpop.blueprints.Direction;
+
 import net.floodlightcontroller.core.IFloodlightProviderService;
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.IOFSwitchListener;
@@ -44,9 +47,13 @@
 import net.floodlightcontroller.core.module.FloodlightModuleException;
 import net.floodlightcontroller.core.module.IFloodlightModule;
 import net.floodlightcontroller.core.module.IFloodlightService;
+import net.floodlightcontroller.restserver.IRestApiService;
+import net.onrc.onos.datagrid.IDatagridService;
 import net.onrc.onos.graph.GraphDBOperation;
 import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
 import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
+import net.onrc.onos.ofcontroller.core.module.IOnosService;
+import net.onrc.onos.ofcontroller.floodlightlistener.INetworkGraphService;
 import net.onrc.onos.ofcontroller.util.Dpid;
 import net.onrc.onos.ofcontroller.util.FlowEntryAction;
 import net.onrc.onos.ofcontroller.util.FlowEntryActions;
@@ -60,14 +67,17 @@
 import net.onrc.onos.ofcontroller.util.FlowEntryAction.ActionSetVlanId;
 import net.onrc.onos.ofcontroller.util.FlowEntryAction.ActionSetVlanPriority;
 import net.onrc.onos.ofcontroller.util.FlowEntryAction.ActionStripVlan;
+import net.onrc.onos.registry.controller.IControllerRegistryService;
 
-public class FlowSynchronizer implements IOFSwitchListener,
-					 IFlowSyncService {
+public class FlowSynchronizer implements IFlowSyncService, IOFSwitchListener {
 
-    protected GraphDBOperation dbHandler = new GraphDBOperation(""); //TODO: conf
     protected static Logger log = LoggerFactory.getLogger(FlowSynchronizer.class);
     protected IFloodlightProviderService floodlightProvider;
-    protected Map<IOFSwitch, Thread> switchThread = new HashMap<IOFSwitch, Thread>();
+    protected IControllerRegistryService registryService;
+    protected IFlowPusherService pusher;
+    
+    private GraphDBOperation dbHandler;
+    private Map<IOFSwitch, Thread> switchThread = new HashMap<IOFSwitch, Thread>();
     
     protected class Synchroizer implements Runnable {
 	IOFSwitch sw;
@@ -76,7 +86,24 @@
 	public Synchroizer(IOFSwitch sw) {
 	    this.sw = sw;
 	    Dpid dpid = new Dpid(sw.getId());
+//	    try {
+//		System.out.println("sleep....");
+//		Thread.sleep(5000);
+//	    } catch (InterruptedException e) {
+//		// TODO Auto-generated catch block
+//		e.printStackTrace();
+//	    }
+	    System.out.println("getting db switch: " + dpid);
 	    this.swObj = dbHandler.searchSwitch(dpid.toString());
+	    System.out.println("switch vertex: " + swObj);
+	    System.out.println(this.swObj.getState());
+	    System.out.println(Lists.newArrayList(swObj.asVertex().getEdges(Direction.BOTH, "")));
+	    System.out.println(Lists.newArrayList(this.swObj.getFlowEntries()));
+	    for(IFlowEntry fe : dbHandler.getAllFlowEntries()){
+		System.out.println(fe.getSwitch() + " " + fe.getSwitchDpid());
+	    }
+	    System.out.println(Lists.newArrayList(dbHandler.getAllFlowEntries()));
+	    return; 
 	}
 	
 	@Override
@@ -129,15 +156,18 @@
 		      "Flow entries skipped " + skipped);
 	}
 	
+	//TODO: replace this with FlowPusher
 	private void writeToSwitch(OFMessage msg) {
-	    try {
-		sw.write(msg, null); // TODO: what is context?
-		sw.flush();
-	    } catch (IOException e) {
-		// TODO Auto-generated catch block
-		System.out.println("ERROR*****");
-		e.printStackTrace();
-	    } 
+//	    try {
+//		sw.write(msg, null); // TODO: what is context?
+//		sw.flush();
+//	    } catch (IOException e) {
+//		// TODO Auto-generated catch block
+//		System.out.println("ERROR*****");
+//		e.printStackTrace();
+//	    } 
+	    System.out.println("write to sw....");
+	    pusher.add(sw, msg);
 	}
 	
 	private Set<FlowEntryWrapper> getFlowEntriesFromGraph() {
@@ -146,6 +176,7 @@
 		FlowEntryWrapper fe = new FlowEntryWrapper(entry);
 		entries.add(fe);
 	    }
+	    System.out.println("Got " + entries.size() + " entries from graph");
 	    return entries;	    
 	}
 	
@@ -202,14 +233,17 @@
 	t.start();
 	switchThread.put(sw, t);
     }
-    
+        
     @Override
     public void addedSwitch(IOFSwitch sw) {
 	// TODO Auto-generated method stub
 	System.out.println("added switch in flow sync: " + sw);
 	
 	// TODO: look at how this is spawned
-	synchronize(sw);
+//	if (registryService.hasControl(sw.getId())) {
+
+	    synchronize(sw);
+//	}
     }
 
     @Override
@@ -226,7 +260,6 @@
     @Override
     public void switchPortChanged(Long switchId) {
 	// TODO Auto-generated method stub
-
     }
 
     @Override
@@ -234,23 +267,26 @@
 	// TODO Auto-generated method stub
 	return "FlowSynchronizer";
     }
+    
+    public FlowSynchronizer() {
+	System.out.println("Initializing FlowSync...");
+	dbHandler = new GraphDBOperation("");
+    }
 
-    /*
-    @Override
+    
+    //@Override
     public void init(FloodlightModuleContext context)
 	    throws FloodlightModuleException {
-	// TODO Auto-generated method stub
 	System.out.println("********* Starting flow sync....");
 	floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
-	System.out.println(context.getAllServices());	
+	registryService = context.getServiceImpl(IControllerRegistryService.class);
+	pusher = context.getServiceImpl(IFlowPusherService.class);
     }
 
-    @Override
+    //@Override
     public void startUp(FloodlightModuleContext context) {
-	// TODO Auto-generated method stub
 	floodlightProvider.addOFSwitchListener(this);
     }
-    */
 
 }
 
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java
index 146f19c..e16dd20 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowPusherService.java
@@ -2,6 +2,10 @@
 
 import net.floodlightcontroller.core.IOFSwitch;
 import net.floodlightcontroller.core.module.IFloodlightService;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowEntry;
+import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
+import net.onrc.onos.ofcontroller.util.FlowEntry;
+import net.onrc.onos.ofcontroller.util.FlowPath;
 
 import org.openflow.protocol.OFMessage;
 
@@ -12,26 +16,28 @@
 	 * @param msg
 	 * @return
 	 */
-	void addMessage(long dpid, OFMessage msg);
+	boolean add(IOFSwitch sw, OFMessage msg);
+	boolean add(IOFSwitch sw, FlowPath flowPath, FlowEntry flowEntry);
+	boolean add(IOFSwitch sw, IFlowPath flowObj, IFlowEntry flowEntryObj);
 	
 	/**
 	 * Suspend pushing message to a switch.
 	 * @param sw
 	 * @return true if success
 	 */
-	boolean suspend(long dpid);
+	boolean suspend(IOFSwitch sw);
 	
 	/**
 	 * Resume pushing message to a switch.
 	 * @param sw
 	 * @return true if success
 	 */
-	boolean resume(long dpid);
+	boolean resume(IOFSwitch sw);
 	
 	/**
 	 * Get whether pushing of message is suspended or not.
 	 * @param sw
 	 * @return true if suspended
 	 */
-	boolean isSuspended(long dpid);
+	boolean isSuspended(IOFSwitch sw);
 }
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowSyncService.java b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowSyncService.java
similarity index 70%
rename from src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowSyncService.java
rename to src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowSyncService.java
index 957386f..1e71f6a 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/IFlowSyncService.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/IFlowSyncService.java
@@ -1,6 +1,7 @@
-package net.onrc.onos.ofcontroller.flowmanager;
+package net.onrc.onos.ofcontroller.flowprogrammer;
 
 import net.floodlightcontroller.core.IOFSwitch;
+import net.floodlightcontroller.core.IOFSwitchListener;
 import net.floodlightcontroller.core.module.IFloodlightService;
 
 /**
diff --git a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
index 7c4bc1a..22c348a 100644
--- a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
+++ b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
@@ -20,6 +20,7 @@
 net.floodlightcontroller.core.test.MockThreadPoolService
 net.onrc.onos.datagrid.HazelcastDatagrid
 net.onrc.onos.ofcontroller.flowmanager.FlowManager
+net.onrc.onos.ofcontroller.flowprogrammer.FlowProgrammer
 net.onrc.onos.ofcontroller.topology.TopologyManager
 net.onrc.onos.ofcontroller.bgproute.BgpRoute
 net.onrc.onos.registry.controller.ZookeeperRegistry