On Fri, Mar 4, 2011 at 10:38 AM, Rickard Öberg <[email protected]> wrote:

> If I understand the problem correctly, is it that the callback
> currently does not get access to the PropertyDescriptor, and only the
> name? Or is there something else in the current pattern that causes
> the problems?

No, when withState() callback is done, it calls the visitProperties(),
so the 'value provider' has to know what the StateHolder is expecting,
which means one need to dig that up;

ModuleSPI module;

Class typeToInstantiate = ...;
ValueDescriptor vd = module.valueDescriptor( typeToInstantiate.getName() );
StateDescriptor sd = vd.state();
Set<PropertyDescriptor> pd = sd.properties();

And use that in the visitProperties callback loop.

The 'type.getName()' is also not fully type safe, which feels icky by itself.

So, it is not so much a matter of it can't be done, but that it is messy.


One alternative I can think of is that the
StateHolder.visitProperties() provides the PropertyDescriptors.


Cheers
-- 
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

I live here; http://tinyurl.com/3xugrbk
I work here; http://tinyurl.com/24svnvk
I relax here; http://tinyurl.com/2cgsug

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to