[SOLVED] How to save IOObject to repository
StaryVena
New Altair Community Member
Hello,
I would like to save IOObjects from ImageProcessing extension to repository, but ImagePlus class, which is essential class in ImageProcessing IOObject, doesn't support serialization. How to serialize image is described in http://imagej.1557.n6.nabble.com/Re-ImagePlus-Serializable-td3681988.html. In AbstractIOObject is write() method, but it has final modifier so it can't be overridden.
Is there a way how to implement my own serialization and de-serialization method? Or is there other solution?
I greet and thank you for your answers.
Vaclav
I would like to save IOObjects from ImageProcessing extension to repository, but ImagePlus class, which is essential class in ImageProcessing IOObject, doesn't support serialization. How to serialize image is described in http://imagej.1557.n6.nabble.com/Re-ImagePlus-Serializable-td3681988.html. In AbstractIOObject is write() method, but it has final modifier so it can't be overridden.
Is there a way how to implement my own serialization and de-serialization method? Or is there other solution?
I greet and thank you for your answers.
Vaclav
0
Answers
-
No one? Does it means, that there is no solution?0
-
Hi,
I've never used it, but the Serializable interface JavaDoc says:
Classes that require special handling during the serialization and deserialization process must implement special methods with these exact signatures:
private void writeObject(java.io.ObjectOutputStream out)
throws IOException
private void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException;
private void readObjectNoData()
throws ObjectStreamException;
You could try to handle your special cases there.
Regards,
Marco
0 -
Hello Marco,
I know this method, but I would like to save an image to the repository by clicking on "Store this result in the repository." (highlighted in the picture) and I'm pretty sure that method writeObject(java.io.ObjectOutputStream out) will not be called.
So, is there any way to do this?
Thanks,
Vaclav0 -
Hello,
I hope that Simon could know answer to this problem
Thanks,
Vaclav0 -
Hi,
let's trace what happens when you click that button.
See JavaDoc of method in step 9 which is a standard serialization method offered by Java. So it should indeed use your custom writeObject(ObjectOutputStream out) method and the other 2 I mentioned earlier. Did you try it and it did not work?
1. StoreInRepositoryAction#actionPerformed(ActionEvent e)
2. RepositoryManager#store(IOObject ioobject, RepositoryLocation location, Operator callingOperator, ProgressListener progressListener)
3. Folder#createIOObjectEntry(String name, IOObject ioobject, Operator callingOperator, ProgressListener progressListener)
4. IOObjectEntry#storeData(IOObject data, Operator callingOperator, ProgressListener l)
5. IOObjectSerializer#serialize(OutputStream out, Object object)
6. IOObjectSerializer#serialize(OutputStream out, Object object, SerializationType serializationType)
7. BodySerializer#serialize(Object object, OutputStream out) aka in this case XMLBodySerializer#serialize(Object object, OutputStream out)
8. XMLSerialization#writeXML(Object object, OutputStream out)
9. ObjectOutputStream#writeObject(Object obj)
Regards,
Marco0 -
Hello,
thank you. Now I see, how it works.
Vaclav0