i have webservice uses immutable classes in action parameters (that's because of other devs working on project) -- means no public setters. no public setters means webservice won't see properties.
the idea create private setters , add init method annotated postconstruct webservice class. inside init method private setters set accessible through reflections.
the problem init method annotated postconstruct isn't called @ while deploying. im using jax-ws , deploying project glassfish.
what want sounds horrible hack.
you problem, if got right, objects used parameters in actions immutable. fortunately, there tons of way customize jaxb mappings annotations. should possible keep classes immutable, yet make fields visible jaxb.
from this answer, 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 don't fact code above needs no-arg constructor customer(), can have @ more complicated approach.
Comments
Post a Comment