01 /*
02 * Copyright 2008-2016 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.groovy;
17
18 import griffon.builder.core.CoreBuilderCustomizer;
19 import griffon.core.addon.GriffonAddon;
20 import griffon.core.event.EventRouter;
21 import griffon.core.injection.Module;
22 import griffon.core.mvc.MVCGroupFactory;
23 import griffon.core.mvc.MVCGroupManager;
24 import griffon.util.BuilderCustomizer;
25 import griffon.util.CompositeResourceBundleBuilder;
26 import griffon.util.ConfigReader;
27 import org.codehaus.griffon.runtime.core.i18n.MessageSourceDecoratorFactory;
28 import org.codehaus.griffon.runtime.core.injection.AbstractModule;
29 import org.codehaus.griffon.runtime.core.resources.ResourceResolverDecoratorFactory;
30 import org.codehaus.griffon.runtime.groovy.event.GroovyAwareDefaultEventRouter;
31 import org.codehaus.griffon.runtime.groovy.i18n.GroovyAwareMessageSourceDecoratorFactory;
32 import org.codehaus.griffon.runtime.groovy.mvc.GroovyAwareMVCGroupFactory;
33 import org.codehaus.griffon.runtime.groovy.mvc.GroovyAwareMVCGroupManager;
34 import org.codehaus.griffon.runtime.groovy.resources.GroovyAwareResourceResolverDecoratorFactory;
35 import org.codehaus.griffon.runtime.groovy.util.GroovyAwareCompositeResourceBundleBuilder;
36 import org.kordamp.jipsy.ServiceProviderFor;
37
38 import javax.inject.Named;
39
40 import static griffon.util.AnnotationUtils.named;
41
42 /**
43 * @author Andres Almiray
44 * @since 2.0.0
45 */
46 @Named("groovy")
47 @ServiceProviderFor(Module.class)
48 public class GroovyModule extends AbstractModule {
49 @Override
50 protected void doConfigure() {
51 // tag::bindings[]
52 bind(ConfigReader.class)
53 .toProvider(ConfigReader.Provider.class)
54 .asSingleton();
55
56 bind(CompositeResourceBundleBuilder.class)
57 .to(GroovyAwareCompositeResourceBundleBuilder.class)
58 .asSingleton();
59
60 bind(GriffonAddon.class)
61 .to(GroovyAddon.class)
62 .asSingleton();
63
64 bind(EventRouter.class)
65 .withClassifier(named("applicationEventRouter"))
66 .to(GroovyAwareDefaultEventRouter.class)
67 .asSingleton();
68
69 bind(EventRouter.class)
70 .to(GroovyAwareDefaultEventRouter.class);
71
72 bind(MVCGroupFactory.class)
73 .to(GroovyAwareMVCGroupFactory.class)
74 .asSingleton();
75
76 bind(MVCGroupManager.class)
77 .to(GroovyAwareMVCGroupManager.class)
78 .asSingleton();
79
80 bind(BuilderCustomizer.class)
81 .to(CoreBuilderCustomizer.class)
82 .asSingleton();
83
84 bind(ResourceResolverDecoratorFactory.class)
85 .to(GroovyAwareResourceResolverDecoratorFactory.class);
86
87 bind(MessageSourceDecoratorFactory.class)
88 .to(GroovyAwareMessageSourceDecoratorFactory.class);
89 // end::bindings[]
90 }
91 }
|