1 package test.guice; 2 3 import com.google.inject.AbstractModule; 4 import com.google.inject.Inject; 5 import com.google.inject.Singleton; 6 7 import org.testng.ITestContext; 8 9 public class GuiceParentModule extends AbstractModule { 10 11 private final ITestContext context; 12 GuiceParentModule(ITestContext context)13 public GuiceParentModule(ITestContext context) { 14 this.context = context; 15 } 16 17 @Override configure()18 protected void configure() { 19 bind(MyService.class).toProvider(MyServiceProvider.class); 20 bind(MyContext.class).to(MyContextImpl.class).in(Singleton.class); 21 bind(ITestContext.class).toInstance(context); 22 } 23 } 24