On 2/26/07, Konstantin Priblouda <[EMAIL PROTECTED]> wrote:

Hi Bob,
I'd like to say that I'm codeveloper of
pico/nanocontainer.


I've used Pico and Nano. Nano uses my AOP framework. You should try Guice.

What's important is that you don't depend on the
> implementation. Depending
> on the interface and annotation is OK. Strings are a
> pain.

We do not depend on string keys to dientify components
- key in container  is just object, and is
needed only in case of ambiguity ( but it could be
string as well )


Using these key objects is more verbose than using annotations with Guice.


Basically I just register this session component -
and my HibernateUserManager receives it in
constructor.

Why do I need an annotation to achieve this?


The annotation indicates which constructor you want injected (to the
framework as well as other programmers). What happens if you forget to
configure a PasswordHasher in Pico? No hashing? That's not very secure.

If you can't annotate a constructor (because you don't control the code),
you can use a custom provider. For example:

class HibernateUserManagerProvider implements Provider<HibernateUserManager>
{
 @Inject Session session;
 @Inject PasswordHasher passwordHasher;
 public HibernateUserManager get() {
   return new HibernateUserManager(session, passwordHasher);
 }
}

Well, there is still a question why it is better than
pico ;)


Write less code, and get better up front checking and better performance.
What more do you want?

Bob

Reply via email to