dev@glassfish.java.net

Re: Habitat.getComponent default

From: Sahoo <Sahoo_at_Sun.COM>
Date: Mon, 17 Aug 2009 09:25:57 +0530

Bill,

No, Habitat.getComponent(Class clazz) is not broken. The implementation
is like this:

    public <T> T getComponent(Class<T> clazz) throws ComponentException {
        if(isContract(clazz))
            return getByContract(clazz);
        else
            return getByType(clazz);
    }

If clazz is a contract, then the javadocs of getByContract says it
returns an arbitrary matching instance.

If you want the a service with "null" name, then please call
Habitat.getComponent(Class clazz, String name) with a null value for
name. It is guaranteed to return unnamed instance only.

Thanks,
Sahoo

Bill Shannon wrote:
> Is it possible that Habitat.getComponent is actually what's broken in
> this case? *Should* it be returning the component with no name?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>
>