Changeset 312
- Timestamp:
- 03/01/07 15:30:38 (2 years ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/request/stubXmlRequestValueErrorFactory.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/util/log/stubLoggerXJConfFactory.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/util/stubRegistryFactory.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/util/xjconf/stubConfigXJConfExtension.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfException.php (added)
- trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfFacade.php (added)
- trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfLoader.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/util/xjconf/xjconf.php (added)
- trunk/src/main/php/net/stubbles/websites/stubXJConfPageFactory.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/stubXmlRequestValueErrorFactory.php
r219 r312 10 10 'net.stubbles.ipo.request.stubRequestValueErrorException', 11 11 'net.stubbles.stubFactory', 12 'net.stubbles.util.xjconf.stubXJConfLoader' 13 ); 14 XJConfLoader::load('DefinitionParser', 15 'XmlParser' 12 'net.stubbles.util.xjconf.xjconf' 16 13 ); 17 14 /** … … 33 30 * instance of the parser that parses the xml configuration files 34 31 * 35 * @var XmlParser32 * @var stubXJConfFacade 36 33 */ 37 protected $x mlParser;34 protected $xjconf; 38 35 39 36 /** … … 57 54 } 58 55 59 return clone $this->x mlParser->getConfigValue($id);56 return clone $this->xjconf->getConfigValue($id); 60 57 } 61 58 … … 69 66 { 70 67 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')); 75 70 } 76 71 77 72 try { 78 $this->x mlParser->parse($source);79 } catch ( XJConfException $xjce) {73 $this->xjconf->parse($source); 74 } catch (stubXJConfException $xjce) { 80 75 $this->initDone[$source] = false; 81 76 throw new stubRequestValueErrorException($xjce->getMessage()); trunk/src/main/php/net/stubbles/util/log/stubLoggerXJConfFactory.php
r219 r312 7 7 * @subpackage util_log 8 8 */ 9 stubClassLoader::load('net.stubbles.util.xjconf.stubXJConfLoader', 10 'net.stubbles.util.xjconf.stubConfigXJConfExtension', 9 stubClassLoader::load('net.stubbles.util.xjconf.xjconf', 11 10 'net.stubbles.stubFactory' 12 );13 XJConfLoader::load('DefinitionParser',14 'XmlParser'15 11 ); 16 12 /** … … 28 24 * 29 25 * @param string $configFile 30 * @throws stub Exception26 * @throws stubXJConfException 31 27 */ 32 28 public static function init($configFile) 33 29 { 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')); 37 32 $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); 45 35 } 46 36 } trunk/src/main/php/net/stubbles/util/stubRegistryFactory.php
r219 r312 7 7 * @subpackage util 8 8 */ 9 stubClassLoader::load('net.stubbles.util.xjconf. stubXJConfLoader');9 stubClassLoader::load('net.stubbles.util.xjconf.xjconf'); 10 10 /** 11 11 * Class for initializing the Registry. … … 20 20 * initialize the Registry with configuration values from given configuration file 21 21 * 22 * @param string $configFile 22 * @param string $configFile 23 * @throws stubXJConfException 23 24 */ 24 25 public static function init($configFile) 25 26 { 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); 35 30 } 36 31 } trunk/src/main/php/net/stubbles/util/xjconf/stubConfigXJConfExtension.php
r150 r312 7 7 * @subpackage util_xjconf 8 8 */ 9 stubClassLoader::load('net.stubbles.util.xjconf. stubXJConfLoader');9 stubClassLoader::load('net.stubbles.util.xjconf.xjconf'); 10 10 XJConfLoader::load('ext.Extension'); 11 11 /** … … 17 17 * <?xml version="1.0" encoding="iso-8859-1"?> 18 18 * <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"> 22 22 * <logger id="default" level="15"> 23 23 * <logAppender type="net.stubbles.util.log.stubFileLogAppender"> … … 41 41 * @var string 42 42 */ 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'; 54 44 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 /** 56 56 * Process a start element 57 57 * … … 60 60 * @throws XJConfException 61 61 */ 62 public function startElement(XmlParser $parser, Tag $tag)62 public function startElement(XmlParser $parser, Tag $tag) 63 63 { 64 64 // nothing to do here 65 }65 } 66 66 67 /**67 /** 68 68 * Process the end element 69 69 * … … 72 72 * @throws XJConfException 73 73 */ 74 public function endElement(XmlParser $parser, Tag $tag)75 {76 // add several values77 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 } 92 92 } 93 93 ?> trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfLoader.php
r171 r312 8 8 * @subpackage util_xjconf 9 9 */ 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 } 10 stubClassLoader::load('net.stubbles.util.xjconf.xjconf'); 18 11 XJConfLoader::load('XJConfClassLoader'); 19 12 /** … … 83 76 { 84 77 $className = explode('.', $fqClassName); 85 return $className[count($className) - 1];78 return $className[count($className) - 1]; 86 79 } 87 80 } trunk/src/main/php/net/stubbles/websites/stubXJConfPageFactory.php
r292 r312 8 8 */ 9 9 stubClassLoader::load('net.stubbles.stubFactory', 10 'net.stubbles.util.xjconf. stubXJConfLoader',10 'net.stubbles.util.xjconf.xjconf', 11 11 'net.stubbles.websites.stubPageConfigurationException', 12 12 'net.stubbles.websites.stubPageFactory', 13 13 'net.stubbles.stubFactory' 14 );15 XJConfLoader::load('DefinitionParser',16 'XmlParser',17 'XJConfClassLoader'18 14 ); 19 15 /** … … 28 24 * the xml parser 29 25 * 30 * @var XmlParser26 * @var stubXJConfFacade 31 27 */ 32 private static $x mlParser;28 private static $xjconf; 33 29 34 30 /** … … 39 35 public function __construct(stubXJConfLoader $classLoader) 40 36 { 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')); 47 40 } 48 41 } … … 70 63 $configSource = stubConfig::getConfigPath() . '/xml/pages/' . $configSource . '.xml'; 71 64 try { 72 self::$x mlParser->parse($configSource);73 } catch ( XJConfException $xjce) {65 self::$xjconf->parse($configSource); 66 } catch (stubXJConfException $xjce) { 74 67 throw new stubPageConfigurationException('Can not read page configuration from ' . $configSource, $xjce); 75 68 } 76 69 77 return self::$x mlParser->getConfigValue('page');70 return self::$xjconf->getConfigValue('page'); 78 71 } 79 72 }
