You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2009/09/25 18:14:16 UTC

[jira] Created: (SLING-1126) Support serializable objects

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.


[jira] Commented: (SLING-1126) Support serializable objects

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760511#action_12760511 ] 

Carsten Ziegeler commented on SLING-1126:
-----------------------------------------

Yes, I completly agree, my idea is to try to  convert the input stream to the requested Class T if T is either Serializable or extends Serializable.
So there is no need to change the signature. If T is not one of the property types and is not Serializable, the get method can't convert the object (like it is today)

> 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.


[jira] Commented: (SLING-1126) Support serializable objects

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759863#action_12759863 ] 

Carsten Ziegeler commented on SLING-1126:
-----------------------------------------

2) is easy :) as we have the commons dynamic classloader which can be used for this (it uses package admin)
1) is the tricky part - the use cases I have all have a generic nature which means the code calling the get method of the value map does not know the type of the property in advance. Therefore it is using ValueMap.get(String)

> 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.


[jira] Commented: (SLING-1126) Support serializable objects

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760219#action_12760219 ] 

Carsten Ziegeler commented on SLING-1126:
-----------------------------------------

What about trying this for a ValueMap.get(KEY, Serializable) ? The usual property values should all be serializable anyway.

> 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.


[jira] Resolved: (SLING-1126) Support serializable objects

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler resolved SLING-1126.
-------------------------------------

    Resolution: Fixed

In Revision: 819904 I'Ve added support for serializable objects to the jcr backed value map implementation. It's now possible to do a put(String, Serializable) and a get(String, Serializable or any sub class). Before this change these operations failed (get returned null), now this works and everything else is untouched.
Added junit tests

> 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.


[jira] Commented: (SLING-1126) Support serializable objects

Posted by "Julian Sedding (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Resolved: (SLING-1126) Support serializable objects

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler resolved SLING-1126.
-------------------------------------

    Resolution: Fixed

Added support for dynamic class loading in Revision: 819910

> 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.


[jira] Commented: (SLING-1126) Support serializable objects

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760510#action_12760510 ] 

Felix Meschberger commented on SLING-1126:
------------------------------------------

No, this won't probably work because the signature today is

     <T> T get(String key, Class<T> type);

We should not limit the functionality of this method by requiring T to extend Serializable.

> 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.


[jira] Reopened: (SLING-1126) Support serializable objects

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler reopened SLING-1126:
-------------------------------------


Forgot to implement the class loading stuff....

> 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.


[jira] Closed: (SLING-1126) Support serializable objects

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler closed SLING-1126.
-----------------------------------


> 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.


[jira] Commented: (SLING-1126) Support serializable objects

Posted by "Carsten Ziegeler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760244#action_12760244 ] 

Carsten Ziegeler commented on SLING-1126:
-----------------------------------------

Yes, good idea.

> 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.


[jira] Commented: (SLING-1126) Support serializable objects

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759674#action_12759674 ] 

Felix Meschberger commented on SLING-1126:
------------------------------------------

Me thinks, that this is a very interesting idea, but ... ;-)

I see two issues with deserialization:

  (1) I would only support deserialization for the ValueMap.get(String, Class<T>) case where the deserialization can be handled cas the fall back case if the type is none of the defined types in JCR and the property is a binary.

  (2) Classloading. This is probably the harder of the problems to solve. And I have now real clue on how to solve this issue -- other than creating some custom class loader which is able to ask PackageAdmin for bundles providing the required classes ...

> 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.


[jira] Commented: (SLING-1126) Support serializable objects

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-1126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760571#action_12760571 ] 

Felix Meschberger commented on SLING-1126:
------------------------------------------

just checking the type for it being Serializable makes sense, yes

> 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.