protected function _actionDispatch(AnCommandContext $context)
    {
        dispatch_plugin('system.onBeforeDispatch', array( $context ));
        
        $name = 'com_'.$this->getComponent()->getIdentifier()->package;

        define('ANPATH_COMPONENT', ANPATH_BASE.DS.'components'.DS.$name);

        if (! file_exists(ANPATH_COMPONENT)) {
            throw new LibBaseControllerExceptionNotFound(
                'Component '.$name.' not found',
                AnHttpResponse::INTERNAL_SERVER_ERROR
            );
        }

        $app = AnService::get('repos:settings.app')->find(array('package' => $name));

        if (isset($app) && $app->enabled != 1) {
            throw new LibBaseControllerExceptionForbidden(
                'Component '.$name.' is disabled',
                AnHttpResponse::INTERNAL_SERVER_ERROR
            );
        }

        $this->getComponent()->dispatch($context);

        dispatch_plugin('system.onAfterDispatch', array( $context ));

        $location = $context->response->getHeader('Location');
        $isHtml = $context->request->getFormat() == 'html';
        $isAjax = $context->request->isAjax();

        if (! $location && $isHtml && !$isAjax) {
            $this->_render($context);
        }

        $this->send($context);
    }