EbeanModule.java
01 /*
02  * Copyright 2014-2017 the original author or authors.
03  *
04  * Licensed under the Apache License, Version 2.0 (the "License");
05  * you may not use this file except in compliance with the License.
06  * You may obtain a copy of the License at
07  *
08  *     http://www.apache.org/licenses/LICENSE-2.0
09  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.codehaus.griffon.runtime.ebean;
17 
18 import griffon.core.Configuration;
19 import griffon.core.addon.GriffonAddon;
20 import griffon.core.injection.Module;
21 import griffon.inject.DependsOn;
22 import griffon.plugins.ebean.EbeanServerHandler;
23 import griffon.plugins.ebean.EbeanServerFactory;
24 import griffon.plugins.ebean.EbeanServerStorage;
25 import org.codehaus.griffon.runtime.core.injection.AbstractModule;
26 import org.codehaus.griffon.runtime.util.ResourceBundleProvider;
27 import org.kordamp.jipsy.ServiceProviderFor;
28 
29 import javax.inject.Named;
30 import java.util.ResourceBundle;
31 
32 import static griffon.util.AnnotationUtils.named;
33 
34 /**
35  @author Andres Almiray
36  */
37 @DependsOn("datasource")
38 @Named("ebean")
39 @ServiceProviderFor(Module.class)
40 public class EbeanModule extends AbstractModule {
41     @Override
42     protected void doConfigure() {
43         // tag::bindings[]
44         bind(ResourceBundle.class)
45             .withClassifier(named("ebean"))
46             .toProvider(new ResourceBundleProvider("Ebean"))
47             .asSingleton();
48 
49         bind(Configuration.class)
50             .withClassifier(named("ebean"))
51             .to(DefaultEbeanConfiguration.class)
52             .asSingleton();
53 
54         bind(EbeanServerStorage.class)
55             .to(DefaultEbeanServerStorage.class)
56             .asSingleton();
57 
58         bind(EbeanServerFactory.class)
59             .to(DefaultEbeanServerFactory.class)
60             .asSingleton();
61 
62         bind(EbeanServerHandler.class)
63             .to(DefaultEbeanServerHandler.class)
64             .asSingleton();
65 
66         bind(GriffonAddon.class)
67             .to(EbeanAddon.class)
68             .asSingleton();
69         // end::bindings[]
70     }
71 }