Quick working hack :

public void toJSON( Object value, JSONWriter json ) throws JSONException
    {
       ...
        else if( value instanceof ValueComposite )
        {
Class<? extends Composite> valueType = ( (ValueComposite) value ).type(); value = valueType.getCanonicalName()+":"+ ( (ValueComposite) value ).toJSON();
        }

        // Serialize value
      ...

    }

    public Object fromJSON( Object json, Module module )
    {
        try
        {
            ...
            }
            else if( result instanceof String )
            {
                String jsonValue = (String) result;
                final int colonIndex = jsonValue.indexOf(':');
                                String typePart = 
jsonValue.substring(0,colonIndex);
                String jsonPart = jsonValue.substring(colonIndex+1);
Class valueType = module.classLoader().loadClass ( typePart);//type.name() );

result = module.valueBuilderFactory().newValueFromJSON ( valueType, jsonPart);
            }

       ...
    }

Values still in base64 format but working with Value type (not ValueComposite) & subclassing is working too.

It seems that entities are allowed in Property<?> ... feature ?

Phil


Le 26 août 2009 à 11:10, Niclas Hedhman a écrit :

On Wed, Aug 26, 2009 at 4:51 PM, Rickard Öberg<[email protected]> wrote:

These are two unrelated issues. The value serialization has to do with whether the type information comes from the code declaration or if its
embedded in the serialized format. The Association issue is just a
visibility issue, since the type information *is* included in the stored format (i.e. the EntityStore is responsible for knowing which EntityType to
use when deserializing).

Ok, fair enough, but IF we say that there is always a type->composite
lookup, it becomes a related issue. One possible course of action; If
the Property<type> resolves to a ValueComposite then it is used,
otherwise Serializable is assumed. And with such rule, the Visibility
rule would come as baby with the stork... ;-)


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

I  live here; http://tinyurl.com/2qq9er
I  work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug

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

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

Reply via email to