Hi there,
the clone() operation on a XMLConfiguration does not work correctly due
to the following problem:
private class XMLFileConfigurationDelegate extends
FileConfigurationDelegate
{
public void load(InputStream in) throws ConfigurationException
{
XMLConfiguration.this.load(in);
}
}
Obviously the delegate references the XMLConfiguration instance it is
created in. Thus when calling
public Object clone()
{
XMLConfiguration copy = (XMLConfiguration) super.clone();
// clear document related properties
copy.document = null;
copy.setDelegate(createDelegate());
// clear all references in the nodes, too
copy.getRoot().visit(new NodeVisitor()
{
public void visitBeforeChildren(Node node, ConfigurationKey
key)
{
node.setReference(null);
}
}, null);
return copy;
}
the delegate still references the original XMLConfiguration, thus will
save the content of the original one
to file instead of the clone as expected! Changing the code like this
copy.setDelegate(copy.createDelegate());
solves the problem! Now the cloned XMLConfiguration with all its applied
changes can be saved!
Regards,
CAK
--
Carsten Kaiser
Principal Consultant
mailto:[EMAIL PROTECTED]
Mobile: +49 (0)170 5270206
Valtech GmbH
Werner-Heisenberg-Straße 2
63263 Neu-Isenburg
Germany
Phone: +49 (0)6102 88468-0
Fax: +49 (0)6102 88468-28
http://www.valtech.de
Geschäftsführer: Ingo Kriescher
Amtsgericht Düsseldorf HRB48672