[protobuf] Re: UnmodifiableLazyStringList is not Serializable

2011-04-15 Thread J.S.
Ok, I got it:

- the buffer at once is serializable
- a attribut of the buffer (a repeated string) might be not

so I have to copy the UnmodifiableLazyStringList to an ArrayList if
I'd like to use the attribut as an argument to pass between beans.

Pro: I dont need to include protobuf.jar into all beans if I pass
plain java collections.
Con: I have to copy the list. UnmodifiableLazyStringList could de
serializable.

js

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Re: UnmodifiableLazyStringList is not Serializable

2011-04-14 Thread J.S.
Hi!

Most of the classes are already implementing Serializable. Maybe
UnmodifiableLazyStringList  was just forgotten. I'll add Serializable
to this class and will try again. Maybe this simple thing is enough.

js

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] Re: UnmodifiableLazyStringList is not Serializable

2011-04-13 Thread Jason Hsueh
Also don't have enough Java-fu, but I'd thought this was basically how this
was solved: the messages override some function that cause the JavaVM to
serialize using protobuf serialization. I was under the impression that the
message internals would then no longer needed to implement Serializable.

(Specifically I think the magic is in
http://code.google.com/apis/protocolbuffers/docs/reference/java/serialized-form.html#com.google.protobuf.GeneratedMessageLite
)

On Wed, Apr 13, 2011 at 5:11 PM, Henner Zeller  wrote:

> On Wed, Apr 13, 2011 at 16:01, Ben Wright  wrote:
> > I agree with J.S. on this one - there are many situations in Java EE
> > environments where "Serializable" is checked or java serialization
> > used when it's not simple or feasible to leverage protobuf
> > serialization.  Most of these situations are "invm / in memory"
> > transfers.  Sometimes java serialization is used to clone objects or
> > to safely pass them between ClassLoader scopes.
> >
> > I've run into this limitation with JBoss ESB and passing protocol
> > buffer objects between services through the "InVM" message transport.
>
> It is a couple of years that I've worked with Java, so my
> serialization fu might not be up-to-par. But would the problem be
> solved if the ProtocolBuffer object implements Externalizable ? That
> way it can be serialized via the Java VM, but it would use the
> protobuf specific serialization.
>
> -h
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to protobuf@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



Re: [protobuf] Re: UnmodifiableLazyStringList is not Serializable

2011-04-13 Thread Henner Zeller
On Wed, Apr 13, 2011 at 16:01, Ben Wright  wrote:
> I agree with J.S. on this one - there are many situations in Java EE
> environments where "Serializable" is checked or java serialization
> used when it's not simple or feasible to leverage protobuf
> serialization.  Most of these situations are "invm / in memory"
> transfers.  Sometimes java serialization is used to clone objects or
> to safely pass them between ClassLoader scopes.
>
> I've run into this limitation with JBoss ESB and passing protocol
> buffer objects between services through the "InVM" message transport.

It is a couple of years that I've worked with Java, so my
serialization fu might not be up-to-par. But would the problem be
solved if the ProtocolBuffer object implements Externalizable ? That
way it can be serialized via the Java VM, but it would use the
protobuf specific serialization.

-h

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Re: UnmodifiableLazyStringList is not Serializable

2011-04-13 Thread Ben Wright
I agree with J.S. on this one - there are many situations in Java EE
environments where "Serializable" is checked or java serialization
used when it's not simple or feasible to leverage protobuf
serialization.  Most of these situations are "invm / in memory"
transfers.  Sometimes java serialization is used to clone objects or
to safely pass them between ClassLoader scopes.

I've run into this limitation with JBoss ESB and passing protocol
buffer objects between services through the "InVM" message transport.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Re: UnmodifiableLazyStringList is not Serializable

2011-04-13 Thread J.S.
Hi!


> Protocol buffers are objects to serialize things, but it doesn't
> really make sense to use Java serialization to serialize their holder
> objects.
I'd like to pass Java objects from a unserialized protocol buffer
between
Beans inside a application server. This makes sense to me.


> If you would try to Java serialize the protocol buffer objects, you
> would loose all the functionality you were probably considering using
> Protocol buffers in the first place: version independent, fast and
> platform independent serialization. The object layout might change
> between each protocol buffer library version or you might just change
> the proto definition - all of which will create trouble if you use
> Java serialization; the protocol buffer binary format, however, is
> stable (and compact, and fast, and platform independent ...)
I think you got it wrong: I'm not going to store a protocol-buffer in
a
java-serialized from, I just need to pass it as an argument between
beans.

> So in this case it was actually good that the
> UnmodifiableLazyStringList was not Java serializable - it helped you
> find an improper use.
The deserialized protocol buffers are already implementing teh
Serializable
interface. Only if you have a repeated String field, it breaks. So I
consider
it as a bug.

> I am not sure what the maintainers think, but I wouldn't add Java
> 'Serializable' to all classes used within the generated objects -
> because then these accidental wrong uses would just go unnoticed.
Sometimes it's just nessesary. And 98% of the buffers are already
Serializable. So somebody has need it before me.

yours

juergen

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.