[Red5] Serialization in PersistableAttributesStore
thomas wajs
thomas at quedesjeux.com
Thu Nov 29 05:49:33 PST 2007
Hello,
I'm trying to make a custom class in PersistableAttributesStore (like
SharedObject, Scope...) persistent. Note that I dont speak about making
an implementation of IPersistable.
It work fine with int and Integer types (because the underlying
serialization use Output.writeNumber, which differ from
Output.writeObject ).
I took a store class to test :
public class Store{
private int val=0;
public void increment(){val++;}
}
First it won't work at all when i restart the server, cause I've got a
ClassNotFoudExcepion on connect whatever i do. Any idea on this point ?
Second I tried to setAttribute on the scope of a room which will start
and stop as client come and go. There, serialization will work fine if i
declare Store as a bean with setVal and getVal. Another option is to
make val public.
But what i want is to perform custom serialization in my real class.
Because I dont want to set up dozens of getter/setter pair, and of
course I want to keep my private visibility.
So I looked up in the API and sources and found IExternalizable which
seem perfect. It has readExternal(IDataInput input) /
writeExternal(IDataOutput output)
I wrote them in Store with input.readInt(val)/output.writeInt(val), but
it just wont do the work, as far as i saw. Now i'm kinda stuck about
this custom persistence thing, and cant see any solution to make it
working. If anyone have an idea about that, I'll be glad to hear it.
Finally, a little thing I found strange is that filePersistence is built
on the top of amf Serialization, because it use the Output/Input impl
from org.red5.io.amf (see org.red5.server.persistence.FilePersistence
line 34).
Thanks all
Thomas
More information about the Red5
mailing list