Params params = pm.getSelectedParam();
PatternParser selectedParser = pm.getSelectedParser();
logger.log(Level.FINE, "selectedParser: " + selectedParser);
if (params == null) {
throw new ResourceNotFoundException(path + "に対応するフォーマットがありません");
}
String controllerName = params.get(CONTROLLER_PLACEHOLDER_LABEL);
if (controllerName == null) {
throw new RuntimeException(selectedParser + "でコントローラが取得できません");
}
String actionName = params.get(ACTION_PLACEHOLDER_LABEL);
if (actionName == null) {
throw new RuntimeException(selectedParser + "でアクションが取得できません");
}
String fullClassName = getFullControllerClassName(controllerName, rootPackage);
try {
Class<?> clazz = Class.forName(fullClassName);
Controller controller = (Controller) clazz.newInstance();
return new ReflectInvoker(servlet, controller, actionName, params);
} catch (ClassNotFoundException e) {
throw new RuntimeException(path + "に対応する" + fullClassName
+ "クラスが見つかりません", e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (ResourceNotFoundException e){
throw new ResourceNotFoundException("Resource not found for " + selectedParser, e);
}
}