java - How to safely refactor (e.g rename fields) DTO classes returned in JAX-RS web service calls? -
i stumbled upon following problem after refactoring of issuedto (used type of elements in returned list below):
- generated json response has changed dictionary key (keys used strings in our selenium tests refactoring broke tests)
- jsf page accesses issuedto objects using field names (or names converted javabeans-named methods, i'm not sure) access textual, not "typed"
@get @path("/issues/{" + locale_param + "}") @produces(mediatype.application_json) public list<issuedto> getslides(@pathparam(locale_param) final string locale) { final locale currentlocale = (locale == null) ? locale.getdefault() : new locale(locale); return issues.getissuesinlocale(currentlocale); }
how can sure refactoring neither break tests nor break jsf pages? there annotation can apply issuedto fields "freeze" names i.e. de-couple java code names used non-statically-typed-javaee-specific contexts?
assuming plain javaee application (i.e. jax-rs jaxb annotations used json generation), use @xmlelement(name = "fixedname")
decouple actual property names xml and json representation.
Comments
Post a Comment