Within my web application I have a tool for generating PDF/XLS reports. These "reporters" inherit from a basic controller and they just describe the reporting functionality, something like:
public abstract class Reporter {
getPath() {
return "/reporter/" + getClass().getSimpleName().replace("Reporter", "").toLowerCase() + ".{pdf|xls}";
}
handleRequest() {
// prepare the data
generateReport(...)
// do something with it
// then report pdf or excel
}
}
@Controller
public class DailyReporter extends Reporter {
@Override
void generateReport(...) {}
}
@Controller
public class AverageReporter extends Reporter {
@Override
void generateReport(...) {}
}
In this way I can just describe the data for each Reporter.
Using Spring MVC, the getPath() method is actually part of the Annotation, but using getClass().getSimpleName().toLowerCase() in the annotation is not possible as it needs to be "Compile time constant". Is there a way to do this with Spring MVC?