The Altair Community is migrating to a new platform to provide a better experience for you. The RapidMiner Community will merge with the Altair Community at the same time. In preparation for the migration, both communities are on read-only mode from July 15th - July 24th, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here.
Options

[SOLVED] How to save IOObject to repository

StaryVenaStaryVena Member Posts: 126 Contributor II
edited November 2018 in Help
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
Tagged:

Answers

  • Options
    StaryVenaStaryVena Member Posts: 126 Contributor II
    No one? Does it means, that there is no solution?
  • Options
    Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,996 RM Engineering
    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
  • Options
    StaryVenaStaryVena Member Posts: 126 Contributor II
    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.

    image

    So, is there any way to do this?

    Thanks,
    Vaclav
  • Options
    StaryVenaStaryVena Member Posts: 126 Contributor II
    Hello,
    I hope that Simon could know answer to this problem  :)

    Thanks,
    Vaclav
  • Options
    Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    let's trace what happens when you click that button.

    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)
    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?

    Regards,
    Marco
  • Options
    StaryVenaStaryVena Member Posts: 126 Contributor II
    Hello,
    thank you. Now I see, how it works.

    Vaclav
Sign In or Register to comment.