View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.guice;
8   
9   import org.mule.api.transformer.Transformer;
10  import org.mule.tck.testmodels.fruit.BananaFactory;
11  import org.mule.tck.testmodels.mule.TestAgent;
12  
13  import com.google.inject.AbstractModule;
14  import com.google.inject.Provides;
15  import com.google.inject.name.Named;
16  
17  /**
18   * Simple Guice module that binds a service interface
19   */
20  public class ConfigServiceModule extends AbstractModule
21  {
22      protected void configure()
23      {
24          //Our auto transform service component
25          this.bind(AutoTransformServiceInterface.class).to(DefaultAutoTransformService.class);
26  
27          //Injection service component
28          this.bind(BananaServiceInterface.class).to(BananaInjectionService.class);
29  
30          //Will make the transformer available in Mule
31          //this.bind(Transformer.class).to(OrangetoAppleTransformer.class);
32  
33      }
34  
35      //This automatically binds the intance to the return type
36      @Provides
37      BananaFactory provideBananaFactory()
38      {
39          return new BananaFactory();
40      }
41  
42      @Provides
43      TestAgent provideTestAgent()
44      {
45          return new TestAgent();
46      }
47  
48      @Provides @Named("orange-to-apple")
49      Transformer providesOrangetoAppleTransformer()
50      {
51          return new OrangetoAppleTransformer();
52      }
53  }