Berin Loritsch wrote:
Schaible, Jörg wrote:

Hi Berin,


To make it a little more clear, consider following:
<providers id="p">
    <provider id="a"/>
    <provider id="b" />
</providers>

....<snip>....

Currently I would just create a Container implementation (by extending the AbstratcContainer or DefaultContainer) and use a DefaultContainerManager. Right point to start?


Yep.  Now, you have direct access via protected members to the internal
setup of the container.  When you look at the Map of components, the
first level connects you to a map for all components of the same role.
That Map allows you to access all the components that implement that
role by their id (or hint).

What you want to do to get the collection of providers exposed is
something like this:

    public Provider[] getProviders()
    {
        final Map hintMap = (Map)m_mapper.get( role );
        Provider[] providers = null;

        if( null != hintMap )
        {
            Collection providerSet = hintMap.values();

            providers = new Provider[providerSet.size()];
            Iterator it = providerSet.iterator();

            for ( int i = 0; it.hasNext(); i++ )
            {
                providers[i] = ((ComponentHandler)it.next()).get();
            }
        }
        else
        {
            providers = new Provider[] {};
        }

        return providers;
    }



Just got this working on Fortress and wanted to share a quick note: the hintMap contains more than just the ComponentHandlers, it also contains a FortressServiceSelector and an extra entry for the default component.
So, you have to use something like


Object o = it.next();
if ( o instanceof ComponentHandler ) {
    ...
    providers.add( ((ComponentHandler)o).get() );

}

return (Provider[])providers.toArray( new Provider[] {});

Still have to figure out the cleanest way to get rid of the default component...

- Filip


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



Reply via email to