Open jojorabbit opened 10 years ago
Without having tried this myself you might want to attempt installing DemoModule as a bootstrap module.
LifecycleInjector.builder().withBootstrapModule(new DemoModule()).builder().build().createInjector();
DemoModule would have to implement BootstrapModule.
Tnx. It works when i bind Interceptor like this in bootstrap module: TraceInterceptor ti = new TraceInterceptor(); binder.bindInterceptor(any(), annotatedWith(Traced.class), ti);
But it hangs after first method executed if i bind it like this: binder.bindInterceptor(subclassesOf(VideoRental.class), any(), ti); not sure what is going on in background. Thanks.
I haven't tried interceptors before. But, a wild guess is that is has something to do with Governator's use of Child Injectors. A recent PR makes child injectors optional. Build from source and run without child injectors and let me know.
I was doing something with interceptors but could not get them working with governator while with guice they work ok. Simple example code can be found here: http://musingsofaprogrammingaddict.blogspot.com/2009/01/guice-tutorial-part-2-method.html
Am getting injecter like this: LifecycleInjector li = LifecycleInjector.builder().build(); Injector injector = li.createInjector(new DemoModule());
from the example above it does not print any invocations like Invocation of method rentMovie() with parameters [1] took 26.0 ms.
but when i get injector with Guice : Injector injector = Guice.createInjector(new DemoModule()); then it prints out all messages.
Is there some example with intercepting methods i did not found anything about aop in wiki? Am i creating injector properly or am i missing something? Thanks.