|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Reference to a Converter object...Hello,
I'm running into an issue, that I have a reference to a "Converted" object. I write a string instead of the whole object since the object will only exist once for that "key" written. My question is why isn't the reference "deserialized" correctly. Thanks, Ben I'm seeing the following error: com.thoughtworks.xstream.converters.ConversionException: Invalid reference ---- Debugging information ---- reference : 120 class : com.cloudswitch.automation.tests.server.TestLocalServer required-type : com.cloudswitch.automation.tests.cloudswitchnode.TestCloudSwitchNode line number : 3385 ------------------------------- The xml in question: <com.cloudswitch.automation.tests.cloudprovider.TestCloudAccount id="120">Amazon</com.cloudswitch.automation.tests.cloudprovider.TestCloudAccount> and in another object: <cloudAccount reference="120"/> The converter does basic static "get" of the object that was registered with the string written to xml: @Override public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { TestCloudAccount cloudAccount = (TestCloudAccount) value; writer.setValue(cloudAccount.getProviderName()); } @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { String providerName = reader.getValue(); return TestCloudAccount.getCloudAccount(providerName); } --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Reference to a Converter object...Hi Ben,
Ben Douglas wrote at Freitag, 16. Oktober 2009 17:42: > Hello, > > I'm running into an issue, that I have a reference to a "Converted" > object. I write a string instead of the whole object since the object > will only exist once for that "key" written. My question is why isn't > the reference "deserialized" correctly. > > Thanks, > Ben > > I'm seeing the following error: > > com.thoughtworks.xstream.converters.ConversionException: Invalid reference > ---- Debugging information ---- > reference : 120 > class : > com.cloudswitch.automation.tests.server.TestLocalServer > required-type : > com.cloudswitch.automation.tests.cloudswitchnode.TestCloudSwitchNode > line number : 3385 > ------------------------------- > > The xml in question: > > <com.cloudswitch.automation.tests.cloudprovider.TestCloudAccount > > > and in another object: > > <cloudAccount reference="120"/> > > The converter does basic static "get" of the object that was registered > with the string written to xml: > > @Override > public void marshal(Object value, HierarchicalStreamWriter writer, > MarshallingContext context) > { > TestCloudAccount cloudAccount = (TestCloudAccount) value; > writer.setValue(cloudAccount.getProviderName()); > } > > @Override > public Object unmarshal(HierarchicalStreamReader reader, > UnmarshallingContext context) > { > String providerName = reader.getValue(); > return TestCloudAccount.getCloudAccount(providerName); > } Actually I cannot really explain what happens. The reference mechanism is implemented in the MarshallingStrategy (selected by XStream's setMode method). At deserialization time the references are kept internally - unless the deserialized object is suddenly null. Are you sure that the "Amazon" instance exists? Did you initialize the XStream in the same way for serialization and deserialization? - Jörg --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |