File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Serialization Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Serialization Question" Watch "Serialization Question" New topic

Serialization Question

Andrew Prinoli

Joined: Jan 11, 2007
Posts: 22
Hi guys,
I'm working on a distributed application.
My client side sends over tcp socket , serialized messages.The class that I serialize is called "AgentMessage". Serialization and deserialization seems to work correctly...but I have a question about keeping the state of a field (is a Vector) : I'll post the code to explain the's very simple :

public class AgentMessage{
private StaticPart sp;
private DynElement de;
private Vector oldde = new Vector();

public AgentMessage(String agent, byte[] code, String mainclass,Certificate signerId, PrivateKey priv, String configuration,String pack, Serializable dclear, byte[] dsecret, PathEl[] dpath,byte[] c) {

sp = new StaticPart(agent, code, mainclass, signerId,priv,configuration, pack);
de = new DynElement(dclear, dsecret, c, dpath);


My final aim is to maintain in the static vector all the "DynElement" objects....
But ,when the message is deserialized in the server side of this app , I have to create a new instance of the class "AgentMessage" the elements in the vector would be lost.....
How do I mantain a collection of these objects??
Thanks a lot guys....
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Are all of your classes serializable? Is Vector? They will all have to be to make this work.

Show us a bit of your deserializing code. I'm curious about why you say you have to make a new instance of AgentMessage.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Serialization Question
It's not a secret anymore!