Changeset 1751

Show
Ignore:
Timestamp:
07/30/08 15:43:04 (4 months ago)
Author:
mikey
Message:

add net::stubbles::ioc::stubBinderRegistry as helper class

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework/trunk/src/main/php/net/stubbles/ioc/stubAbstractIOCPreInterceptor.php

    r1534 r1751  
    99stubClassLoader::load('net::stubbles::ipo::interceptors::stubPreInterceptor', 
    1010                      'net::stubbles::ioc::stubBinder', 
    11                       'net::stubbles::lang::stubRegistry' 
     11                      'net::stubbles::ioc::stubBinderRegistry' 
    1212); 
    1313/** 
     
    2828    public function preProcess(stubRequest $request, stubSession $session, stubResponse $response) 
    2929    { 
    30         $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
    31         if (null === $binder) { 
    32             $binder = new stubBinder(); 
    33             stubRegistry::set(stubBinder::REGISTRY_KEY, $binder); 
    34         } 
    35          
    36         $this->configure($binder); 
     30        $this->configure(stubBinderRegistry::create()); 
    3731    } 
    3832 
  • framework/trunk/src/main/php/net/stubbles/ioc/stubBindingScopeSession.php

    r1534 r1751  
    88 */ 
    99stubClassLoader::load('net::stubbles::ioc::stubBinder', 
     10                      'net::stubbles::ioc::stubBinderRegistry', 
    1011                      'net::stubbles::ioc::stubBindingScope', 
    1112                      'net::stubbles::ioc::stubValueInjectionProvider', 
    12                       'net::stubbles::lang::stubRegistry', 
    1313                      'net::stubbles::lang::exceptions::stubRuntimeException' 
    1414); 
     
    8888    /** 
    8989     * retrieves the session from the binder 
    90      * 
    91      * @throws  stubRuntimeException 
    9290     */ 
    9391    protected function getSession() 
    9492    { 
    95         $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
    96         if (null === $binder) { 
    97             throw new stubRuntimeException('Can not return provider, no access to session possible because of missing binder instance in registry.'); 
    98         } 
    99          
    100         $this->session = $binder->getInjector()->getInstance('stubSession'); 
     93        $this->session = stubBinderRegistry::get()->getInjector()->getInstance('stubSession'); 
    10194    } 
    10295} 
  • framework/trunk/src/main/php/net/stubbles/ioc/stubIOCPreInterceptor.php

    r1534 r1751  
    99 */ 
    1010stubClassLoader::load('net::stubbles::ipo::interceptors::stubPreInterceptor', 
    11                       'net::stubbles::ioc::stubBinder', 
    12                       'net::stubbles::lang::stubRegistry' 
     11                      'net::stubbles::ioc::stubBinderRegistry' 
    1312); 
    1413/** 
     
    2928    public function preProcess(stubRequest $request, stubSession $session, stubResponse $response) 
    3029    { 
    31         $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
    32         if (null === $binder) { 
    33             $binder = new stubBinder(); 
    34             stubRegistry::set(stubBinder::REGISTRY_KEY, $binder); 
    35         } 
    36          
     30        $binder = stubBinderRegistry::create(); 
    3731        $binder->bind('stubRequest')->toInstance($request); 
    3832        $binder->bind('stubSession')->toInstance($session); 
  • framework/trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcAbstractInvokingSubProcessor.php

    r1547 r1751  
    99 * @subpackage  service_jsonrpc_subprocessors 
    1010 */ 
    11 stubClassLoader::load('net::stubbles::ioc::stubBinder', 
     11stubClassLoader::load('net::stubbles::ioc::stubBinderRegistry', 
    1212                      'net::stubbles::ipo::request::validator::stubPassThruValidator', 
    13                       'net::stubbles::lang::stubRegistry', 
    1413                      'net::stubbles::reflection::reflection', 
    1514                      'net::stubbles::service::annotations::stubWebMethodAnnotation', 
     
    8180        } 
    8281 
    83         $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
    84         if (($binder instanceof stubBinder) === false) { 
    85             throw new stubRuntimeException('No instance of net::stubbles::ioc::stubBinder in registry.'); 
    86         } 
    87  
    88         $instance = $binder->getInjector()->getInstance($class->getName()); 
     82        $instance = stubBinderRegistry::get()->getInjector()->getInstance($class->getName()); 
    8983        return $method->invokeArgs($instance, $params); 
    9084    } 
  • framework/trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisLoadExtensionPageElement.php

    r1508 r1751  
    88 */ 
    99stubClassLoader::load('net::stubbles::lang::exceptions::stubIOException', 
    10                       'net::stubbles::ioc::stubBinder', 
     10                      'net::stubbles::ioc::stubBinderRegistry', 
    1111                      'net::stubbles::websites::memphis::stubMemphisExtension', 
    1212                      'net::stubbles::websites::memphis::stubMemphisPageElement' 
     
    6666        parent::init($request, $session, $response, $context); 
    6767        if (null === $this->extension) { 
    68             $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
    69             if (($binder instanceof stubBinder) === false) { 
    70                 throw new stubRuntimeException('No instance of net::stubbles::ioc::stubBinder in registry.'); 
    71             } 
    72              
     68            $binder = stubBinderRegistry::get(); 
    7369            $binder->bindConstant()->named('context')->to($this->context); 
    7470            $binder->bind('stubRequest')->named('prefixed')->toInstance($this->request); 
  • framework/trunk/src/main/php/net/stubbles/websites/xml/skin/stubDefaultSkinGenerator.php

    r1737 r1751  
    77 * @subpackage  websites_xml_skin 
    88 */ 
    9 stubClassLoader::load('net::stubbles::ioc::stubBinder', 
     9stubClassLoader::load('net::stubbles::ioc::stubBinderRegistry', 
    1010                      'net::stubbles::lang::stubFactory', 
    1111                      'net::stubbles::lang::stubRegistry', 
     
    112112    public function generate(stubSession $session, stubPage $page, $skinName) 
    113113    { 
    114         $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
    115         if (($binder instanceof stubBinder) === false) { 
    116             throw new stubRuntimeException('No instance of net::stubbles::ioc::stubBinder in registry.'); 
    117         } 
    118          
     114        $binder = stubBinderRegistry::get(); 
    119115        $binder->bind('stubXMLStreamWriter')->to(stubXMLStreamWriterFactory::getFqClassNameAsAvailable()); 
    120116        $binder->bindConstant()->named('imagePath')->to(getcwd()); 
  • framework/trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php

    r1737 r1751  
    88 * @subpackage  websites_xml 
    99 */ 
    10 stubClassLoader::load('net::stubbles::ioc::stubBinder', 
     10stubClassLoader::load('net::stubbles::ioc::stubBinderRegistry', 
    1111                      'net::stubbles::lang::stubRegistry', 
    1212                      'net::stubbles::lang::exceptions::stubRuntimeException', 
     
    8383        } 
    8484         
    85         $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
    86         if (($binder instanceof stubBinder) === false) { 
    87             throw new stubRuntimeException('XML/XSL view engine requires IoC.'); 
    88         } 
    89          
     85        $binder = stubBinderRegistry::get(); 
    9086        $binder->bind('stubPage')->toInstance($this->page); 
    9187        $injector = $binder->getInjector(); 
  • framework/trunk/src/main/php/net/stubbles/xml/rss/stubRSSProcessor.php

    r1649 r1751  
    77 * @subpackage  xml_rss 
    88 */ 
    9 stubClassLoader::load('net::stubbles::ioc::stubBinder', 
     9stubClassLoader::load('net::stubbles::ioc::stubBinderRegistry', 
    1010                      'net::stubbles::ipo::request::validator::stubPreSelectValidator', 
    11                       'net::stubbles::lang::stubRegistry', 
    1211                      'net::stubbles::lang::exceptions::stubFileNotFoundException', 
    1312                      'net::stubbles::lang::exceptions::stubRuntimeException', 
     
    6968        } 
    7069         
    71         $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
    72         if (($binder instanceof stubBinder) === false) { 
    73             throw new stubRuntimeException('No binder configured in registry.'); 
    74         } 
    75          
     70        $binder = stubBinderRegistry::get(); 
    7671        $this->response->addHeader('Content-Type', 'text/xml'); 
    7772        $this->response->write($binder->getInjector() 
  • framework/trunk/src/test/php/net/stubbles/ioc/IOCTestSuite.php

    r1390 r1751  
    3030        $suite->addTestFile($dir . '/annotations/stubSingletonAnnotationTestCase.php'); 
    3131        $suite->addTestFile($dir . '/stubAbstractIOCPreInterceptorTestCase.php'); 
     32        $suite->addTestFile($dir . '/stubBinderRegistryTestCase.php'); 
    3233        $suite->addTestFile($dir . '/stubBinderTestCase.php'); 
    3334        $suite->addTestFile($dir . '/stubInjectorBasicTestCase.php');