package com.boundary.sdk.event;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import org.apache.commons.daemon.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class EchoTask extends TimerTask {
    @Override
    public void run() {
        System.out.println(new Date() + " running ...");
    }
}

public class BoundaryEventDaemon extends EventApplication implements Daemon {
	
	private static Logger LOG = LoggerFactory.getLogger(BoundaryEventDaemon.class);

    private static Timer timer = null;
    
    public BoundaryEventDaemon() {
    	
    }

    public static void main(String[] args) {
//        timer = new Timer();
//        timer.schedule(new EchoTask(), 0, 1000);
    }

    public void init(DaemonContext dc) throws DaemonInitException, Exception {
        System.out.println("initializing ...");
    }

    public void start() throws Exception {
        System.out.println("starting ...");
        boot();
    }

    public void stop() throws Exception {
        System.out.println("stopping ...");
        main.stop();
        
        if (timer != null) {
            timer.cancel();
        }
    }

    public void destroy() {
        System.out.println("done.");
    }
 }


@@ -1,343 +1,744 @@
-package com.boundary.sdk.event;%0Aimport java.util.Date;%0Aimport java.util.Timer;%0Aimport java.util.TimerTask;%0A%0Aimport org.apache.commons.daemon.*;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aclass EchoTask extends TimerTask %7B%0A    @Override%0A    public void run() %7B%0A        System.out.println(new Date() + %22 running ...%22);%0A    %7D%0A%7D
+// Copyright 2014 Boundary, Inc.%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0Apackage com.boundary.sdk.event;%0Aimport java.util.Timer;%0A%0Aimport org.apache.commons.daemon.*;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0Apu
@@ -899,48 +899,8 @@
 ss);
-%0A%0A    private static Timer timer = null;
 %0A   
@@ -998,89 +998,8 @@
 ) %7B%0A
-//        timer = new Timer();%0A//        timer.schedule(new EchoTask(), 0, 1000);
 %0A   
@@ -1093,29 +1093,19 @@
     
-System.out.println(%22i
+LOG.info(%22I
 niti
@@ -1177,33 +1177,20 @@
     
-    System.out.println(%22s
+%09LOG.info(%22S
 tart
@@ -1273,33 +1273,20 @@
     
-    System.out.println(%22s
+%09LOG.info(%22S
 topp
@@ -1321,84 +1321,8 @@
 ();%0A
-        %0A        if (timer != null) %7B%0A            timer.cancel();%0A        %7D%0A
     
@@ -1360,36 +1360,29 @@
     
-    System.out.println(%22done
+%09LOG.info(%22Destroy ..
 .%22);

Clean up ; remove unused imports ; license header