Reputation: 8136
I have the class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ClassFqn", propOrder = { <some properties> })
public class ClassFqn
{
//... Here should be fields, constructor and logic
}
Objects are immutable and I use cached objects pool factory instead of direct creation.
Can I use this pool factory when I do JAXB deserialization for these objects?
Upvotes: 2
Views: 1459
Reputation: 149027
There are a couple of ways that you could support this use case.
@XmlType
to specify Factory Class & MethodYou can use the @XmlType
annotation to specify a factory class and method:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(
name = "ClassFqn",
propOrder = { <some properties> }
factoryClass=ClassFqnFactory.class,
factoryMethod="createClassFqn")
public class ClassFqn
{
//... Here should be fields, constructor and logic
}
For More Information
XmlAdapter
An XmlAdapter
can also be leveraged. Essentially you read the data into a temporary object and then implement the XmlAdapter
to use your own mechanisms to create the final object.
For More Information
Upvotes: 3