/** @see org.vraptor.Interceptor#intercept(org.vraptor.LogicFlow) */
  public void intercept(LogicFlow flow) throws LogicException, ViewException {
    // if a extended component marked as component,
    // the extended method read as normal Logic Method
    // if Directly invoke the extended logicMethod,
    // redirect to index page
    LogicRequest logicRequest = flow.getLogicRequest();

    ServletContext servletContext = logicRequest.getServletContext();
    WebApplication application =
        (WebApplication) servletContext.getAttribute(WebApplication.class.getName());
    Introspector introspector = application.getIntrospector();
    BeanProvider beanProvider = introspector.getBeanProvider();

    if (isExtendedAnnotationPresent(logicRequest)) {
      // redirect to index page
      ViewService viewService =
          (ViewService) beanProvider.findAttribute(logicRequest, ViewService.class.getName());
      viewService.redirectToAction(Domain.FORUMS, Actions.LIST);
    }

    // TODO: preMethed if need this feature

    // normal logic method execute
    flow.execute();

    // extend method exectute if need
    ActionExtensionManager manager =
        (ActionExtensionManager)
            servletContext.getAttribute(ActionExtensionManager.class.getName());

    LogicDefinition logicDefinition = logicRequest.getLogicDefinition();
    List<LogicDefinition> extendedLogicDefinitions = manager.getLogicDefinition(logicDefinition);

    for (LogicDefinition extendedLogicDefinition : extendedLogicDefinitions) {
      this.execute(extendedLogicDefinition, logicRequest);
    }
  }
  private Object[] readParameter(
      LogicRequest logicRequest, LogicMethod logicMethod, Object componentInstance)
      throws SettingException {
    WebApplication application =
        (WebApplication)
            logicRequest.getServletContext().getAttribute(WebApplication.class.getName());
    Introspector introspector = application.getIntrospector();

    List<MethodParameter> methodParams = logicMethod.getParameters();

    List<ReadParameter> allParams = new ArrayList<ReadParameter>();
    allParams.addAll(methodParams);

    // instantiate parameters
    Object[] methodParamObjects = new Object[methodParams.size()];
    for (int i = 0; i < methodParamObjects.length; i++) {
      try {
        methodParamObjects[i] = methodParams.get(i).newInstance();
      } catch (ComponentInstantiationException e) {
        methodParamObjects[i] = null;
      }
    }

    List<ValidationMessage> problems =
        introspector.readParameters(
            allParams,
            componentInstance,
            logicRequest,
            application.getConverterManager(),
            methodParamObjects);

    if (problems.size() != 0) {
      throw new SettingException(problems.toString());
    }
    return methodParamObjects;
  }