Also, InjectorHolder.getInjector().inject(this) does not work with guice, it returns an illegalstateexception saying there's no injector assigned for the holder. It would be nice to have more documentation on how to use salve, regards.

Edgar Merino



Guðmundur Bjarni escribió:
I agree that static injection is fugly, it makes unit tests very sad and
kills puppies, but in some cases its a necessary evil. Lets say for example
that it is only needed in a very few cases, then IMO pulling in Salve is a
bit of an overkill. I've tried out Salve, liked it but it's a bit of a
commitment to use compile time weaving/instrumentation.
Last I checked, the InjectorHolder only worked with Spring and not with
Guice. I looked into fixing that some time ago but didn't finish that work.
I've got more time now if someone is interested? :)

regards,
Guðmundur Bjarni


igor.vaynberg wrote:
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




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to