What you want to do sounds like a horrible hack.
You problem, if I got it right, is that the objects used as parameters in your actions are immutable. Fortunately, there are tons of way to customize the JAXB mappings with annotations. It should be possible to keep your classes immutable, yet make the fields visible to JAXB.
From this answer, I see:
package blog.immutable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="customer")
@XmlAccessorType(XmlAccessType.NONE)
public final class Customer {
@XmlAttribute
private final String name;
@XmlElement
private final Address address;
@SuppressWarnings("unused")
private Customer() {
this(null, null);
}
public Customer(String name, Address address) {
this.name = name;
this.address = address;
}
public String getName() {
return name;
}
public Address getAddress() {
return address;
}
}
If you don't like the fact that the code above needs a no-arg constructor Customer()
, you can have a look at this more complicated approach.