[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Changing the way AbstractVFSDeployment serializes root

alesj do-not-reply at jboss.com
Thu Jun 19 02:52:10 EDT 2008


"scott.stark at jboss.org" wrote : That will also change the vfs relative path. Different vfs context should not matter, but  being able to access the parent breaks the api usage.
  | 
What about this?

  |   private void writeObject(ObjectOutputStream out) throws IOException, URISyntaxException
  |    {
  |       URL url = rootUrl;
  |       if (url == null)
  |       {
  |          VFS vfs = getFile().getVFS();
  |          url = vfs.getRoot().toURL();
  |       }
  |       String pathName = path;
  |       if (pathName == null)
  |          pathName = getFile().getPathName();
  | 
  |       ObjectOutputStream.PutField fields = out.putFields();
  |       fields.put("rootUrl", url);
  |       fields.put("path", pathName);
  |       out.writeFields();
  |    }
  | 
  |    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
  |    {
  |       ObjectInputStream.GetField fields = in.readFields();
  |       rootUrl = (URL) fields.get("rootUrl", null);
  |       path = (String) fields.get("path", null);
  |    }
  | 
And then having a lazy construction on file.

This way a lot less bytes get serialized. ;-)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4159166#4159166

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4159166



More information about the jboss-dev-forums mailing list