[ 
https://issues.apache.org/jira/browse/WICKET-2241?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Guðmundur Bjarni Ólafsson updated WICKET-2241:
----------------------------------------------

    Attachment: 0002-Guice-integration-doesn-t-honour-optional-bindings.patch

What Eduardo S. Nunes wrote is 100% correct. I unfortunately didn't try the 
patch with the Guice 2.0 snapshots, which throws a ConfigurationException (this 
exception has default visibility in Guice 1.0, thus catching a 
RuntimeException) if no binding is found.

I've created another patch (and tested) that should be applied on top of the 
one that has already been committed.

> Guice integration doesn't honour optional bindings
> --------------------------------------------------
>
>                 Key: WICKET-2241
>                 URL: https://issues.apache.org/jira/browse/WICKET-2241
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-guice
>            Reporter: Jesse Wilson
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.4-RC3
>
>         Attachments: 
> 0001-WICKET-2241-Support-for-Guice-s-Inject-optional.patch, 
> 0002-Guice-integration-doesn-t-honour-optional-bindings.patch
>
>
> When @Inject(optional=true) is applied and the binding isn't available, 
> wicket should skip the injection silently.
> http://groups.google.com/group/google-guice/browse_thread/thread/2abe9b55ee26a198
> To check whether the binding is available, you need to use a try/catch block:
>   try {
>     Binding binding = injector.getBinding(key);
>     // use the binding
>   } catch (ConfigurationException e) {
>     // the binding isn't available
>   }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to