in web/src/main/java/org/apache/commons/chain2/web/servlet/ChainProcessor.java [159:203]
public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
ServletWebContext<String, Object> context =
new ServletWebContextBase(getServletContext(), request, response);
Catalog<String, Object, ServletWebContext<String, Object>> theCatalog;
if (attribute != null) {
ServletContext servletContext = getServletContext();
Object testAttribute = servletContext.getAttribute(this.attribute);
if (testAttribute instanceof Catalog) {
/* "attribute" should always contain an instance of a
* Catalog class according to the historical chain convention.
* Although, we now double-check that it is in fact a catalog
* here, we still need to suppress warnings because of the
* type erasure of generics. */
@SuppressWarnings("unchecked")
Catalog<String, Object, ServletWebContext<String, Object>> attributeCatalog =
(Catalog<String, Object, ServletWebContext<String, Object>>)testAttribute;
theCatalog = attributeCatalog;
} else {
String msg = "The object stored as the attribute [" +
attribute + "] was not of the expected type [" +
"Catalog]";
throw new IllegalArgumentException(msg);
}
} else if (catalog != null) {
theCatalog = CatalogFactoryBase.<String, Object, ServletWebContext<String, Object>>getInstance()
.getCatalog(catalog);
} else {
theCatalog = CatalogFactoryBase.<String, Object, ServletWebContext<String, Object>>getInstance()
.getCatalog();
}
if (attribute == null) {
request.setAttribute(CATALOG_DEFAULT, theCatalog);
}
Command<String, Object, ServletWebContext<String, Object>> cmd = theCatalog
.<Command<String, Object, ServletWebContext<String, Object>>>getCommand(this.command);
try {
cmd.execute(context);
} catch (Exception e) {
throw new ServletException(e);
}
}