Changeset 446
- Timestamp:
- 03/29/07 23:24:48 (2 years ago)
- Files:
-
- trunk/lib/xjconf.star (modified) (previous)
- trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueErrorFactory.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueErrorXJConfFactory.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfFacade.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/integration/stubRequestValueErrorXJConfFactoryTestCase.php (added)
- trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/request/stubRequestValueErrorXJConfFactoryTestCase.php (deleted)
- trunk/src/test/resources/ipo (deleted)
- trunk/src/test/runIntegration.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueErrorFactory.php
r142 r446 20 20 * 21 21 * @param string $id id of RequestValueError to create 22 * @param string $source optional source where RequestValueError is defined23 22 * @return stubRequestValueError 24 23 * @throws stubRequestValueErrorException 25 24 */ 26 public function create($id , $source = null);25 public function create($id); 27 26 } 28 27 ?> trunk/src/main/php/net/stubbles/ipo/request/stubRequestValueErrorXJConfFactory.php
r444 r446 24 24 * switches whether initialization has been done 25 25 * 26 * @var array< bool>26 * @var array<string,stubRequestValueError> 27 27 */ 28 protected $initDone = array(); 28 protected static $requestValueErrors = null; 29 29 30 /** 30 * instance of the parser that parses the xml configuration files31 * 32 * @ var stubXJConfFacade31 * constructor 32 * 33 * @throws stubRequestValueErrorException 33 34 */ 34 protected $xjconf; 35 public function __construct() 36 { 37 if (null == self::$requestValueErrors) { 38 self::$requestValueErrors = array(); 39 $xjconf = new stubXJConfFacade(array('__default' => stubXJConfLoader::getInstance())); 40 $xjconf->parseAndAddDefinitions(stubFactory::getResourceURIs('xjconf/request.xml')); 41 $sources = stubFactory::getResourceURIs('ipo/request.xml'); 42 foreach ($sources as $source) { 43 try { 44 $xjconf->parse($source); 45 } catch (stubXJConfException $xjce) { 46 throw new stubRequestValueErrorException($xjce->getMessage()); 47 } 48 49 self::$requestValueErrors = array_merge(self::$requestValueErrors, $xjconf->getConfigValues()); 50 } 51 } 52 } 35 53 36 54 /** … … 40 58 * 41 59 * @param string $id id of RequestValueError to create 42 * @param string $source optional source where RequestValueError is defined43 60 * @return stubRequestValueError 44 61 * @throws stubRequestValueErrorException 45 62 */ 46 public function create($id , $source = null)63 public function create($id) 47 64 { 48 if ( null == $source) {49 $source = stubFactory::getResourceURIs('ipo/request.xml');65 if (isset(self::$requestValueErrors[$id]) == true) { 66 return clone self::$requestValueErrors[$id]; 50 67 } 51 68 52 if (is_array($source) == false) { 53 $source = array($source); 54 } 55 56 foreach ($source as $sourceURI) { 57 if (isset($this->initDone[$sourceURI]) == false) { 58 $this->init($sourceURI); 59 } 60 } 61 62 return clone $this->xjconf->getConfigValue($id); 63 } 64 65 /** 66 * initialize the XJConf stuff and parse the given configuration source file 67 * 68 * @param string $source source where RequestValueErrors are defined 69 * @throws stubRequestValueErrorException 70 */ 71 protected function init($source = null) 72 { 73 if (count($this->initDone) == 0) { 74 $this->xjconf = new stubXJConfFacade(array('__default' => stubXJConfLoader::getInstance())); 75 $this->xjconf->parseAndAddDefinitions(stubFactory::getResourceURIs('xjconf/request.xml')); 76 } 77 78 try { 79 $this->xjconf->parse($source); 80 } catch (stubXJConfException $xjce) { 81 $this->initDone[$source] = false; 82 throw new stubRequestValueErrorException($xjce->getMessage()); 83 } 84 85 $this->initDone[$source] = true; 69 throw new stubRequestValueErrorException('RequestValueError with id ' . $id . ' does not exist.'); 86 70 } 87 71 } trunk/src/main/php/net/stubbles/util/xjconf/stubXJConfFacade.php
r440 r446 171 171 172 172 /** 173 * checks whether a data structure associated with this name exists 174 * 175 * @param string $name 176 * @return bool 177 * @throws stubXJConfException 178 */ 179 public function hasConfigValue($name) 180 { 181 if (null == $this->xmlParser) { 182 throw new stubXJConfException('Invalid state: needs to parse first.'); 183 } 184 185 return $this->xmlParser->hasConfigValue($name); 186 } 187 188 /** 173 189 * returns the data structure associated with this name 174 190 * … … 185 201 return $this->xmlParser->getConfigValue($name); 186 202 } 203 204 /** 205 * returns a list of all data structures 206 * 207 * @return mixed 208 * @throws stubXJConfException 209 */ 210 public function getConfigValues() 211 { 212 if (null == $this->xmlParser) { 213 throw new stubXJConfException('Invalid state: needs to parse first.'); 214 } 215 216 return $this->xmlParser->getConfigValues(); 217 } 187 218 } 188 219 ?> trunk/src/test/php/net/stubbles/ipo/IPOTestSuite.php
r444 r446 25 25 $this->addTestFile($dir . '/request/stubRequestPrefixDecoratorTestCase.php'); 26 26 $this->addTestFile($dir . '/request/stubRequestValueErrorTestCase.php'); 27 $this->addTestFile($dir . '/request/stubRequestValueErrorXJConfFactoryTestCase.php');28 27 29 28 $this->addTestFile($dir . '/request/filters/stubFloatFilterTestCase.php'); trunk/src/test/runIntegration.php
r400 r446 35 35 $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/integration/ProcessorTestCase.php'); 36 36 $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/integration/RegistryTestCase.php'); 37 $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/integration/stubRequestValueErrorXJConfFactoryTestCase.php'); 37 38 $testSuite->addTestFile(TEST_SRC_PATH . '/php/net/stubbles/integration/VariantManagerTestCase.php'); 38 39 if (PHP_SAPI == 'cli') {
