[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Backup/Restore bug



On Fre, 02 Mär 2001, you wrote:
> On Fri, 02 Mar 2001, Jörg Prante wrote:
> > Hi,
> > 
> > I try to backup an Ozone database, but I can't restore it.
> > 
> > The reason is that a hash object with subclasses ( Hashtable, 
> > HashMap, DxHashMap, whatever) cannot be re-instantiated during restore.
> 
> The problem is that Hashtable (and some other collection classes) are using
> inner classes. Unfortunately we didn't find a way to reconstruct inner classes
> via reflection.

That is right. It is because of the inner classes in HashMap.
Therefore the log:
> > handleValueObjStartElement: java.lang.InstantiationException: 
> > java.util.HashMap$Entry

> 
> However, there _is_ a workaround for Hashtable (can be easily extended for
> other classes). So Hashtable and DxHashMap, which is based on Hashtable)
> _should_ work. Rolf wrote this code. Maybe he known what's going on here?
>
> Falko

The workaround for Hashtable is the HashtableContentHandler. This
ContentHandler handles only this part of the backup-XML which contains the
informaion about the Hashtable.
e.g.
...
<valueObj type="java.util.Hashtable" id="-1296781293"> 	... from here
            <member name="table">
                <valueArray type="[Ljava.util.Hashtable$Entry;" id="402698259">
                    <valueObj type="java.util.Hashtable$Entry" id="-1283936237">
                        <member name="hash">
                            <value type="int" id="-1168068592">1</value>
                        </member>
                        <member name="key">
                            <value type="java.lang.Integer" id="-1283411949">1</value>
                        </member>
                        <member name="value">
                            <value type="java.lang.Integer" id="-1282363373">999</value>
                        </member>
	...  
</valueObj> 						... to here
...

It works in this way:
If the XML2ObjectContentHandler gets a valueObj from type java.util.Hashtable
it creates a new HashtableContentHandler (line 610-612) which will handle the
part from the  hashtable-start-tag to the proper end-tag. 
The HashtableContentHandler notices all key- and value-member-tags and put the
values in a Hashtable (line 124/125). 
When the proper end-tag of Hashtable is reached
the XML2ObjectContentHandler gets the Hashtable and continue his work.

Maybe in this way you can try to write a HashMapContentHandler for your
backup.

Best regards.

Rolf

> > Jörg
> > 
> > -- 
> > Jörg Prante
> > Sevenval AG (HRB 32757) e-business marketing technologies
> > D-50667 Köln . Alter Markt 36-42
> > Fon +49 221 65007-0 . Fax 4249891
> > http://www.sevenval.de . joerg@7val.com
> -- 
> ______________________________________________________________________
> Falko Braeutigam                              mailto:falko@smb-tec.com
> SMB GmbH                                        http://www.smb-tec.com
-- 
______________________________________________________________________
Rolf Kluge                                     mailto:rolf@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com