/*
 * Copyright 2016 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package mclab;

import java.net.*;
import java.io.*;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Skeletal ONOS application component.
 */
@Component(immediate = true)
public class AppComponent {

    private final Logger log = LoggerFactory.getLogger(getClass());

    @Activate
	    protected void activate() {
		    try {
		    	/*****************************
		    	 * TODO:
		    	 * 1. make db thread
		    	 * 2. make db command
		    	 * 3. make heartbeat 
			 * 4. make show command
		    	 * ***************************/
			    log.info("Started");
		    }
		    catch(Exception e)
		    {}
    }

    @Deactivate
    protected void deactivate() {
        log.info("Stopped");
    }

}

@@ -655,16 +655,47 @@
 va.io.*;
+%0Aimport java.util.concurrent.*;
 %0A%0Aimport
@@ -1122,16 +1122,476 @@
 ass());%0A
+    protected final String MYSQL_DRIVER = %22com.mysql.jdbc.Driver%22;%0A    protected final String MYSQL_URL = %22jdbc:mysql://localhost:3306/AP_Information?%22 + %22user=root&password=mclab1%22;%0A    protected final String MYSQL_USER = %22root%22;%0A    protected final String MYSQL_PASSWORD = %22mclab1%22;%0A%0A    protected MySQLdb db = null;%0A    protected ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();%0A    protected ThreadPoolExecutor conExecutor;
 %0A    @Ac
@@ -1597,17 +1597,16 @@
 ctivate%0A
-%09
     prot
@@ -1629,17 +1629,16 @@
 ate() %7B%0A
-%09
 %09    try
@@ -1641,22 +1641,300 @@
  try %7B%0A%09
-%09
     %09
+%09db = new MySQLdb(MYSQL_DRIVER,MYSQL_URL, MYSQL_USER, MYSQL_PASSWORD);%0A%09%09%09executor.scheduledAtFixedRate(heartbeatThread, 1, 5, TimeUnit.SECONDS);%0A%0A%09%09%09conExecutor = (ThreadPoolExecutor)(Executors.newCachedThreadPool();%0A%09%09%09conExecutor.execute(new DBThread(db, conExecutor));%0A%09%09    
 /*******
@@ -1962,17 +1962,16 @@
 *%0A%09%09    
-%09
  * TODO:
@@ -1977,17 +1977,16 @@
 :%0A%09%09    
-%09
  * 1. ma
@@ -2004,17 +2004,16 @@
 d%0A%09%09    
-%09
  * 2. ma
@@ -2032,17 +2032,16 @@
 d%0A%09%09    
-%09
  * 3. ma
@@ -2056,17 +2056,20 @@
 beat %0A%09%09
-%09
+    
  * 4. ma
@@ -2090,17 +2090,16 @@
 d%0A%09%09    
-%09
  * *****
@@ -2124,17 +2124,16 @@
 ****/%0A%09%09
-%09
     log.
@@ -2153,17 +2153,15 @@
 %22);%0A
-%09
 %09    %7D%0A
-%09
 %09   
@@ -2180,17 +2180,16 @@
 tion e)%0A
-%09
 %09    %7B%7D%0A
@@ -2245,20 +2245,17 @@
 ate() %7B%0A
-    
+%09
     log.
@@ -2271,16 +2271,139 @@
 pped%22);%0A
+%09    executor.shutdown();%0A%09    conExecutor.shutdown();%0A    %7D%0A%0A    protected void heartbeatThread() %7B%0A    %09%09db.heartbeat();%0A
     %7D%0A%0A%7D

update AppComponet.java