Change all the package names from infrautils to odlguice
[odlguice.git] / inject / inject-guice-testutils / src / main / java / org / opendaylight / odlguice / inject / guice / testutils / AbstractCheckedModule.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.odlguice.inject.guice.testutils;
9
10 import com.google.inject.AbstractModule;
11 import com.google.inject.Binder;
12 import org.opendaylight.odlguice.inject.ModuleSetupRuntimeException;
13
14 /**
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}.
18  *
19  * @deprecated Use org.opendaylight.infrautils.inject.guice.AbstractCheckedModule instead.
20  *
21  * @author Michael Vorburger.ch
22  */
23 @Deprecated
24 public abstract class AbstractCheckedModule extends AbstractModule {
25
26     /**
27      * Configures a {@link Binder} via the exposed methods.
28      *
29      * @throws ModuleSetupRuntimeException if binding failed
30      */
31     @Override
32     @SuppressWarnings("checkstyle:IllegalCatch")
33     protected final void configure() throws ModuleSetupRuntimeException {
34         try {
35             checkedConfigure();
36         } catch (Exception e) {
37             throw new ModuleSetupRuntimeException(e);
38         }
39     }
40
41     protected abstract void checkedConfigure() throws Exception;
42
43 }