package com.ctrip.zeus.task;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author:xingchaowang
 * @date: 12/7/2015.
 */
public abstract class AbstractTask implements Task {
    @Resource
    private TaskManager taskManager2;

    @PostConstruct
    private void init() {
        taskManager2.add(this);
        start();
    }

    public abstract void start();

    @Override
    public String getName() {
        return getClass().getSimpleName();
    }

    @Override
    public long getInterval() {
        return 60000;
    }

    public abstract void run() throws Exception;

    @Override
    public void shutDown() {
        stop();
        taskManager2.remove(this);
        taskManager2 = null;
    }

    public abstract void stop();
}

@@ -325,24 +325,41 @@
 id init() %7B%0A
+        start();%0A
         task
@@ -378,33 +378,16 @@
 (this);%0A
-        start();%0A
     %7D%0A%0A 

switch start and add process