File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization Question

 
Andrew Prinoli
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 problem...it'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);
oldde.add(de);

}



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"....so the elements in the vector would be lost.....
How do I mantain a collection of these objects??
Thanks a lot guys....
Bye!!!
A.P.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic