com.google.gerrit.lifecycle.LifecycleModule Maven / Gradle / Ivy
package com.google.gerrit.lifecycle;
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.extensions.events.LifecycleListener;
import com.google.inject.Singleton;
import com.google.inject.binder.LinkedBindingBuilder;
import com.google.inject.internal.UniqueAnnotations;
import java.lang.annotation.Annotation;
/** Module to support registering a unique LifecyleListener. */
public abstract class LifecycleModule extends FactoryModule {
/**
* @return a unique listener binding.
* To create a listener binding use:
*
* listener().to(MyListener.class);
*
* where {@code MyListener} is a {@link Singleton} implementing the {@link LifecycleListener}
* interface.
*/
protected LinkedBindingBuilder listener() {
final Annotation id = UniqueAnnotations.create();
return bind(LifecycleListener.class).annotatedWith(id);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy