01 /*
02 * SPDX-License-Identifier: Apache-2.0
03 *
04 * Copyright 2008-2017 the original author or authors.
05 *
06 * Licensed under the Apache License, Version 2.0 (the "License");
07 * you may not use this file except in compliance with the License.
08 * You may obtain a copy of the License at
09 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.codehaus.griffon.runtime.groovy;
19
20 import griffon.builder.core.CoreBuilderCustomizer;
21 import griffon.core.addon.GriffonAddon;
22 import griffon.core.event.EventRouter;
23 import griffon.core.injection.Module;
24 import griffon.core.mvc.MVCGroupFactory;
25 import griffon.core.mvc.MVCGroupManager;
26 import griffon.util.BuilderCustomizer;
27 import griffon.util.ConfigReader;
28 import griffon.util.ResourceBundleLoader;
29 import org.codehaus.griffon.runtime.core.i18n.MessageSourceDecoratorFactory;
30 import org.codehaus.griffon.runtime.core.injection.AbstractModule;
31 import org.codehaus.griffon.runtime.core.resources.ResourceResolverDecoratorFactory;
32 import org.codehaus.griffon.runtime.groovy.event.GroovyAwareDefaultEventRouter;
33 import org.codehaus.griffon.runtime.groovy.i18n.GroovyAwareMessageSourceDecoratorFactory;
34 import org.codehaus.griffon.runtime.groovy.mvc.GroovyAwareMVCGroupFactory;
35 import org.codehaus.griffon.runtime.groovy.mvc.GroovyAwareMVCGroupManager;
36 import org.codehaus.griffon.runtime.groovy.resources.GroovyAwareResourceResolverDecoratorFactory;
37 import org.codehaus.griffon.runtime.groovy.util.GroovyScriptResourceBundleLoader;
38 import org.kordamp.jipsy.ServiceProviderFor;
39
40 import javax.inject.Named;
41
42 import static griffon.util.AnnotationUtils.named;
43
44 /**
45 * @author Andres Almiray
46 * @since 2.0.0
47 */
48 @Named("groovy")
49 @ServiceProviderFor(Module.class)
50 public class GroovyModule extends AbstractModule {
51 @Override
52 protected void doConfigure() {
53 // tag::bindings[]
54 bind(ConfigReader.class)
55 .toProvider(ConfigReader.Provider.class)
56 .asSingleton();
57
58 bind(ResourceBundleLoader.class)
59 .to(GroovyScriptResourceBundleLoader.class)
60 .asSingleton();
61
62 bind(GriffonAddon.class)
63 .to(GroovyAddon.class)
64 .asSingleton();
65
66 bind(EventRouter.class)
67 .withClassifier(named("applicationEventRouter"))
68 .to(GroovyAwareDefaultEventRouter.class)
69 .asSingleton();
70
71 bind(EventRouter.class)
72 .to(GroovyAwareDefaultEventRouter.class);
73
74 bind(MVCGroupFactory.class)
75 .to(GroovyAwareMVCGroupFactory.class)
76 .asSingleton();
77
78 bind(MVCGroupManager.class)
79 .to(GroovyAwareMVCGroupManager.class)
80 .asSingleton();
81
82 bind(BuilderCustomizer.class)
83 .to(CoreBuilderCustomizer.class)
84 .asSingleton();
85
86 bind(ResourceResolverDecoratorFactory.class)
87 .to(GroovyAwareResourceResolverDecoratorFactory.class);
88
89 bind(MessageSourceDecoratorFactory.class)
90 .to(GroovyAwareMessageSourceDecoratorFactory.class);
91 // end::bindings[]
92 }
93 }
|