bindAsContract(MyInjectablePerRequest.class).in(RequestScoped.class);
bindAsContract(MyInjectableSingleton.class).in(Singleton.class);
}
});
final RequestScope requestScope = locator.getService(RequestScope.class);
final MyInjectableSingleton myInjectableSingleton = locator.getService(MyInjectableSingleton.class);
assertEquals(myInjectableSingleton, locator.getService(MyInjectableSingleton.class));
final MyInjectablePerRequest myInjectablePerRequest = requestScope.runInScope(new Callable<MyInjectablePerRequest>() {
@Override
public MyInjectablePerRequest call() throws Exception {
final MyInjectablePerRequest myInjectablePerRequest = locator.getService(MyInjectablePerRequest.class);
assertEquals(myInjectablePerRequest, locator.getService(MyInjectablePerRequest.class));
return myInjectablePerRequest;
}
});
requestScope.runInScope(new Runnable() {
@Override
public void run() {
assertNotSame(myInjectablePerRequest, locator.getService(MyInjectablePerRequest.class));
}