there are cases where this approach plain old sucks.

as you mentioned, if its not a component you have to use static injection
which is fugly

class mydataprovider implements idataprovider {
  public mydataprovider() {
     InjectorHolder.getInjector().inject(this);
  }
}

another problem is that the injector creates a proxy which in certain
situations cant be done. eg your dependency is a class from a 3rd party
library that does not have a default constructor, thus cglib cannot create a
proxy.

another advantage of salve is that it _removes_ the field from the class. so
your classes are smaller and there are no serialization problems whatsoever
as far as dependencies go.

-igor

On Tue, Oct 21, 2008 at 4:15 AM, Guðmundur Bjarni <
[EMAIL PROTECTED]> wrote:

>
> I haven't used Salve with Wicket, but I've been using the wicket-guice
> integration quite extensively. The reason I'm answering this is that I feel
> that many of the use cases of Salve can be solved with pure vanilla Guice.
> In cases where you can't control the instantiation of objects, you can use
> static injection, which is a bit dirty, but IMO cleaner than
> instrumentation. :) So this post is maybe a tiny bit off topic. :)
>
> The way I've been doing it is by using the guice-servlet package which
> allows you to extend a GuiceServletContextListener to create a Injector. To
> tell your servlet container about this, put something similar into your
> web.xml:
>
>        <listener>
>
>
> <listener-class>dk.dtu.kiosk.guice.MyGuiceServletContextListener</listener-class>
>        </listener>
>
> Then I use the wicket-guice integration for hooking the two together. To
> bootstrap Wicket with Guice you simply use the following in your web.xml
>
>        <filter>
>                <filter-name>myApplication</filter-name>
>                <filter-class>
>                        org.apache.wicket.protocol.http.WicketFilter
>                </filter-class>
>                <init-param>
>                        <param-name>applicationFactoryClassName</param-name>
>                        <param-value>
>
>  org.apache.wicket.guice.GuiceWebApplicationFactory
>                        </param-value>
>                </init-param>
>                <init-param>
>                        <param-name>injectorContextAttribute</param-name>
>
>  <param-value>com.google.inject.Injector</param-value>
>                </init-param>
>        </filter>
>
> Voila! Now you can use the @Inject annotation in any Wicket component. You
> also have the option of using Providers if you need something dep. injected
> or in the difficult cases static injection.
>
> regards,
> Guðmundur Bjarni
> --
> View this message in context:
> http://www.nabble.com/Salve-and-Guice-tp20087649p20088079.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to