Changeset 241
- Timestamp:
- 02/07/07 14:53:30 (1 year ago)
- Files:
-
- trunk/config/xml/processors.xml (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/processors/stubDefaultProcessorResolver.php (added)
- trunk/src/main/php/net/stubbles/websites/processors/stubProcessorResolver.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/websites/processors/stubSimpleProcessorResolver.php (added)
- trunk/src/main/php/net/stubbles/websites/stubFrontController.php (added)
- trunk/src/main/resources/xjconf/processors.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/config/xml/processors.xml
r240 r241 3 3 xmlns:xj="http://xjconf.net/XJConf" 4 4 xmlns="http://stubbles.net/websites"> 5 <processors> 6 <processor name="default">net.stubbles.websites.processors.stubPageProcessor</processor> 7 <processor name="page">net.stubbles.websites.processors.stubPageProcessor</processor> 8 </processors> 5 <defaultResolver default="page"> 6 <processor name="page" type="net.stubbles.websites.processors.stubPageProcessor" /> 7 </defaultResolver> 9 8 </xj:configuration> trunk/src/main/php/net/stubbles/websites/processors/stubProcessorResolver.php
r240 r241 1 1 <?php 2 2 /** 3 * Factory to resolve the correct processor to use.3 * Interface for processor resolvers. 4 4 * 5 5 * @author Frank Kleine <mikey@stubbles.net> … … 7 7 * @subpackage websites_processors 8 8 */ 9 stubClassLoader::load('net.stubbles.stubFactory', 10 'net.stubbles.ipo.request.stubRequest', 9 stubClassLoader::load('net.stubbles.ipo.request.stubRequest', 11 10 'net.stubbles.ipo.session.stubSession', 12 'net.stubbles.util.validators.stubPreSelectValidator',13 'net.stubbles.util.xjconf.stubXJConfLoader',14 11 'net.stubbles.websites.processors.stubProcessor', 15 12 'net.stubbles.websites.processors.stubProcessorException' 16 13 ); 17 XJConfLoader::load('DefinitionParser',18 'XmlParser',19 'XJConfClassLoader'20 );21 14 /** 22 * Factory to resolve the correct processor to use.15 * Interface for processor resolvers. 23 16 * 24 17 * @static … … 26 19 * @subpackage websites_processors 27 20 */ 28 classstubProcessorResolver21 interface stubProcessorResolver 29 22 { 30 23 /** … … 36 29 * @throws stubProcessorException 37 30 */ 38 public static function resolve(stubRequest $request, stubSession $session) 39 { 40 $tagParser = new DefinitionParser(array('http://stubbles.net/websites' => stubXJConfLoader::getInstance())); 41 $defs = $tagParser->parse(stubFactory::getResourceURI('xjconf/processors.xml')); 42 43 $xmlParser = new XmlParser(); 44 $xmlParser->setTagDefinitions($defs); 45 46 try { 47 $xmlParser->parse(stubConfig::getConfigPath() . '/xml/processors.xml'); 48 } catch (XJConfException $xjce) { 49 throw new stubProcessorException('Can not load processor configuration.', $xjce); 50 } 51 52 $processors = $xmlParser->getConfigValue('processors'); 53 if ($request->hasValue('processor') == false) { 54 $processorName = 'default'; 55 } else { 56 $processorName = $request->getValidatedValue(new stubPreSelectValidator(array_keys($processors)), 'processor'); 57 if (null == $processorName) { 58 $processorName = 'default'; 59 } 60 } 61 62 stubClassLoader::load($processors[$processorName]); 63 $className = stubClassLoader::getNonQualifiedClassName($processors[$processorName]); 64 $processor = new $className($request, $session); 65 if (($processor instanceof stubProcessor) == false) { 66 throw new stubProcessorException($processors[$processorName] . ' is not an instance of ' . stubClassLoader::getFullQualifiedClassName('stubProcessor')); 67 } 68 69 return $processor; 70 } 31 public function resolve(stubRequest $request, stubSession $session); 71 32 } 72 33 ?> trunk/src/main/resources/xjconf/processors.xml
r240 r241 2 2 <defines> 3 3 <namespace uri="http://stubbles.net/websites"> 4 <tag name="processors" type="array" /> 5 <tag name="processor" type="string" keyAttribute="name" /> 4 <tag name="defaultResolver" type="net.stubbles.websites.processors.stubDefaultProcessorResolver" keyAttribute="resolver"> 5 <attribute name="default" type="string" /> 6 </tag> 7 <tag name="processor" type="string" > 8 <setterMethod name="addProcessor"> 9 <attribute name="name" type="string" /> 10 <attribute name="type" type="string" /> 11 </setterMethod> 12 </tag> 13 <tag name="simpleResolver" type="net.stubbles.websites.processors.stubSimpleProcessorResolver" keyAttribute="resolver"> 14 <attribute name="processor" type="string" /> 15 </tag> 6 16 </namespace> 7 17 </defines>
