2 * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.infrautils.inject.guice;
10 import com.google.inject.AbstractModule;
11 import com.google.inject.Binder;
12 import org.opendaylight.infrautils.inject.ModuleSetupRuntimeException;
15 * Convenience Guice module support class with configure method that allows
16 * throwing checked exceptions, which are caught and re-thrown as unchecked
17 * {@link ModuleSetupRuntimeException}.
19 * @author Michael Vorburger.ch
21 public abstract class AbstractCheckedModule extends AbstractModule {
24 * Configures a {@link Binder} via the exposed methods.
26 * @throws ModuleSetupRuntimeException if binding failed
29 @SuppressWarnings("checkstyle:IllegalCatch")
30 protected final void configure() throws ModuleSetupRuntimeException {
33 } catch (Exception e) {
34 throw new ModuleSetupRuntimeException(e);
38 protected abstract void checkedConfigure() throws Exception;