[picocontainer-dev] characteristics, properties, and per component decoration

Mike Rettig <[email protected]> Sat, 14 Aug 2010 15:01:54 -0500
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
I'm working on a port of spruice (http://www.spruice.org) to pico.
Spruice is a programmatic api to wire components using type safe
proxies. It currently uses spring for programmatic object wiring. I'd
like to remove spring due to its heavyweight nature.

I'm having some difficulties porting to pico due to the per component
customizations. I need to pass unique wiring constraints for each and
every component. In the pico docs, I can see how this can be done
using the Characteristics class and Properties. Is this really the
best way to do this? Is there some other way to do per component
customizations and not use Properties?

e.g.
container.as(MY_PROPERTIES);

I'd prefer a simple decorator chaining api.

PicoDecorator<MyClass> myDecorator = new PicoDecorator<MyClass>(){
    SomeObject dataForThisComponent;
    public MyClass decorate(MyClass instance) {
    .... modify object
     return instance;
   }
};

Properties props = ...bean properties

MutablePicoContainer container = ...
container.createAdapterChain()
             .cache()
             .decorate(myDecorator)
             .setBeanProperties(props)
             .construct(InjectionType.Constructor, MyClass.class);

Thanks,

Mike Rettig

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email