}
public ServiceStrategy createOutputStrategy(HttpServletResponse response) {
//If verbose exceptions is on then lets make sure they actually get the
// exception by using the file strategy.
ServiceStrategy theStrategy = null;
if (serviceStrategy == null) {
// none set, look up in web application context
serviceStrategy = getServletContext().getInitParameter("serviceStrategy");
}
// do a lookup
if (serviceStrategy != null) {
theStrategy = (ServiceStrategy) context.getBean(serviceStrategy);
}
if (theStrategy == null) {
// default to partial buffer 2
theStrategy = (ServiceStrategy) context.getBean("PARTIAL-BUFFER2");
}
// clone the strategy since at the moment the strategies are marked as singletons
// in the web.xml file.
try {
theStrategy = (ServiceStrategy) theStrategy.clone();
} catch (CloneNotSupportedException e) {
LOGGER.log(Level.SEVERE,
"Programming error found, service strategies should be cloneable, " + e, e);
throw new RuntimeException("Found a strategy that does not support cloning...", e);
}