Changeset 1459

Show
Ignore:
Timestamp:
03/25/08 09:57:21 (3 months ago)
Author:
mikey
Message:

preparation of enhancement #133: refactored caching processor out of memphis processor, new caching processor still needs a test. website cache does not require session any more

Files:

Legend:

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

    r1301 r1459  
    4747     * 
    4848     * @param   stubRequest   $request 
    49      * @param   stubSession   $session 
    50      * @param   stubResponse  $response 
    51      * @param   string        $page      name of the page to be cached 
     49     * @param   stubResponse  $response 
     50     * @param   string        $pageName  name of the page to be cached 
    5251     * @return  bool          true if data was retrieved from cache, else false 
    5352     */ 
    54     public function retrieve(stubRequest $request, stubSession $session, stubResponse $response, $page) 
    55     { 
    56         $cacheKey = $this->generateCacheKey($page); 
     53    public function retrieve(stubRequest $request, stubResponse $response, $pageName) 
     54    { 
     55        $cacheKey = $this->generateCacheKey($pageName); 
    5756        if ($this->isCached($cacheKey) === false) { 
    58             $this->log($page, $cacheKey, stubWebsiteCache::MISS); 
     57            $this->log($pageName, $cacheKey, stubWebsiteCache::MISS); 
    5958            return false; 
    6059        } 
     
    6463        } 
    6564         
    66         if ($this->doRetrieve($request, $session, $response, $cacheKey) === true) { 
    67             $this->log($page, $cacheKey, stubWebsiteCache::HIT); 
     65        if ($this->doRetrieve($request, $response, $cacheKey) === true) { 
     66            $this->log($pageName, $cacheKey, stubWebsiteCache::HIT); 
    6867            return true; 
    6968        } 
    7069         
    71         $this->log($page, $cacheKey, stubWebsiteCache::MISS); 
     70        $this->log($pageName, $cacheKey, stubWebsiteCache::MISS); 
    7271        return false; 
    7372    } 
     
    7776     * 
    7877     * @param   stubRequest   $request 
    79      * @param   stubSession   $session 
    8078     * @param   stubResponse  $response 
    8179     * @param   string        $cacheKey 
    8280     * @return  bool          true if data was retrieved from cache, else false 
    8381     */ 
    84     protected abstract function doRetrieve(stubRequest $request, stubSession $session, stubResponse $response, $cacheKey); 
     82    protected abstract function doRetrieve(stubRequest $request, stubResponse $response, $cacheKey); 
    8583 
    8684    /** 
     
    8987     * @param   stubRequest   $request 
    9088     * @param   stubResponse  $response 
    91      * @param   string        $page      name of the page to be cached 
     89     * @param   string        $pageName  name of the page to be cached 
    9290     * @return  bool          true if successfully stored, else false 
    9391     */ 
    94     public function store(stubRequest $request, stubResponse $response, $page
     92    public function store(stubRequest $request, stubResponse $response, $pageName
    9593    { 
    9694        if (stubMode::$CURRENT->isCacheEnabled() === false) { 
     
    9896        } 
    9997         
    100         return $this->doStore($request, $response, $this->generateCacheKey($page)); 
     98        return $this->doStore($request, $response, $this->generateCacheKey($pageName)); 
    10199    } 
    102100 
     
    136134        clearstatcache(); 
    137135        foreach ($this->getUsedFiles() as $fileName) { 
    138             if (is_readable($filename) === false) { 
     136            if (is_readable($fileName) === false) { 
    139137                continue; 
    140138            } 
  • trunk/src/main/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheFactory.php

    r1458 r1459  
    88 */ 
    99stubClassLoader::load('net::stubbles::websites::cache::stubCachableProcessor', 
     10                      'net::stubbles::websites::cache::stubCachingProcessor', 
    1011                      'net::stubbles::websites::cache::stubWebsiteCache', 
    1112                      'net::stubbles::websites::cache::stubWebsiteCacheFactory' 
     
    2021{ 
    2122    /** 
    22      * configures the processor with a website cache factory 
     23     * configures the processor with a website cache factory and returns the 
     24     * configured processor 
    2325     * 
    24      * @param  stubProcessor  $processor 
     26     * @param   stubProcessor  $processor 
     27     * @return  stubProcessor 
    2528     */ 
    2629    public function configure(stubProcessor $processor) 
    2730    { 
    2831        if (($processor instanceof stubCachableProcessor) === false) { 
    29             return
     32            return $processor
    3033        } 
    3134         
     35        $processor = new stubCachingProcessor($processor); 
    3236        $processor->setWebsiteCache($this->getWebsiteCache()); 
     37        return $processor; 
    3338    } 
    3439 
  • trunk/src/main/php/net/stubbles/websites/cache/stubCachableProcessor.php

    r1231 r1459  
    1919{ 
    2020    /** 
    21      * sets the website cache to be used by the processor 
     21     * adds the cache variables for the current request and returns whether 
     22     * response is cachable or not 
    2223     * 
    23      * @param  stubWebsiteCache  $websiteCache 
     24     * @param   stubWebsiteCache  $websiteCache 
     25     * @return  bool 
    2426     */ 
    25     public function setWebsiteCache(stubWebsiteCache $websiteCache); 
     27    public function addCacheVars(stubWebsiteCache $cache); 
     28 
     29    /** 
     30     * returns the name of the current page 
     31     * 
     32     * Non-page-based processors should return another unique identifier for 
     33     * the current request if they want to implement this interface. 
     34     * 
     35     * @return  string 
     36     */ 
     37    public function getPageName(); 
    2638} 
    2739?> 
  • trunk/src/main/php/net/stubbles/websites/cache/stubDefaultWebsiteCache.php

    r1301 r1459  
    104104     * 
    105105     * @param   stubRequest   $request 
    106      * @param   stubSession   $session 
    107106     * @param   stubResponse  $response 
    108107     * @param   string        $cacheKey 
    109108     * @return  bool          true if successfully retrieved, else false 
    110109     */ 
    111     protected function doRetrieve(stubRequest $request, stubSession $session, stubResponse $response, $cacheKey) 
     110    protected function doRetrieve(stubRequest $request, stubResponse $response, $cacheKey) 
    112111    { 
    113         $contents = $this->cache->get($cacheKey); 
    114         $contents = str_replace('$SID', $session->getName() . '=' . $session->getId(), $contents); 
    115         $contents = str_replace('$SESSION_NAME', $session->getName(), $contents); 
    116         $contents = str_replace('$SESSION_ID', $session->getId(), $contents); 
    117         $response->write($contents); 
     112        $response->write($this->cache->get($cacheKey)); 
    118113        return true; 
    119114    } 
  • trunk/src/main/php/net/stubbles/websites/cache/stubGzipWebsiteCache.php

    r1301 r1459  
    113113     * 
    114114     * @param   stubRequest   $request 
    115      * @param   stubSession   $session 
    116      * @param   stubResponse  $response 
    117      * @param   string        $page      name of the page to be cached 
     115     * @param   stubResponse  $response 
     116     * @param   string        $pageName  name of the page to be cached 
    118117     * @return  bool          true if data was retrieved from cache, else false 
    119118     */ 
    120     public function retrieve(stubRequest $request, stubSession $session, stubResponse $response, $page) 
    121     { 
    122         if (parent::retrieve($request, $session, $response, $page) === true) { 
     119    public function retrieve(stubRequest $request, stubResponse $response, $pageName) 
     120    { 
     121        if (parent::retrieve($request, $response, $pageName) === true) { 
    123122            return true; 
    124123        } 
    125124         
    126         return $this->websiteCache->retrieve($request, $session, $response, $page); 
     125        return $this->websiteCache->retrieve($request, $response, $pageName); 
    127126    } 
    128127 
     
    131130     * 
    132131     * @param   stubRequest   $request 
    133      * @param   stubSession   $session 
    134132     * @param   stubResponse  $response 
    135133     * @param   string        $cacheKey 
    136134     * @return  bool          true if data was retrieved from cache, else false 
    137135     */ 
    138     protected function doRetrieve(stubRequest $request, stubSession $session, stubResponse $response, $cacheKey) 
     136    protected function doRetrieve(stubRequest $request, stubResponse $response, $cacheKey) 
    139137    { 
    140138        // we do not use gzipped content because we probably have to insert 
  • trunk/src/main/php/net/stubbles/websites/cache/stubWebsiteCache.php

    r1307 r1459  
    88 */ 
    99stubClassLoader::load('net::stubbles::ipo::request::stubRequest', 
    10                       'net::stubbles::ipo::response::stubResponse', 
    11                       'net::stubbles::ipo::session::stubSession' 
     10                      'net::stubbles::ipo::response::stubResponse' 
    1211); 
    1312/** 
     
    7574     * 
    7675     * @param   stubRequest   $request 
    77      * @param   stubSession   $session 
    7876     * @param   stubResponse  $response 
    79      * @param   string        $page      name of the page to be cached 
     77     * @param   string        $pageName  name of the page to be cached 
    8078     * @return  bool          true if data was retrieved from cache, else false 
    8179     */ 
    82     public function retrieve(stubRequest $request, stubSession $session, stubResponse $response, $page); 
     80    public function retrieve(stubRequest $request, stubResponse $response, $pageName); 
    8381 
    8482    /** 
     
    8785     * @param   stubRequest   $request 
    8886     * @param   stubResponse  $response 
    89      * @param   string        $page      name of the page to be cached 
     87     * @param   string        $pageName  name of the page to be cached 
    9088     * @return  bool          true if successfully stored, else false 
    9189     */ 
    92     public function store(stubRequest $request, stubResponse $response, $page); 
     90    public function store(stubRequest $request, stubResponse $response, $pageName); 
    9391} 
    9492?> 
  • trunk/src/main/php/net/stubbles/websites/cache/stubWebsiteCacheFactory.php

    r1231 r1459  
    1717{ 
    1818    /** 
    19      * configures the processor with a website cache factory 
     19     * configures the processor with a website cache factory and returns the 
     20     * configured processor 
    2021     * 
    21      * @param  stubProcessor  $processor 
     22     * @param   stubProcessor  $processor 
     23     * @return  stubProcessor 
    2224     */ 
    2325    public function configure(stubProcessor $processor); 
  • trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisProcessor.php

    r1442 r1459  
    4040    protected $config; 
    4141    /** 
    42      * website cache to be used 
    43      * 
    44      * @var  stubWebsiteCache 
    45      */ 
    46     protected $cache; 
    47     /** 
    48      * page to display 
    49      * 
    50      * @var  stubPage 
    51      */ 
    52     protected $page; 
    53     /** 
    54      * name of page to display 
    55      * 
    56      * @var  string 
    57      */ 
    58     protected $pageName; 
     42     * context 
     43     * 
     44     * @var  array<string,mixed> 
     45     */ 
     46    protected $context = array('part'       => null, 
     47                               'page'       => null, 
     48                               'pageName'   => '', 
     49                               'frameId'    => '' 
     50                         ); 
     51    /** 
     52     * decorated request 
     53     * 
     54     * @var  stubRequestPrefixDecorator 
     55     */ 
     56    protected $prefixRequest; 
    5957 
    6058    /** 
     
    6765    public function __construct(stubRequest $request, stubSession $session, stubResponse $response) 
    6866    { 
     67        $this->prefixRequest = new stubRequestPrefixDecorator($request, ''); 
    6968        parent::__construct($request, $session, $response); 
    7069        $this->config = $this->createConfig(); 
     
    7271 
    7372    /** 
    74      * sets the website cache to be used by the processor 
    75      * 
    76      * @param  stubWebsiteCache  $websiteCache 
    77      */ 
    78     public function setWebsiteCache(stubWebsiteCache $websiteCache) 
    79     { 
    80         $this->cache = $websiteCache; 
    81     } 
     73     * helper method to create the config object 
     74     * 
     75     * @return  stubMemphisConfig 
     76     */ 
     77    // @codeCoverageIgnoreStart 
     78    protected function createConfig() 
     79    { 
     80        return new stubMemphisConfig(); 
     81    } 
     82    // @codeCoverageIgnoreEnd 
    8283 
    8384    /** 
     
    8889    public function selectPage(stubPageFactory $pageFactory) 
    8990    { 
    90         $this->pageName = $pageFactory->getPageName($this->request); 
    91         $this->page     = $pageFactory->getPage($this->pageName); 
    92         $this->session->putValue('net.stubbles.websites.lastPage', $this->pageName); 
    93     } 
    94  
    95     /** 
    96      * helper method to create the config object 
    97      * 
    98      * @return  stubMemphisConfig 
    99      * @throws  stubException 
    100      */ 
    101     protected function createConfig() 
    102     { 
    103         return new stubMemphisConfig(); 
    104     } 
    105  
    106     /** 
    107      * helper method to create the template 
    108      * 
    109      * @return  stubMemphisTemplate 
    110      */ 
    111     protected function createTemplate() 
    112     { 
    113         $template = new stubMemphisTemplate(stubRegistry::getConfig(stubMemphisTemplate::REGISTRY_KEY_DIR, stubConfig::getPagePath() . '/../templates')); 
    114         if (stubMode::$CURRENT->isCacheEnabled() === true) { 
    115             $template->enableCache(); 
    116         } 
    117  
    118         return $template; 
    119     } 
    120  
    121     /** 
    122      * processes the request 
    123      */ 
    124     public function process() 
    125     { 
    126         $elements      = $this->page->getElements(); 
    127         $prefixRequest = new stubRequestPrefixDecorator($this->request, ''); 
    128         $context       = array('part' => null, 
    129                                'page' => $this->page 
    130                          ); 
    131         $frameId       = $this->getFrameId(); 
    132         if (null !== $this->cache) { 
    133             $cachable = $this->processCacheVars($prefixRequest, $elements, $frameId, $context); 
    134             if (true === $cachable && $this->cache->retrieve($this->request, $this->session, $this->response, $this->pageName) === true) { 
    135                 return; 
    136             } 
    137         } 
    138  
    139         $this->template      = $this->createTemplate(); 
    140         $context['template'] = $this->template; 
    141         $this->template->readTemplatesFromInput($this->config->getFrame($frameId)); 
    142         $this->setTemplateVars($frameId); 
    143         $this->processPageElements($prefixRequest, $elements, $context); 
    144         if (null !== $this->cache) { 
    145             if (true === $cachable) { 
    146                 $this->cache->store($this->request, $this->response, $this->pageName); 
    147             } 
    148  
    149             $contents = str_replace('$SID', $this->session->getName() . '=' . $this->session->getId(), $this->response->getData()); 
    150             $contents = str_replace('$SESSION_NAME', $this->session->getName(), $contents); 
    151             $this->response->replaceData(str_replace('$SESSION_ID', $this->session->getId(), $contents)); 
    152         } 
    153     } 
    154  
    155     /** 
    156      * helper method to set the cache variables 
    157      * 
    158      * @param   stubRequest  $prefixRequest 
    159      * @param   array        $elements 
    160      * @param   string       $frameId 
    161      * @param   array        $context 
    162      * @return  bool         true if page is cachable, else false 
    163      */ 
    164     protected function processCacheVars(stubRequest $prefixRequest, array $elements, $frameId, array $context) 
    165     { 
    166         $this->cache->addCacheVar('page', $this->pageName); 
    167         $this->cache->addCacheVar('frame', $frameId); 
    168         $this->cache->addCacheVar('variant', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 
    169         $sslMode = 'no'; 
    170         if ($this->isSSL() === true) { 
    171             $sslMode = 'yes'; 
    172         } 
    173  
    174         $this->cache->addCacheVar('ssl', $sslMode); 
    175         foreach ($this->config->getParts() as $part) { 
    176             $context['part'] = $part; 
    177             foreach ($this->config->getDefaultElements($part) as $defaultElement) { 
    178                 $prefixRequest->setPrefix($defaultElement->getName()); 
    179                 $defaultElement->init($prefixRequest, $this->session, $this->response, $context); 
    180                 if ($defaultElement->isAvailable() === false) { 
    181                     continue; 
    182                 } elseif ($defaultElement->isCachable() === false) { 
    183                     return false; 
    184                 } 
    185  
    186                 $this->cache->addCacheVars($defaultElement->getCacheVars()); 
    187                 $this->cache->addUsedFiles($defaultElement->getUsedFiles()); 
    188             } 
    189  
    190             foreach ($elements as $name => $element) { 
    191                 $prefixRequest->setPrefix($name); 
    192                 $element->init($prefixRequest, $this->session, $this->response, $context); 
    193                 if ($element->isAvailable() === false) { 
    194                     continue; 
    195                 } elseif ($element->isCachable() === false) { 
    196                     return false; 
    197                 } 
    198  
    199                 $this->cache->addCacheVars($element->getCacheVars()); 
    200                 $this->cache->addUsedFiles($element->getUsedFiles()); 
    201             } 
    202         } 
    203  
    204         return true; 
    205     } 
    206  
    207     /** 
    208      * helper method to process the page elements 
    209      * 
    210      * @param  stubRequest  $prefixRequest 
    211      * @param  array        $elements 
    212      * @param  array        $context 
    213      */ 
    214     protected function processPageElements(stubRequest $prefixRequest, array $elements, array $context) 
    215     { 
    216         foreach ($this->config->getParts() as $part) { 
    217             $content         = ''; 
    218             $context['part'] = $part; 
    219             foreach ($this->config->getDefaultElements($part) as $defaultElement) { 
    220                 $prefixRequest->setPrefix($defaultElement->getName()); 
    221                 $defaultElement->init($prefixRequest, $this->session, $this->response, $context); 
    222                 if ($defaultElement->isAvailable() === false) { 
    223                     continue; 
    224                 } 
    225  
    226                 $content .= $defaultElement->process(); 
    227                 if ($prefixRequest->isCancelled() === true) { 
    228                     return; 
    229                 } 
    230             } 
    231  
    232             foreach ($elements as $name => $element) { 
    233                 $prefixRequest->setPrefix($name); 
    234                 $element->init($prefixRequest, $this->session, $this->response, $context); 
    235                 if ($element->isAvailable() === false) { 
    236                     continue; 
    237                 } 
    238  
    239                 $content .= $element->process(); 
    240                 if ($prefixRequest->isCancelled() === true) { 
    241                     return; 
    242                 } 
    243             } 
    244  
    245             $this->template->addGlobalVar($part, $content); 
    246         } 
    247  
    248         $this->response->write($this->template->getParsedTemplate('frame')); 
     91        $this->context['pageName'] = $pageFactory->getPageName($this->request); 
     92        $this->context['page']     = $pageFactory->getPage($this->context['pageName']); 
     93        $this->session->putValue('net.stubbles.websites.lastPage', $this->context['pageName']); 
     94        $this->context['frameId']  = $this->getFrameId(); 
    24995    } 
    25096 
     
    256102    protected function getFrameId() 
    257103    { 
    258         if ($this->page->hasProperty('frame_fixed') === true && $this->page->getProperty('frame_fixed') === true) { 
    259             return $this->page->getProperty('frame'); 
     104        if ($this->context['page']->hasProperty('frame_fixed') === true && $this->context['page']->getProperty('frame_fixed') === true) { 
     105            return $this->context['page']->getProperty('frame'); 
    260106        } 
    261107 
     
    265111            $frame = $this->session->getValue('net.stubbles.websites.memphis.frame'); 
    266112        } else { 
    267             $frame = $this->page->getProperty('frame'); 
     113            $frame = $this->context['page']->getProperty('frame'); 
    268114        } 
    269115 
     
    276122 
    277123    /** 
     124     * adds the cache variables for the current request and returns whether 
     125     * response is cachable or not 
     126     * 
     127     * @param   stubWebsiteCache  $websiteCache 
     128     * @return  bool 
     129     */ 
     130    public function addCacheVars(stubWebsiteCache $cache) 
     131    { 
     132        $cache->addCacheVar('page', $this->context['pageName']); 
     133        $cache->addCacheVar('frame', $this->context['frameId']); 
     134        $cache->addCacheVar('variant', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 
     135        foreach ($this->config->getParts() as $part) { 
     136            $this->context['part'] = $part; 
     137            foreach ($this->config->getDefaultElements($part) as $defaultElement) { 
     138                $this->prefixRequest->setPrefix($defaultElement->getName()); 
     139                $defaultElement->init($this->prefixRequest, $this->session, $this->response, $this->context); 
     140                if ($defaultElement->isAvailable() === true) { 
     141                    if ($defaultElement->isCachable() === false) { 
     142                        return false; 
     143                    } 
     144 
     145                    $cache->addCacheVars($defaultElement->getCacheVars()); 
     146                    $cache->addUsedFiles($defaultElement->getUsedFiles()); 
     147                } 
     148            } 
     149 
     150            foreach ($this->context['page']->getElements() as $name => $element) { 
     151                $this->prefixRequest->setPrefix($name); 
     152                $element->init($this->prefixRequest, $this->session, $this->response, $this->context); 
     153                if ($element->isAvailable() === true) { 
     154                    if ($element->isCachable() === false) { 
     155                        return false; 
     156                    } 
     157 
     158                    $cache->addCacheVars($element->getCacheVars()); 
     159                    $cache->addUsedFiles($element->getUsedFiles()); 
     160                } 
     161            } 
     162        } 
     163 
     164        return true; 
     165    } 
     166 
     167    /** 
     168     * returns the name of the current page 
     169     * 
     170     * @return  string 
     171     */ 
     172    public function getPageName() 
     173    { 
     174        return $this->context['pageName']; 
     175    } 
     176 
     177    /** 
     178     * processes the request 
     179     */ 
     180    public function process() 
     181    { 
     182        $this->template            = $this->createTemplate(); 
     183        $this->context['template'] = $this->template; 
     184        $this->template->readTemplatesFromInput($this->config->getFrame($this->context['frameId'])); 
     185        $this->setTemplateVars(); 
     186        foreach ($this->config->getParts() as $part) { 
     187            $content               = ''; 
     188            $this->context['part'] = $part; 
     189            foreach ($this->config->getDefaultElements($part) as $defaultElement) { 
     190                $this->prefixRequest->setPrefix($defaultElement->getName()); 
     191                $defaultElement->init($this->prefixRequest, $this->session, $this->response, $this->context); 
     192                if ($defaultElement->isAvailable() === true) { 
     193                    $content .= $defaultElement->process(); 
     194                    if ($this->prefixRequest->isCancelled() === true) { 
     195                        return; 
     196                    } 
     197                } 
     198            } 
     199 
     200            foreach ($this->context['page']->getElements() as $name => $element) { 
     201                $this->prefixRequest->setPrefix($name); 
     202                $element->init($this->prefixRequest, $this->session, $this->response, $this->context); 
     203                if ($element->isAvailable() === true) { 
     204                    $content .= $element->process(); 
     205                    if ($this->prefixRequest->isCancelled() === true) { 
     206                        return; 
     207                    } 
     208                } 
     209            } 
     210 
     211            $this->template->addGlobalVar($part, $content); 
     212        } 
     213 
     214        $this->response->write($this->template->getParsedTemplate('frame')); 
     215    } 
     216 
     217    /** 
     218     * helper method to create the template 
     219     * 
     220     * @return  stubMemphisTemplate 
     221     */ 
     222    // @codeCoverageIgnoreStart 
     223    protected function createTemplate() 
     224    { 
     225        $template = new stubMemphisTemplate(stubRegistry::getConfig(stubMemphisTemplate::REGISTRY_KEY_DIR, stubConfig::getPagePath() . '/../templates')); 
     226        if (stubMode::$CURRENT->isCacheEnabled() === true) { 
     227            $template->enableCache(); 
     228        } 
     229 
     230        return $template; 
     231    } 
     232    // @codeCoverageIgnoreEnd 
     233 
     234    /** 
    278235     * helper method to set the template vars 
    279      * 
    280      * @param  string    $frameId 
    281      */ 
    282     protected function setTemplateVars($frameId) 
    283     { 
    284         $this->template->addGlobalVar('UCUO_FRAME', $frameId); 
    285         $this->template->addGlobalVar('PAGE_TITLE', htmlentities($this->page->getProperty('title'))); 
    286         $this->template->addGlobalVar('PAGE_NAME', $this->pageName); 
     236     */ 
     237    protected function setTemplateVars() 
     238    { 
     239        $this->template->addGlobalVar('UCUO_FRAME', $this->context['frameId']); 
     240        $this->template->addGlobalVar('PAGE_TITLE', htmlentities($this->context['page']->getProperty('title'))); 
     241        $this->template->addGlobalVar('PAGE_NAME', $this->context['pageName']); 
    287242        $this->template->addGlobalVar('VARIANT', $this->session->getValue('net.stubbles.websites.variantmanager.variant.name', '')); 
    288243        $this->template->addGlobalVar('VARIANT_ALIAS', $this->session->getValue('net.stubbles.websites.variantmanager.variant.alias', '')); 
     
    293248        $this->template->addGlobalVar('SERVICE_URL', $serviceUrl); 
    294249 
    295         if (null === $this->cache) { 
    296             $this->template->addGlobalVar('SID', $this->session->getName() . '=' . $this->session->getId()); 
    297             $this->template->addGlobalVar('SESSION_NAME', $this->session->getName()); 
    298             $this->template->addGlobalVar('SESSION_ID', $this->session->getId()); 
    299         } else { 
    300             $this->template->addGlobalVar('SID', '$SID'); 
    301             $this->template->addGlobalVar('SESSION_NAME', '$SESSION_NAME'); 
    302             $this->template->addGlobalVar('SESSION_ID', '$SESSION_ID'); 
    303         } 
    304  
     250        $this->template->addGlobalVar('SID', '$SID'); 
     251        $this->template->addGlobalVar('SESSION_NAME', '$SESSION_NAME'); 
     252        $this->template->addGlobalVar('SESSION_ID', '$SESSION_ID'); 
    305253        // add meta information to the page 
    306254        foreach ($this->config->getMetaTags() as $key => $value) { 
  • trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php

    r1442 r1459  
    6565 
    6666    /** 
     67     * returns the request instance 
     68     * 
     69     * @return  stubRequest 
     70     */ 
     71    public function getRequest() 
     72    { 
     73        return $this->request; 
     74    } 
     75 
     76    /** 
     77     * returns the session instance 
     78     * 
     79     * @return  stubSession 
     80     */ 
     81    public function getSession() 
     82    { 
     83        return $this->session; 
     84    } 
     85 
     86    /** 
     87     * returns the response instance 
     88     * 
     89     * @return  stubResponse 
     90     */ 
     91    public function getResponse() 
     92    { 
     93        return $this->response; 
     94    } 
     95 
     96    /** 
    6797     * sets the interceptor descriptor 
    6898     * 
  • trunk/src/main/php/net/stubbles/websites/processors/stubProcessor.php

    r1457 r1459  
    2828     */ 
    2929    #public function __construct(stubRequest $request, stubSession $session, , stubResponse $response); 
     30 
     31    /** 
     32     * returns the request instance 
     33     * 
     34     * @return  stubRequest 
     35     */ 
     36    public function getRequest(); 
     37 
     38    /** 
     39     * returns the session instance 
     40     * 
     41     * @return  stubSession 
     42     */ 
     43    public function getSession(); 
     44 
     45    /** 
     46     * returns the response instance 
     47     * 
     48     * @return  stubResponse 
     49     */ 
     50    public function getResponse(); 
    3051 
    3152    /** 
  • trunk/src/main/php/net/stubbles/websites/stubFrontController.php

    r1441 r1459  
    139139         
    140140        if (null !== $this->websiteCacheFactory) { 
    141             $this->websiteCacheFactory->configure($processor); 
     141            $processor = $this->websiteCacheFactory->configure($processor); 
    142142        } 
    143143         
  • trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php

    r1458 r1459  
    3939        $suite->addTestFile($dir . '/memphis/stubMemphisIncludeFilePageElementTestCase.php'); 
    4040        $suite->addTestFile($dir . '/memphis/stubMemphisPageElementTestCase.php'); 
     41        $suite->addTestFile($dir . '/memphis/stubMemphisProcessorCachableTestCase.php'); 
    4142        $suite->addTestFile($dir . '/memphis/stubMemphisProcessorTestCase.php'); 
    4243 
  • trunk/src/test/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheFactoryTestCase.php

    r1458 r1459  
    4040    public function nonCachableProcessor() 
    4141    { 
     42        $mockProcessor = $this->getMock('stubProcessor'); 
    4243        $this->abstractWebsiteCacheFactory->expects($this->never()) 
    4344                                          ->method('getWebsiteCache'); 
    44         $this->abstractWebsiteCacheFactory->configure($this->getMock('stubProcessor')); 
     45        $this->assertSame($mockProcessor, $this->abstractWebsiteCacheFactory->configure($mockProcessor)); 
    4546    } 
    4647 
     
    5455        $mockWebsiteCache  = $this->getMock('stubWebsiteCache'); 
    5556        $cachableProcessor = $this->getMock('stubCachableProcessor'); 
    56         $cachableProcessor->expects($this->once()) 
    57                           ->method('setWebsiteCache') 
    58                           ->with($this->equalTo($mockWebsiteCache)); 
    5957        $this->abstractWebsiteCacheFactory->expects($this->once()) 
    6058                                          ->method('getWebsiteCache') 
    6159                                          ->will($this->returnValue($mockWebsiteCache)); 
    62         $this->abstractWebsiteCacheFactory->configure($cachableProcessor); 
     60        $cachingProcessor = $this->abstractWebsiteCacheFactory->configure($cachableProcessor); 
     61        $this->assertType('stubCachingProcessor', $cachingProcessor); 
     62        $this->assertSame($cachableProcessor, $cachingProcessor->getProcessor()); 
    6363    } 
    6464} 
  • trunk/src/test/php/net/stubbles/websites/cache/stubAbstractWebsiteCacheTestCase.php

    r1252 r1459  
    6262     */ 
    6363    protected $mockRequest; 
    64     /** 
    65      * mocked session instance 
    66      * 
    67      * @var  PHPUnit_Framework_MockObject_MockObject 
    68      */ 
    69     protected $mockSession; 
    7064    /** 
    7165     * mocked response instance 
     
    9993                              ->will($this->returnValue(array('foo' => 'bar'))); 
    10094        $this->mockRequest  = $this->getMock('stubRequest'); 
    101         $this->mockSession  = $this->getMock('stubSession'); 
    10295        $this->mockResponse = $this->getMock('stubResponse'); 
    10396        stubMode::setCurrent(stubMode::$PROD); 
     
    118111        $this->mockResponse->expects($this->never())->method('addHeader'); 
    119112        $this->mockCacheContainer->expects($this->never())->method('has'); 
    120         $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mockSession, $this->mockResponse, 'baz')); 
     113        $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mockResponse, 'baz')); 
    121114        $this->assertEquals('disabled', $this->abstractWebsiteCache->getMissReason()); 
    122115    } 
     
    135128        $this->mockResponse->expects($this->never())->method('addHeader'); 
    136129        $this->mockCacheContainer->expects($this->once())->method('has')->will($this->returnValue(false)); 
    137         $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mockSession, $this->mockResponse, 'baz')); 
     130        $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest,$this->mockResponse, 'baz')); 
    138131        $this->assertEquals('no cache file', $this->abstractWebsiteCache->getMissReason()); 
    139132    } 
     
    151144        $this->abstractWebsiteCache->expects($this->once()) 
    152145                                   ->method('doRetrieve') 
    153                                    ->with($this->equalTo($this->mockRequest), $this->equalTo($this->mockSession), $this->equalTo($this->mockResponse)) 
     146                                   ->with($this->equalTo($this->mockRequest), $this->equalTo($this->mockResponse)) 
    154147                                   ->will($this->returnValue(false)); 
    155148        $this->abstractWebsiteCache->expects($this->once())->method('isUsedFilesCheckEnabled')->will($this->returnValue(false)); 
     
    157150        $this->mockResponse->expects($this->never())->method('addHeader'); 
    158151        $this->mockCacheContainer->expects($this->once())->method('has')->will($this->returnValue(true)); 
    159         $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mockSession, $this->mockResponse, 'baz')); 
     152        $this->assertFalse($this->abstractWebsiteCache->retrieve($this->mockRequest, $this->mockResponse, 'baz')); 
    160153        $this->assertEquals('', $this->abstractWebsiteCache->getMissReason()); 
    161154    } 
     
    173166        $this->abstractWebsiteCache->expects($this->once()) 
    174167                                   ->method('doRetrieve') 
    175                                    ->with($this->equalTo($this->mockRequest), $this->equalTo($this->mockSession), $this->equalTo($this->mockResponse)) 
     168&nbs