Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Serialize and event model

Thread view: 
VisionSet - 07 Nov 2005 10:51 GMT
I have a bunch of model classes that I use on client and server.  When a
model object gets serialized all the observers of that model that are my
clients view need to be removed.  But I have internal model observers also -
not sure that was wise?  Now at the present state of the design it is proper
to remove all observers whatever, but that may not end up being the case.  I
know I can track the type of observer that is being added not a problem and
remove certain types when the time comes.  My real question is where do I do
the removal? At present I do it like this:

private void writeObject(ObjectOutputStream s) throws IOException {
 observers.clear();
 s.defaultWriteObject();
}

Can anyone see a problem with that?
At the moment I could declare my observer collection transient, and lazily
reinstantiate, but like I said thats a bit presumptious.
Any other tips in this regard?

TIA

--
Mike W
G Winstanley - 08 Nov 2005 09:09 GMT
> I have a bunch of model classes that I use on client and server.  When a
> model object gets serialized all the observers of that model that are my
[quoted text clipped - 16 lines]
>
> TIA

I don't see why you have to clear the observers. The normal procedure
would be to declare the collection of observers transient, then
re-register them if/when necessary on deserialization.

Stan
VisionSet - 08 Nov 2005 18:37 GMT
> > At the moment I could declare my observer collection transient, and lazily
> > reinstantiate, but like I said thats a bit presumptious.
[quoted text clipped - 3 lines]
> would be to declare the collection of observers transient, then
> re-register them if/when necessary on deserialization.

Yeah that's what I've done, and lazily reinstantiate the collection afer
deserialisation.

Thanks,
--
Mike W
G Winstanley - 09 Nov 2005 12:49 GMT
> > > At the moment I could declare my observer collection transient, and
> lazily
[quoted text clipped - 9 lines]
>
> Thanks,

Oops, I missed that last past of your posting. Shouldn't read things in
a hurry. That should be all you need to do, unless you have some unusual
requirements for some reason.

Stan


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.