<P>Extract the <a href="#URIMappingString">URI Mapping String</a> from the underlying request, and
map it to an {@link Action}.
*/
@Override public final Action getWebAction() {
Action result = null;
AppException problem = new AppException();
Class webAction = fUriToActionMapping.get(fURIMappingString);
if ( webAction == null ) {
throw new RuntimeException("Cannot map URI to an Action class : " + Util.quote(fURIMappingString));
}
Class[] ctorArgs = {RequestParser.class};
try {
Constructor ctor = webAction.getConstructor(ctorArgs);
result = (Action)ctor.newInstance(new Object[]{this});
}
catch(NoSuchMethodException ex){
problem.add("Action does not have public constructor having single argument of type 'RequestParser'.");
}
catch(InstantiationException ex){
problem.add("Cannot call Action constructor using reflection (class is abstract). " + ex);
}
catch(IllegalAccessException ex){
problem.add("Cannot call Action constructor using reflection (constructor not public). " + ex);
}
catch(IllegalArgumentException ex){
problem.add("Cannot call Action constructor using reflection. " + ex);
}
catch(InvocationTargetException ex){
String message = ex.getCause() == null ? ex.toString() : ex.getCause().getMessage();
problem.add("Cannot call Action constructor using reflection (constructor threw exception). " + message);
}
if( problem.isNotEmpty() ){
throw new RuntimeException("Problem constructing Action for URI " + Util.quote(fURIMappingString) + " " + Util.logOnePerLine(problem.getMessages()));
}
fLogger.info("URI " + Util.quote(fURIMappingString) + " successfully mapped to an instance of " + webAction);
return result;
}