Merge "Add Mycilla code to odlguice"
[odlguice.git] / inject / inject-guice / src / main / java / org / opendaylight / infrautils / inject / guice / AutoWiringModule.java
1 /*
2  * Copyright (c) 2018 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.infrautils.inject.guice;
9
10 /**
11  * Guice Module with classpath scanning based autowiring.
12  *
13  * @author Michael Vorburger.ch
14  */
15 public class AutoWiringModule extends AbstractCheckedModule {
16
17     protected final GuiceClassPathBinder classPathBinder;
18     private final String packagePrefix;
19
20     public AutoWiringModule(GuiceClassPathBinder classPathBinder, String packagePrefix) {
21         this.classPathBinder = classPathBinder;
22         this.packagePrefix = packagePrefix;
23     }
24
25     @Override
26     protected final void checkedConfigure() throws Exception {
27         classPathBinder.bindAllSingletons(packagePrefix, binder());
28         configureMore();
29     }
30
31     protected void configureMore() throws Exception {
32     }
33 }