@OnStart & @OnStop
Posted
by Geertjan
on Oracle Blogs
See other posts from Oracle Blogs
or by Geertjan
Published on Tue, 10 Jul 2012 20:28:29 +0000
Indexed on
2012/07/10
21:21 UTC
Read the original article
Hit count: 233
/NetBeans IDE
In applications based on NetBeans Platform 7.2, you'll be able to replace all your ModuleInstall classes with this code:
import org.openide.modules.OnStart;
import org.openide.modules.OnStop;
@OnStart
public final class Installer implements Runnable {
@Override
public void run() {
System.out.println("enable something...");
}
@OnStop
public static final class Down implements Runnable {
@Override
public void run() {
System.out.println("disable something...");
}
}
}
Build the module and the annotations result in named services, thanks to @NamedServiceDefinition:
Aside from no longer needing to register the ModuleInstall class in the manifest, performance of startup will be enhanced, if you use the above approach:
© Oracle Blogs or respective owner