You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Guðmundur Bjarni Ólafsson (JIRA)" <ji...@apache.org> on 2009/04/25 15:01:32 UTC

[jira] Updated: (WICKET-2241) Guice integration doesn't honour optional bindings

     [ 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: 0001-WICKET-2241-Support-for-Guice-s-Inject-optional.patch

Wrote a simple fix which adds an optional parameter to GuiceProxyTargetLocator. Before calling injector.getInstance(key) it checks whether the target is optional, if it is Guice is asked whether a binding exists (via injector.getBinding(key)) and if there is no binding a null is returned from the locator. Otherwise it just proceeds as it did before.

> 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
>            Priority: Minor
>         Attachments: 0001-WICKET-2241-Support-for-Guice-s-Inject-optional.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.