public synchronized void reloadRulebase ( ) throws RuleBaseException { long start = System . currentTimeMillis ( ) ; reloadDeclarations ( ) ; packageStrings . clear ( ) ; for ( RuleBaseElementId id : manager . listAll ( RuleBaseElementType . Function ) ) { String packageName = id . getPackageName ( ) ; StringBuffer packageString = getPackageString ( packageName ) ; String code = manager . get ( id ) ; packageString . append ( code ) ; } for ( RuleBaseElementId id : manager . listAll ( RuleBaseElementType . Rule ) ) { String packageName = id . getPackageName ( ) ; StringBuffer packageString = getPackageString ( packageName ) ; String code = manager . get ( id ) ; String formattedRule = String . format ( RULE_TEMPLATE , id . getName ( ) , code ) ; packageString . append ( formattedRule ) ; } for ( RuleBaseElementId id : manager . listAll ( RuleBaseElementType . Process ) ) { getPackageString ( id . getPackageName ( ) ) ; } Collection < KnowledgePackage > compiledPackages = new HashSet < KnowledgePackage > ( ) ; if ( packageStrings . isEmpty ( ) ) { Set < String > emptySet = Collections . emptySet ( ) ; compiledPackages . addAll ( compileDrlString ( "package dummy;\n" + declarations , emptySet ) ) ; } else { for ( Map . Entry < String , StringBuffer > entry : packageStrings . entrySet ( ) ) { String packageName = entry . getKey ( ) ; StringBuffer drlCode = entry . getValue ( ) ; Collection < String > flows = queryFlows ( packageName ) ; Collection < KnowledgePackage > compiledDrlPackage = compileDrlString ( drlCode . toString ( ) , flows ) ; compiledPackages . addAll ( compiledDrlPackage ) ; } } lockRuleBase ( ) ; clearRulebase ( ) ; base . addKnowledgePackages ( compiledPackages ) ; unlockRuleBase ( ) ; LOGGER . info ( "Reloading the rulebase took {}ms" , System . currentTimeMillis ( ) - start ) ; }
reloads the rulebase but keeps references intact