Tuesday, 20 August 2013

How can I use a LifecycleListener in a gerrit plugin?

How can I use a LifecycleListener in a gerrit plugin?

I'm writing a gerrit plugin and want to close network connections on
plugin restart/shutdown. This can be done using a LifecycleListener.
As far as I know, there are two modes of operation for a gerrit plugin
concerning Guice. One is to not declare anything in the Manifest and use
auto-registration for everything, using annotations like @Listen and
@Export. The other is to create a Guice module and do all wiring manually
in that module.
I'd like to use auto-registration, but I can't make it work with a
LifecycleListener. Adding a @Listen annotation has no effect, the Listener
is getting ignored.
My code looks like this (minimized):
@Listen
@Singleton
public class CommitValidationTest implements CommitValidationListener {
@Listen
public static class Lifecycle implements LifecycleListener {
@Override
public void start() {
// write to log
}
@Override
public void stop() {
// write to log
}
}
}

No comments:

Post a Comment