
| Key: |
XSTR-358
|
| Type: |
Bug
|
| Status: |
Closed
|
| Resolution: |
Fixed
|
| Assignee: |
Unassigned
|
| Reporter: |
Steve Tynor
|
| Votes: |
0
|
| Watchers: |
1
|
|
If you were logged in you would be able to see more operations.
|
|
|
XStream
Created: 26/Oct/06 05:14 PM
Updated: 09/Nov/06 04:58 PM
|
|
| Component/s: |
None
|
| Affects Version/s: |
None
|
| Fix Version/s: |
1.2.1
|
|
| JDK version and platform: |
Sun 1.5
|
|
I have converters that require intitialization via their constructors (common functionality in an AbstractConverter and text like:
public class MatrixIdConverter extends AbstractMapConverter {
public MatrixIdConverter() {
super("matrix id", ServiceLocator.getMapManager().getMatrixNameMap());
}
}
the problem is that such a converter invoked via an @XStreamConverter(MatrixIdConverter.class) annotation does not work -- due to using Sun14ReflectionProvider to instantiate the converter object (AnnotationReflectionConverter.java at about line 35):
protected void marshallField(final MarshallingContext context,
Object newObj, Field field) {
XStreamConverter annotation = annotationProvider.getAnnotation(field, XStreamConverter.class);
if (annotation != null) {
context.convertAnother(newObj, (Converter) reflectionProvider
.newInstance(annotation.value()));
} else {
context.convertAnother(newObj);
}
}
Just because I want to use the non-constructor serialization for my XML serialization does not mean I want to avoid constructors for my converters. Is there a way to avoid this? (I.e. I would think that the code should always use pure Java reflection for instantiating "worker" objects and only use Sun14 style reflection for instantiating deserialized objects.)
|
|
Description
|
I have converters that require intitialization via their constructors (common functionality in an AbstractConverter and text like:
public class MatrixIdConverter extends AbstractMapConverter {
public MatrixIdConverter() {
super("matrix id", ServiceLocator.getMapManager().getMatrixNameMap());
}
}
the problem is that such a converter invoked via an @XStreamConverter(MatrixIdConverter.class) annotation does not work -- due to using Sun14ReflectionProvider to instantiate the converter object (AnnotationReflectionConverter.java at about line 35):
protected void marshallField(final MarshallingContext context,
Object newObj, Field field) {
XStreamConverter annotation = annotationProvider.getAnnotation(field, XStreamConverter.class);
if (annotation != null) {
context.convertAnother(newObj, (Converter) reflectionProvider
.newInstance(annotation.value()));
} else {
context.convertAnother(newObj);
}
}
Just because I want to use the non-constructor serialization for my XML serialization does not mean I want to avoid constructors for my converters. Is there a way to avoid this? (I.e. I would think that the code should always use pure Java reflection for instantiating "worker" objects and only use Sun14 style reflection for instantiating deserialized objects.)
|
Show » |
|