google-code-export / gwt-platform

Automatically exported from code.google.com/p/gwt-platform
1 stars 0 forks source link

Injecting Logger doesn't work #344

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
--- STEPS TO REPRODUCE ---
Try to bind a logger manually to a presenter class:

       @Inject
       public PagePresenter(final EventBus eventBus, final MyView view,
final MyProxy proxy, final Logger logger)
       {
               super(eventBus, view, proxy);
               this.logger = logger;
       }
       private final Logger logger;

It doesn't work since Gin does not support built-in binding for Logger as in 
Guice.
> [ERROR] No @Inject or default constructor found for class 
java.util.logging.Logger

Try adding @Provides annotation to create it with its non-
default constructor:

public class ClientModule extends AbstractPresenterModule
{
       @Override
       protected void configure()
       {
               ...
       }

       @Provides
       Logger provideLogger() {
               return Logger.getLogger("MyLogger");
       }
}

[ERROR] A binding to java.util.logging.Logger was already configured
at [unknown source].
 at
com.example.test.app.client.gin.ClientModule.provideLogger(ClientModule.java:
40)

--- EXPECTED ---
logger field initialized by injection.

--- ACTUAL ---
Compile Error. See above.

--- SYSTEM ---
Windows 7 x64
Eclipse Indigo
GWT 2.3
GWTP Plugin 0.6.0.201106071126

--- FORUM LINK ---
https://mail.google.com/mail/#inbox/131769efd6689bc0

Original issue reported on code.google.com by omidk...@gmail.com on 29 Jul 2011 at 5:12

GoogleCodeExporter commented 9 years ago
Oops... link to forum post should go here: http://goo.gl/e4Qyq

Original comment by omidk...@gmail.com on 29 Jul 2011 at 5:18

GoogleCodeExporter commented 9 years ago
Is this a valid GWTP issue? Logger is automatically injected in Gin. (I don't 
like that, but they wont change it. :))

Original comment by philippe.beaudoin on 30 Aug 2011 at 3:10