Changeset 1006

Show
Ignore:
Timestamp:
11/08/07 20:20:01 (1 year ago)
Author:
schst
Message:

Check, whether binder already is in registry before creating a binder,
added abstract base class for IoC interceptors

Files:

Legend:

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

    r852 r1006  
    3131 */ 
    3232class stubBinder extends stubBaseObject { 
     33 
     34    /** 
     35     * Key for storing the binder in the registry 
     36     */ 
     37    const REGISTRY_KEY = 'net.stubbles.ioc.stubBinder'; 
    3338 
    3439    /** 
  • trunk/src/main/php/net/stubbles/ioc/stubIOCPreInterceptor.php

    r867 r1006  
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     6 * @author      Stephan Schmidt <schst@stubbles.net> 
    67 * @package     stubbles 
    78 * @subpackage  ioc 
    89 */ 
    910stubClassLoader::load('net.stubbles.ipo.interceptors.stubPreInterceptor', 
    10                       'net.stubbles.ioc.ioc', 
     11                      'net.stubbles.ioc.stubBinder', 
    1112                      'net.stubbles.util.stubRegistry' 
    1213); 
     
    2829    public function preProcess(stubRequest $request, stubSession $session, stubResponse $response) 
    2930    { 
    30         $binder = new stubBinder(); 
     31        $binder = stubRegistry::get(stubBinder::REGISTRY_KEY); 
     32        if ($binder === null) { 
     33            $binder = new stubBinder(); 
     34            stubRegistry::set(stubBinder::REGISTRY_KEY, $binder); 
     35        } 
    3136        $binder->bind('stubRequest')->toInstance($request); 
    3237        $binder->bind('stubSession')->toInstance($session); 
    3338        $binder->bind('stubResponse')->toInstance($response); 
    34         stubRegistry::set('net.stubbles.ioc.stubBinder', $binder); 
    3539    } 
    3640}