frjaeger220 / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Decorators, that injection point can ask to have applied ad-hoc #96

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Let's say I want to support the following:

  @Inject RemoteService service;

or

  @Inject @ShortTimeout RemoteService service;

Currently this requires two different bindings and some ugly coding.  And
then if you want the short timeout for AnotherRemoteService you do it all
over again.  

Instead we could provide a way to independently bind the @ShortTimeout
annotation to a generic decorator such as

  interface Decorator<T> {
    T decorate(T t);
  }
  public class ShortTimeoutDecorator<T> implements Decorator<T> {
    public ShortTimeoutDecorator(Class<T> type, long time, TimeUnit unit) {
      ...
    }
    public T decorate(T t) {
      ...
    }
  }

Now you could just apply that to anything you want.

Original issue reported on code.google.com by kevin...@gmail.com on 24 Apr 2007 at 9:58

GoogleCodeExporter commented 9 years ago
Issue 307 has been merged into this issue.

Original comment by limpbizkit on 27 Apr 2009 at 6:10

GoogleCodeExporter commented 9 years ago
See issue 307, including an extension that implements this.
http://javaonhorse.googlecode.com/svn/branches/pre-0.1-taowen-spike-2/javaonhors
e-
auxiliary/src/main/java/com/google/inject/chain/

Original comment by limpbizkit on 27 Apr 2009 at 6:11

GoogleCodeExporter commented 9 years ago
Hi, will these Chain API be a extension on guice as it is AssistedInject?

Original comment by cvgav...@gmail.com on 13 Jan 2010 at 4:48

GoogleCodeExporter commented 9 years ago
It looks like an extension (see comment #2) already implements this.  

Original comment by sberlin on 2 May 2010 at 12:49