📄 activator.java
字号:
package net.sf.pim.scheduler;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jcrontab.Crontab;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "net.sf.pim.scheduler";
// The shared instance
private static Activator plugin;
// This variable defines the Crontab
static private Crontab crontab = null;
/**
* The constructor
*/
public Activator() {
plugin = this;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
crontab = Crontab.getInstance();
try {
ShutdownHook();
crontab.getInstance().init();
System.out.println("Working...");
} catch (Exception e) {
e.printStackTrace();
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
public static void ShutdownHook() throws Exception {
try {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("Shutting down...");
// stops the system in 200 miliseconds :-)
crontab.uninit(200);
System.out.println("Stoped");
}
});
} catch (Exception e) {
throw new Exception(e.toString());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -