Issue Details (XML | Word | Printable)

Key: CASTOR-2614
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Joachim Grüneis
Reporter: John Huss
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
castor

XML_NAMING configuration cannot be set programmatically

Created: 15/Jan/09 03:07 PM   Updated: 10/Feb/09 12:16 PM   Resolved: 05/Feb/09 04:35 PM
Return to search
Component/s: Core
Affects Version/s: 1.2
Fix Version/s: 1.3

Time Tracking:
Not Specified

File Attachments: 1. Java Source File CastorMixedTest.java (2 kB)

Issue Links:
dependent
 

Testcase included: yes


 Description  « Hide

This code:

public static User unmarshalUser(final java.io.Reader reader)
throws MarshalException, ValidationException { XMLContext context = new XMLContext(); context.setProperty(XMLConfiguration.XML_NAMING, "mixed"); Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setClass(User.class); User user = (User) unmarshaller.unmarshal(reader); return user; }

doesn't work because the XML_NAMING property isn't taking effect at runtime. It can only be set from a properties file.



Larry Chu added a comment - 23/Jan/09 03:41 PM

XML_NAMING is org.exolab.castor.xml.naming. Changing the property using the methods XMLContext.setProperty() or Marshaller.setProperty() does not change the XMLNaming strategy as I would have expected. I attached a JUnit test.


Joachim Grüneis added a comment - 27/Jan/09 04:23 PM

I think I have a quick solution to solve this...
there are some values - e.g. XMLNaming - that are not instantiated from the property by each access but only the first time; afterwards the preinitialized value is used
the quick solution is to extend the setProperty method to set all those values to null


Joachim Grüneis added a comment - 29/Jan/09 06:06 PM

The patch at issue 2630 also solves this problem.
Thx for the test I used it as base for my patch.


Joachim Grüneis added a comment - 05/Feb/09 04:35 PM

The patch which fixes the problem is committed together with the test case.