[ 
https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760221#action_12760221
 ] 

Julian Sedding commented on SLING-1126:
---------------------------------------

To add a bit of flexibility, it should probably be ValueMap.get(String, Class<T 
extends Serializable>), returning T. This would cater for both:

Serializable s = valueMap.get(key, Serializable.class);

and if Foo implements Serializable:

Foo f = valueMap.get(key, Foo.class);

thus avoiding unnecessary casts, when the expected type is known.

> Support serializable objects
> ----------------------------
>
>                 Key: SLING-1126
>                 URL: https://issues.apache.org/jira/browse/SLING-1126
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.0.4
>            Reporter: Carsten Ziegeler
>            Assignee: Carsten Ziegeler
>             Fix For: JCR Resource 2.0.6
>
>
> The JcrPropertyMap and JcrModifiablePropertyMap only support reading and 
> writing the object types supported by JCR. It is currently not possible to 
> store any serializable objects.
> Supporting the writing of serializable objects is easy, we just have to 
> enhance the JcrModifiablePropertyMap to write the serialized object into the 
> repository (through an ObjectOutputStream).
> Reading a serialized object is more tricky as the implementation does not 
> know in advance, if the input stream contains a serialized object or some 
> arbitrary data.
> The check for this is a little bit expensive as it would require to first try 
> to read the data through an ObjectInputStream and if that success we have the 
> serialized object. If this is not successful, a new input stream has to be 
> used.
> As I think that this is a very valuable feature (for example the Sling 
> eventing has a use case for this), we should do this special check only under 
> certain circumstances, for example
> a) if ValueMap.get(KEY) is invoked and  the property is an input stream
> or
> b) if ValueMap.get(KEY, Object.class) is used
> Any other ideas, suggestions?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to