Changeset 311

Show
Ignore:
Timestamp:
02/28/07 18:07:11 (1 year ago)
Author:
mikey
Message:

added correct injection handling
added request and session creation (draft)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/stubFrontController.php

    r241 r311  
    88 */ 
    99stubClassLoader::load('net.stubbles.stubFactory', 
     10                      'net.stubbles.ioc.injection.injection', 
     11                      'net.stubbles.ipo.request.stubWebRequest', 
     12                      'net.stubbles.ipo.session.stubPHPSession', 
     13                      'net.stubbles.util.stubRegistry', 
    1014                      'net.stubbles.util.xjconf.stubXJConfLoader' 
    1115); 
     
    4145     */ 
    4246    protected $resolver; 
     47    /** 
     48     * the list of injections 
     49     * 
     50     * @var  stubInjectionMap 
     51     */ 
     52    protected $injectionMap; 
    4353    /** 
    4454     * contains request data 
     
    8393            throw new stubException($xjce->getMessage()); 
    8494        } 
     95        $this->resolver     = $xmlParser->getConfigValue('resolver'); 
    8596         
    86         $this->resolver = $xmlParser->getConfigValue('resolver'); 
     97        $this->injectionMap = new stubInjectionMap(); 
     98        if (stubRegistry::hasConfig('net.stubbles.ipo.request.class') == true) { 
     99            $fqClassName = stubRegistry::getConfig('net.stubbles.ipo.request.class'); 
     100            stubClassLoader::load($fqClassName); 
     101            $className = stubClassLoader::getNonQualifiedClassName($fqClassName); 
     102            $request   = new $className(); 
     103            if (($request instanceof stubRequest) == false) { 
     104                throw new stubException('Configured request class is not an instance of stubRequest.'); 
     105            } 
     106             
     107            $this->injectionMap->addInjection('stubRequest', $request); 
     108        } else { 
     109            $this->injectionMap->addInjection('stubRequest', new stubWebRequest()); 
     110        } 
     111         
     112        if (stubRegistry::hasConfig('net.stubbles.ipo.session.class') == true) { 
     113            $fqClassName = stubRegistry::getConfig('net.stubbles.ipo.session.class'); 
     114            stubClassLoader::load($fqClassName); 
     115            $className = stubClassLoader::getNonQualifiedClassName($fqClassName); 
     116            $session   = new $className(); 
     117            if (($session instanceof stubSession) == false) { 
     118                throw new stubException('Configured session class is not an instance of stubSession.'); 
     119            } 
     120             
     121            $this->injectionMap->addInjection('stubSession', $session); 
     122        } else { 
     123            $this->injectionMap->addInjection('stubSession', new stubPHPSession()); 
     124        } 
    87125    } 
    88126 
     
    93131    { 
    94132        foreach ($this->preInterceptors as $preInterceptor) { 
    95             #Inject::factory(array(), $preInterceptor); 
     133            stubInjectAnnotation::factory($this->injectionMap, $preInterceptor); 
    96134            $preInterceptor->preProcess(); 
    97135        } 
     
    101139     * processes all postinterceptors 
    102140     */ 
    103     protected function tearDown(stubResponse $response
     141    protected function tearDown(
    104142    { 
    105143        foreach ($this->postInterceptors as $postInterceptor) { 
    106             #Inject::factory(array(), $postInterceptor); 
    107             $postInterceptor->preProcess(); 
     144            stubInjectAnnotation::factory($this->injectionMap, $postInterceptor); 
     145            $postInterceptor->postProcess(); 
    108146        } 
    109147    } 
     
    116154        $this->startUp(); 
    117155        $response = $this->resolver->resolve($this->request, $this->session)->process()->getResponse(); 
    118         $this->tearDown($response); 
     156        $this->injectionMap->addInjection('stubResponse', $response); 
     157        $this->tearDown(); 
    119158        $response->send(); 
    120159    }