Changeset 1121

Show
Ignore:
Timestamp:
12/06/07 15:58:26 (7 months ago)
Author:
mikey
Message:

added website cache factory and interface for cachable processors and support for them in the front controller (part of enhancement #116)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/stubFrontController.php

    r1098 r1121  
    1414                      'net.stubbles.util.stubRegistry', 
    1515                      'net.stubbles.util.stubRegistryInitializer', 
     16                      'net.stubbles.websites.cache.stubWebsiteCacheFactory', 
    1617                      'net.stubbles.websites.processors.stubProcessorResolverFactory' 
    1718                       
     
    5556     */ 
    5657    protected $response; 
     58    /** 
     59     * factory for the website cache 
     60     * 
     61     * @var  stubWebsiteCacheFactory 
     62     */ 
     63    protected $websiteCacheFactory; 
    5764 
    5865    /** 
     
    115122 
    116123    /** 
     124     * sets the website cache factory to be used 
     125     * 
     126     * @param  stubWebsiteCacheFactory  $websiteCacheFactory 
     127     */ 
     128    public function setWebsiteCacheFactory(stubWebsiteCacheFactory $websiteCacheFactory) 
     129    { 
     130        $this->websiteCacheFactory = $websiteCacheFactory; 
     131    } 
     132 
     133    /** 
    117134     * does the whole processing 
    118135     */ 
     
    124141        foreach ($this->interceptorInitializer->getPreInterceptors() as $preInterceptor) { 
    125142            $preInterceptor->preProcess($this->request, $this->session, $this->response); 
    126             if ($this->request->isCancelled() == true) { 
     143            if ($this->request->isCancelled() === true) { 
    127144                $this->response->send(); 
    128145                return; 
     
    130147        } 
    131148         
     149        if (null !== $this->websiteCacheFactory) { 
     150            $this->websiteCacheFactory->configure($processor); 
     151        } 
     152         
    132153        $this->response = $processor->process()->getResponse(); 
    133         if ($this->request->isCancelled() == false) { 
     154        if ($this->request->isCancelled() === false) { 
    134155            foreach ($this->interceptorInitializer->getPostInterceptors() as $postInterceptor) { 
    135156                $postInterceptor->postProcess($this->request, $this->session, $this->response); 
    136                 if ($this->request->isCancelled() == true) { 
     157                if ($this->request->isCancelled() === true) { 
    137158                    break; 
    138159                } 
  • trunk/src/test/php/net/stubbles/websites/stubFrontControllerProcessTestCase.php

    r737 r1121  
    1818Mock::generate('stubProcessorResolverFactory'); 
    1919Mock::generate('stubRegistryInitializer'); 
     20Mock::generate('stubWebsiteCacheFactory'); 
    2021require_once dirname(__FILE__) . '/TeststubFrontController.php'; 
    2122/** 
     
    7576     */ 
    7677    protected $mockProcessor; 
    77      
     78    /** 
     79     * mocked website cache factory 
     80     * 
     81     * @var  stubWebsiteCacheFactory 
     82     */ 
     83    protected $mockWebsiteCacheFactory; 
     84 
    7885    /** 
    7986     * set up test environment 
     
    97104        $this->mockResponse2   = new MockstubResponse(); 
    98105        $this->mockProcessor->setReturnValue('getResponse', $this->mockResponse2); 
     106        $this->mockWebsiteCacheFactory = new MockstubWebsiteCacheFactory(); 
    99107    } 
    100108 
     
    117125        $this->mockProcessor->setReturnValue('getInterceptorDescriptor', 'interceptors'); 
    118126        $this->mockProcessor->expectNever('process'); 
     127        $this->mockWebsiteCacheFactory->expectNever('configure'); 
     128        $this->frontController->setWebsiteCacheFactory($this->mockWebsiteCacheFactory); 
    119129        $this->frontController->process(); 
    120130    } 
    121      
     131 
    122132    /** 
    123133     * assure that processing ends when request is cancelled 
     
    137147        $this->frontController->process(); 
    138148    } 
    139      
     149 
    140150    /** 
    141151     * assure that processing ends when request is cancelled 
     
    156166        $this->frontController->process(); 
    157167    } 
    158      
     168 
    159169    /** 
    160170     * assure that processing ends when request is cancelled 
     
    175185        $this->mockResponse2->expectOnce('send'); 
    176186        $this->mockProcessorResolver->expectOnce('resolve'); 
     187        $this->mockWebsiteCacheFactory->expectOnce('configure'); 
     188        $this->frontController->setWebsiteCacheFactory($this->mockWebsiteCacheFactory); 
    177189        $this->frontController->process(); 
    178190    }