Changeset 312

Show
Ignore:
Timestamp:
03/01/07 15:30:38 (2 years ago)
Author:
mikey
Message:

added net.stubbles.util.xjconf.stubXJConfFacade
added bootstrap file for net.stubbles.util.xjconf
got rid of all xjconf related stuff in concrete stubbles classes, uses facade now only

Files:

Legend:

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

    r219 r312  
    1010                      'net.stubbles.ipo.request.stubRequestValueErrorException', 
    1111                      'net.stubbles.stubFactory', 
    12                       'net.stubbles.util.xjconf.stubXJConfLoader' 
    13 ); 
    14 XJConfLoader::load('DefinitionParser', 
    15                    'XmlParser' 
     12                      'net.stubbles.util.xjconf.xjconf' 
    1613); 
    1714/** 
     
    3330     * instance of the parser that parses the xml configuration files 
    3431     * 
    35      * @var  XmlParser 
     32     * @var  stubXJConfFacade 
    3633     */ 
    37     protected $xmlParser
     34    protected $xjconf
    3835     
    3936    /** 
     
    5754        } 
    5855         
    59         return clone $this->xmlParser->getConfigValue($id); 
     56        return clone $this->xjconf->getConfigValue($id); 
    6057    } 
    6158     
     
    6966    { 
    7067        if (count($this->initDone) == 0) { 
    71             $tagParser = new DefinitionParser(); 
    72             $defs      = $tagParser->parse(stubFactory::getResourceURI('xjconf/request.xml')); 
    73             $this->xmlParser = new XmlParser(); 
    74             $this->xmlParser->setTagDefinitions($defs); 
     68            $this->xjconf = new stubXJConfFacade(); 
     69            $this->xjconf->setDefinitionFile(stubFactory::getResourceURI('xjconf/request.xml')); 
    7570        } 
    7671         
    7772        try { 
    78             $this->xmlParser->parse($source); 
    79         } catch (XJConfException $xjce) { 
     73            $this->xjconf->parse($source); 
     74        } catch (stubXJConfException $xjce) { 
    8075            $this->initDone[$source] = false; 
    8176            throw new stubRequestValueErrorException($xjce->getMessage()); 
  • trunk/src/main/php/net/stubbles/util/log/stubLoggerXJConfFactory.php

    r219 r312  
    77 * @subpackage  util_log 
    88 */ 
    9 stubClassLoader::load('net.stubbles.util.xjconf.stubXJConfLoader', 
    10                       'net.stubbles.util.xjconf.stubConfigXJConfExtension', 
     9stubClassLoader::load('net.stubbles.util.xjconf.xjconf', 
    1110                      'net.stubbles.stubFactory' 
    12 ); 
    13 XJConfLoader::load('DefinitionParser', 
    14                    'XmlParser' 
    1511); 
    1612/** 
     
    2824     * 
    2925     * @param   string  $configFile 
    30      * @throws  stubException 
     26     * @throws  stubXJConfException 
    3127     */ 
    3228    public static function init($configFile) 
    3329    { 
    34         $tagParser = new DefinitionParser(array('http://stubbles.net/util/log' => stubXJConfLoader::getInstance())); 
    35         $defs      = $tagParser->parse(stubFactory::getResourceURI('xjconf/logging.xml')); 
    36         $xmlParser = new XmlParser(); 
     30        $xjconf = new stubXJConfFacade(array('http://stubbles.net/util/log' => stubXJConfLoader::getInstance())); 
     31        $xjconf->setDefinitionFile(stubFactory::getResourceURI('xjconf/logging.xml')); 
    3732        $configExtension = new stubConfigXJConfExtension(); 
    38         $xmlParser->addExtension($configExtension); 
    39         $xmlParser->setTagDefinitions($defs); 
    40         try { 
    41             $xmlParser->parse($configFile); 
    42         } catch (XJConfException $xjce) { 
    43             throw new stubException($xjce->getMessage()); 
    44         } 
     33        $xjconf->addExtension($configExtension); 
     34        $xjconf->parse($configFile); 
    4535    } 
    4636} 
  • trunk/src/main/php/net/stubbles/util/stubRegistryFactory.php

    r219 r312  
    77 * @subpackage  util 
    88 */ 
    9 stubClassLoader::load('net.stubbles.util.xjconf.stubXJConfLoader'); 
     9stubClassLoader::load('net.stubbles.util.xjconf.xjconf'); 
    1010/** 
    1111 * Class for initializing the Registry. 
     
    2020     * initialize the Registry with configuration values from given configuration file 
    2121     * 
    22      * @param  string  $configFile 
     22     * @param   string  $configFile 
     23     * @throws  stubXJConfException 
    2324     */ 
    2425    public static function init($configFile) 
    2526    { 
    26         $tagParser = new DefinitionParser(array('http://stubbles.net/util/registry' => stubXJConfLoader::getInstance())); 
    27         $defs      = $tagParser->parse(stubFactory::getResourceURI('xjconf/registry.xml')); 
    28         $xmlParser = new XmlParser(); 
    29         $xmlParser->setTagDefinitions($defs); 
    30         try { 
    31             $xmlParser->parse($configFile); 
    32         } catch (XJConfException $xjce) { 
    33             throw new Exception($xjce->getMessage()); 
    34         } 
     27        $xjconf = new stubXJConfFacade(array('http://stubbles.net/util/registry' => stubXJConfLoader::getInstance())); 
     28        $xjconf->setDefinitionFile(stubFactory::getResourceURI('xjconf/registry.xml')); 
     29        $xjconf->parse($configFile); 
    3530    } 
    3631} 
  • trunk/src/main/php/net/stubbles/util/xjconf/stubConfigXJConfExtension.php

    r150 r312  
    77 * @subpackage  util_xjconf 
    88 */ 
    9 stubClassLoader::load('net.stubbles.util.xjconf.stubXJConfLoader'); 
     9stubClassLoader::load('net.stubbles.util.xjconf.xjconf'); 
    1010XJConfLoader::load('ext.Extension'); 
    1111/** 
     
    1717 * <?xml version="1.0" encoding="iso-8859-1"?> 
    1818 * <xj:configuration 
    19  *     xmlns:xj="http://xjconf.net/XJConf" 
    20  *     xmlns:cfg="http://stubbles.net/util/XJConf" 
    21  *     xmlns="http://stubbles.net/util/log"> 
     19 * xmlns:xj="http://xjconf.net/XJConf" 
     20 * xmlns:cfg="http://stubbles.net/util/XJConf" 
     21 * xmlns="http://stubbles.net/util/log"> 
    2222 *   <logger id="default" level="15"> 
    2323 *     <logAppender type="net.stubbles.util.log.stubFileLogAppender"> 
     
    4141     * @var  string 
    4242     */ 
    43     private $namespace = 'http://stubbles.net/util/XJConf'; 
    44      
    45     /** 
    46      * Get the namespace URI used by the extension 
    47      *  
    48      * @return  string 
    49      */ 
    50     public function getNamespace() 
    51     { 
    52         return $this->namespace; 
    53     } 
     43    private $namespace = 'http://stubbles.net/util/XJConf'; 
    5444     
    55     /** 
     45    /** 
     46     * Get the namespace URI used by the extension 
     47     *  
     48     * @return  string 
     49     */ 
     50    public function getNamespace() 
     51    { 
     52        return $this->namespace; 
     53    } 
     54     
     55    /** 
    5656     * Process a start element 
    5757     *  
     
    6060     * @throws XJConfException 
    6161     */ 
    62    public function startElement(XmlParser $parser, Tag $tag) 
     62    public function startElement(XmlParser $parser, Tag $tag) 
    6363    { 
    6464        // nothing to do here 
    65    
     65   
    6666     
    67    /** 
     67    /** 
    6868     * Process the end element 
    6969     *  
     
    7272     * @throws  XJConfException 
    7373     */ 
    74    public function endElement(XmlParser $parser, Tag $tag) 
    75    
    76        // add several values 
    77        if ($tag->getName() == 'stubConfig' && $tag->hasAttribute('method') == true &&  $tag->hasAttribute('name') == true) { 
    78            $methodName = $tag->getAttribute('method'); 
    79            $refClass = new ReflectionClass('stubConfig'); 
    80            if ($refClass->hasMethod($methodName) == false) { 
    81                throw new XJConfException('The requested method ' . $methodName . ' is not available in class stubConfig.'); 
    82            
    83              
    84            $resultTag = new GenericTag($tag->getAttribute('name')); 
    85            $resultTag->setKey($tag->getAttribute('name')); 
    86            $resultTag->setValue($refClass->getMethod($methodName)->invoke(null)); 
    87            return $resultTag; 
    88        
    89          
    90        return null; 
    91    
     74    public function endElement(XmlParser $parser, Tag $tag) 
     75   
     76        // add several values 
     77        if ($tag->getName() == 'stubConfig' && $tag->hasAttribute('method') == true &&  $tag->hasAttribute('name') == true) { 
     78            $methodName = $tag->getAttribute('method'); 
     79            $refClass = new ReflectionClass('stubConfig'); 
     80            if ($refClass->hasMethod($methodName) == false) { 
     81                throw new XJConfException('The requested method ' . $methodName . ' is not available in class stubConfig.'); 
     82           
     83             
     84            $resultTag = new GenericTag($tag->getAttribute('name')); 
     85            $resultTag->setKey($tag->getAttribute('name')); 
     86            $resultTag->setValue($refClass->getMethod($methodName)->invoke(null)); 
     87            return $resultTag; 
     88       
     89         
     90        return null; 
     91   
    9292} 
    9393?> 
  • trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfLoader.php

    r171 r312  
    88 * @subpackage  util_xjconf 
    99 */ 
    10 $xjConfUri = StarClassRegistry::getUriForClass('net.xjconf.XJConfLoader'); 
    11 if (null === $xjConfUri) { 
    12     if (!@include 'XJConf/XJConfLoader.php') { 
    13         throw new stubException('XJConf could not be found in lib nor in include path.'); 
    14     } 
    15 } else { 
    16     require $xjConfUri; 
    17 
     10stubClassLoader::load('net.stubbles.util.xjconf.xjconf'); 
    1811XJConfLoader::load('XJConfClassLoader'); 
    1912/** 
     
    8376    { 
    8477        $className = explode('.', $fqClassName); 
    85        return $className[count($className) - 1]; 
     78        return $className[count($className) - 1]; 
    8679    } 
    8780} 
  • trunk/src/main/php/net/stubbles/websites/stubXJConfPageFactory.php

    r292 r312  
    88 */ 
    99stubClassLoader::load('net.stubbles.stubFactory', 
    10                       'net.stubbles.util.xjconf.stubXJConfLoader', 
     10                      'net.stubbles.util.xjconf.xjconf', 
    1111                      'net.stubbles.websites.stubPageConfigurationException', 
    1212                      'net.stubbles.websites.stubPageFactory', 
    1313                      'net.stubbles.stubFactory' 
    14 ); 
    15 XJConfLoader::load('DefinitionParser', 
    16                    'XmlParser', 
    17                    'XJConfClassLoader' 
    1814); 
    1915/** 
     
    2824     * the xml parser 
    2925     * 
    30      * @var  XmlParser 
     26     * @var  stubXJConfFacade 
    3127     */ 
    32     private static $xmlParser
     28    private static $xjconf
    3329 
    3430    /** 
     
    3935    public function __construct(stubXJConfLoader $classLoader) 
    4036    { 
    41         if (null == self::$xmlParser) { 
    42             $tagParser = new DefinitionParser(array('http://stubbles.net/websites' => $classLoader)); 
    43             $defs      = $tagParser->parse(stubFactory::getResourceURI('xjconf/websites.xml')); 
    44  
    45             self::$xmlParser = new XmlParser(); 
    46             self::$xmlParser->setTagDefinitions($defs); 
     37        if (null == self::$xjconf) { 
     38            self::$xjconf = new stubXJConfFacade(array('http://stubbles.net/websites' => $classLoader)); 
     39            self::$xjconf->setDefinitionFile(stubFactory::getResourceURI('xjconf/websites.xml')); 
    4740        } 
    4841    } 
     
    7063        $configSource = stubConfig::getConfigPath() . '/xml/pages/' . $configSource . '.xml'; 
    7164        try { 
    72             self::$xmlParser->parse($configSource); 
    73         } catch (XJConfException $xjce) { 
     65            self::$xjconf->parse($configSource); 
     66        } catch (stubXJConfException $xjce) { 
    7467            throw new stubPageConfigurationException('Can not read page configuration from ' . $configSource, $xjce); 
    7568        } 
    7669 
    77         return self::$xmlParser->getConfigValue('page'); 
     70        return self::$xjconf->getConfigValue('page'); 
    7871    } 
    7972}