Changeset 585

Show
Ignore:
Timestamp:
04/20/07 14:35:54 (2 years ago)
Author:
mikey
Message:

reworked creation of stubRequestValueError via XJConf: can now be cached

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueError.php

    r537 r585  
    2121 * @XMLMethods[XMLMatcher](pattern="/getId|getMessages/") 
    2222 */ 
    23 class stubRequestValueError extends stubBaseObject 
     23class stubRequestValueError extends stubSerializableObject 
    2424{ 
    2525    /** 
  • trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueErrorXJConfFactory.php

    r580 r585  
    99stubClassLoader::load('net.stubbles.ipo.request.stubRequestValueErrorFactory', 
    1010                      'net.stubbles.ipo.request.stubRequestValueErrorException', 
    11                       'net.stubbles.util.stubFactory', 
    12                       'net.stubbles.util.xjconf.xjconf', 
    13                       'net.stubbles.util.xjconf.xjconfReal' 
     11                      'net.stubbles.util.xjconf.xjconf' 
    1412); 
    1513/** 
     
    2018 * @uses        http://php.xjconf.net/ 
    2119 */ 
    22 class stubRequestValueErrorXJConfFactory extends stubBaseObject implements stubRequestValueErrorFactory 
     20class stubRequestValueErrorXJConfFactory extends stubBaseObject implements stubRequestValueErrorFactory, stubXJConfInitializer 
    2321{ 
    2422    /** 
     
    3634    public function __construct() 
    3735    { 
    38         if (null == self::$requestValueErrors) { 
    39             self::$requestValueErrors = array(); 
    40             $xjconf = new stubXJConfFacade(new XJConfFacade(array('__default' => stubXJConfLoader::getInstance()))); 
    41             $xjconf->addDefinitions(stubFactory::getResourceURIs('xjconf/request.xml')); 
    42             $sources = stubFactory::getResourceURIs('ipo/request.xml'); 
    43             foreach ($sources as $source) { 
    44                 try { 
    45                     $xjconf->parse($source); 
    46                 } catch (stubXJConfException $xjce) { 
    47                     throw new stubRequestValueErrorException($xjce->getMessage()); 
    48                 } 
    49                  
    50                 self::$requestValueErrors = array_merge(self::$requestValueErrors, $xjconf->getConfigValues()); 
    51             } 
     36        if (null != self::$requestValueErrors) { 
     37            return; 
     38        } 
     39         
     40        self::$requestValueErrors = array(); 
     41        $xjconf = new stubXJConfProxy($this); 
     42        try { 
     43            $xjconf->process(stubFactory::getResourceURIs('ipo/request.xml')); 
     44        } catch (stubXJConfException $xjce) { 
     45            throw new stubRequestValueErrorException($xjce->getMessage()); 
    5246        } 
    5347    } 
    54      
     48 
     49    /** 
     50     * returns the descriptor that identifies this initializer 
     51     * 
     52     * @return  string 
     53     */ 
     54    public function getDescriptor() 
     55    { 
     56        return 'request'; 
     57    } 
     58 
     59    /** 
     60     * returns the data to cache  
     61     * 
     62     * @return  array 
     63     */ 
     64    public function getCacheData() 
     65    { 
     66        return self::$requestValueErrors; 
     67    } 
     68 
     69    /** 
     70     * sets the data from the cache 
     71     * 
     72     * @param  array  $cacheData 
     73     */ 
     74    public function setCacheData(array $cacheData) 
     75    { 
     76        self::$requestValueErrors = $cacheData; 
     77    } 
     78 
     79    /** 
     80     * returns a list of extensions for the parser 
     81     * 
     82     * @return  array<Extension> 
     83     */ 
     84    public function getExtensions() 
     85    { 
     86        return array(); 
     87    } 
     88 
     89    /** 
     90     * will be called in case the stubXJConfProxy did not found the data in the 
     91     * cache and the initializer has to load values from the facade 
     92     * 
     93     * @param  stubXJConfFacade  $xjconf 
     94     */ 
     95    public function loadData(stubXJConfFacade $xjconf) 
     96    { 
     97        self::$requestValueErrors = array_merge(self::$requestValueErrors, $xjconf->getConfigValues()); 
     98    } 
     99 
    55100    /** 
    56101     * creates the stubRequestValueError with the id from the given source