1 /** 2 * Copyright (C) 2008 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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 com.google.inject.grapher.demo; 17 18 import com.google.inject.AbstractModule; 19 import com.google.inject.Provides; 20 import com.google.inject.Singleton; 21 import com.google.inject.name.Names; 22 23 /** 24 * Module that adds a variety of different kinds of {@link Bindings} to be used 25 * to generate a comprehensive sample graph. 26 * 27 * @see InjectorGrapherDemo 28 * 29 * @author phopkins (at) gmail.com (Pete Hopkins) 30 */ 31 public class BackToTheFutureModule extends AbstractModule { 32 @Override 33 protected void configure() { 34 bind(DeLorian.class); 35 36 bind(EnergySource.class).annotatedWith(Nuclear.class).to(Plutonium.class); 37 bind(EnergySource.class).annotatedWith(Renewable.class).to(Lightning.class); 38 39 bind(Plutonium.class).toProvider(PlutoniumProvider.class); 40 bind(PinballParts.class).annotatedWith(Used.class).toInstance(new PinballParts()); 41 42 bind(Person.class).annotatedWith(Driver.class).to(MartyMcFly.class).in(Singleton.class); 43 bind(Person.class).annotatedWith(Inventor.class).to(DocBrown.class).in(Singleton.class); 44 45 bindConstant().annotatedWith(Names.named("year")).to("1955"); 46 } 47 48 @Provides 49 public FluxCapacitor provideFluxCapacitor(EnergySource energySource) { 50 return null; 51 } 52 }