Re: Speeding up loading snapshots

Karl Wettin <[email protected]>
Newsgroups gmane.comp.java.prevayler
Message-ID <[email protected]>
On Jan 25, 2011, at 7:11 PM, Klaus Wuestefeld wrote:

> the TCOB1 principle:
> http://www.prevayler.org/old_wiki/ThereCanOnlyBeOne.html

Yeah, I don't really like that principle. I prefere using the same class that implements Externalizable and using a static serialVersionUID, where I add a local version to my instance and load/refactor the instance accordingly for what is required. Works great with logs, snaphots and what not. And I don't have to go change my class names.

Something like this:

public class MyClass {
  private static final long serialVersionUID = 1l;

  @Override
  public void writeExternal(ObjectOutput objectOutput) throws IOException {
    objectOutput.writeInt(2); // local object version
    objectOutput.write...
  }

  @Override
  public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException {
    int version = objectInput.readInt();
    if (version == 1) {
      ... =  objectInput.read...
    } else if (version == 2) {
      ... =  objectInput.read...
    } else {
      throw new UnsupportedLocalVersion(version, 1, 2);
    }
  }



	karl

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d

_______________________________________________
To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion
_______________________________________________
"Databases in Memoriam" -- http://www.prevayler.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.