private static RuleController getRule ( String baseUri , UnitRequest controllerRequest , TransactionalNotifyHandler handler ) { if ( ruleMap == null ) { synchronized ( LOCK_FOR_LAZY_INITIALIZATION ) { if ( ruleMap == null ) { loadRules ( ) ; } } } try { if ( ruleMap . get ( baseUri ) != null ) { Constructor < ? extends RuleController > constructor = ruleMap . get ( baseUri ) . getConstructor ( ) ; //rule controller is stateful, so we need to create new instance for each request. RuleController controller = constructor . newInstance ( ) ; controller . setHandler ( handler . setTransactional ( controller . isTransactional ( ) ) ) ; controller . setControllerRequest ( controllerRequest ) ; LOG . debug ( "rule found: " + controller . getClass ( ) + " for uri " + baseUri ) ; return controller ; } LOG . debug ( "rule controller not mapped:" + baseUri ) ; return null ; } catch ( Throwable e ) { throw new RuntimeException ( "error while mapping rule controller for uri " + baseUri , e ) ; } }
This method is in fact a factory method which produces the mapped rule controller .