...
Code Block | ||
---|---|---|
| ||
import org.openide.modules.OnStart;
import org.openide.modules.OnStop;
import org.openide.windows.OnShowing;
import java.util.concurrent.Callable;
public class Module {
private Module() {
}
@OnStart
public static class StartOp implements Runnable {
@Override
public void run() {
}
}
@OnShowing()
public static class ShowingOp implements Runnable {
@Override
public void run() {
}
}
@OnStop
public static class MaybeStopOp implements Callable {
@Override
public Boolean call() {
return Boolean.TRUE;
}
@OnStop
public static class StopOp implements Runnable {
@Override
public void run() {
}
} |
...
Code Block | ||
---|---|---|
| ||
<dependency> // needed for the @OnStart and @OnStop annotations <groupId>org.netbeans.api</groupId> <artifactId>org-openide-modules</artifactId> <version>RELEASE802</version> </dependency> <dependency> // needed for the @OnShowing annotation <groupId>org.netbeans.api</groupId> <artifactId>org-openide-windows</artifactId> <version>RELEASE802</version> </dependency> |
All OnStart Runnables declared by various modules are invoked in parallel and as soon as possible. Do stuff here which has to be done very early and only once for your module.
All OnShowing Runnables are invoked when the windowing system is started and ready. Here you can initialise your UI components.
- Callable
The OnStop Callables annotated with OnStop are first consulted if shutdown is requested by the user. Callables can prevent the shutdown by returningFalse
. This might be the case if download is still in progress. - Runnable
If all Callables allow the shutdown the Runnables annotated with OnStop are invoked. Here you can clean up allocated resources and shutdown services.