I would like to introduce caching into an existing Spring project which uses JAXB to expose WebServices. Caching will be done on the level of end points. In order to do that
Another way to generate toString() method - JAXB2 Basics Plugins. This way looks better because doesn't use reflection. Example how to do it with maven below.
org.jvnet.jaxb2.maven2
maven-jaxb2-plugin
0.8.2
generate
${project.basedir}/src/main/resources
${project.basedir}/src/main/java
true
-XtoString
org.jvnet.jaxb2_commons
jaxb2-basics
0.6.4
org.jvnet.jaxb2_commons
jaxb2-basics-runtime
0.6.4
As the result you'll get such code.
public String toString() {
final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE;
final StringBuilder buffer = new StringBuilder();
append(null, buffer, strategy);
return buffer.toString();
}
public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) {
strategy.appendStart(locator, this, buffer);
appendFields(locator, buffer, strategy);
strategy.appendEnd(locator, this, buffer);
return buffer;
}
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) {
{
String theName;
theName = this.getName();
strategy.appendField(locator, this, "name", buffer, theName);
}
{
String theBank;
theBank = this.getBank();
strategy.appendField(locator, this, "bank", buffer, theBank);
}
return buffer;
}