protected abstract void configureBindings() throws Exception;
+ /**
+ * Binds instance to both the interfaceClass as well as the implementationClass.
+ *
+ * @param interfaceClass class type of an interface
+ * @param implementationClass class type of implementing class
+ * @param instance an instance implementing both interfaceClass & implementationClass
+ * @param <T> type of interfaceClass
+ */
+ @SuppressWarnings("unchecked")
+ protected <T> void bindTypesToInstance(Class<T> interfaceClass, Class<? extends T> implementationClass,
+ T instance) {
+ if (implementationClass.equals(interfaceClass)) {
+ throw new IllegalArgumentException("interfaceClass should not be the same as implementationClass: "
+ + interfaceClass + "; " + implementationClass);
+ }
+ bind(interfaceClass).toInstance(instance);
+ bind((Class<T>) implementationClass).toInstance(instance);
+ }
+
}
* We do this to avoid having to declare bindings of Listeners asEagerSingleton(),
* because in typical OpenDaylight projects there are Listener classes which are not @Inject,
* but must still be created (so that they're registered).
- * @see <a href="https://github.com/google/guice/wiki/Bootstrap">Guice documentation</a>.
+ * See <a href="https://github.com/google/guice/wiki/Bootstrap">Guice documentation</a>.
*/
protected static final Stage DEFAULT_STAGE = Stage.PRODUCTION;