public void addEventListener( final RuleBaseEventListener listener ) { // no need for synchonization or locking because eventSupport is thread-safe this.eventSupport.addEventListener( listener ); }
/** * Notify listeners and sub-classes about imminent removal of a function from a package. * * This method is called with the rulebase lock held. * @param pkg * @param functionName */ private void removeFunction( final Package pkg, final String functionName ) { this.eventSupport.fireBeforeFunctionRemoved( pkg, functionName ); removeFunction( functionName ); this.eventSupport.fireAfterFunctionRemoved( pkg, functionName ); }
public void lock() { // The lock is reentrant, so we need additional magic here to skip // notifications for locked if this thread already has locked it. boolean firstLock = !this.lock.isWriteLockedByCurrentThread(); if (firstLock) { this.eventSupport.fireBeforeRuleBaseLocked(); } // Always lock to increase the counter this.lock.writeLock(); if ( firstLock ) { this.additionsSinceLock = 0; this.removalsSinceLock = 0; this.eventSupport.fireAfterRuleBaseLocked(); } }
public void unlock() { boolean lastUnlock = this.lock.getWriteHoldCount() == 1; if (lastUnlock) { this.eventSupport.fireBeforeRuleBaseUnlocked(); } this.lock.writeUnlock(); if ( lastUnlock ) { this.eventSupport.fireAfterRuleBaseUnlocked(); } }
public void addProcess( final Process process ) { // XXX: could use a synchronized(processes) here. this.eventSupport.fireBeforeProcessAdded( process ); lock(); try { this.processes.put( process.getId(), process ); } finally { unlock(); } this.eventSupport.fireAfterProcessAdded( process ); }
public void removeProcess( final String id ) { Process process = this.processes.get( id ); if (process == null) { throw new IllegalArgumentException( "Process '" + id + "' does not exist for this Rule Base." ); } this.eventSupport.fireBeforeProcessRemoved( process ); lock(); try { this.processes.remove( id ); this.pkgs.get(process.getPackageName()).removeRuleFlow(id); } finally { unlock(); } this.eventSupport.fireAfterProcessRemoved( process ); }
public void addRule( final Package pkg, final Rule rule ) throws InvalidPatternException { lock(); try { this.eventSupport.fireBeforeRuleAdded( pkg, rule ); // if ( !rule.isValid() ) { // throw new IllegalArgumentException( "The rule called " + rule.getName() + " is not valid. Check for compile errors reported." ); // } addRule( rule ); this.eventSupport.fireAfterRuleAdded( pkg, rule ); } finally { unlock(); } }
/** * Notify listeners and sub-classes about imminent removal of a rule from a package. * * @param pkg * @param rule */ // FIXME: removeRule(String, String) and removeRule(Package, Rule) do totally different things! public void removeRule( final Package pkg, final Rule rule ) { lock(); try { this.eventSupport.fireBeforeRuleRemoved( pkg, rule ); removeRule( rule ); this.eventSupport.fireAfterRuleRemoved( pkg, rule ); } finally { unlock(); } }
this.eventSupport.fireBeforePackageRemoved( pkg ); this.eventSupport.fireAfterPackageRemoved( pkg ); } finally { unlock();
newPkg.checkValidity(); this.additionsSinceLock++; this.eventSupport.fireBeforePackageAdded( newPkg ); this.eventSupport.fireAfterPackageAdded( newPkg );