45 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/**
 | 
						|
 * This file is part of Rubanetra.
 | 
						|
 * Copyright (C) 2013,2014 Stefan Swerk (stefan_rubanetra@swerk.priv.at)
 | 
						|
 *
 | 
						|
 * This program is free software: you can redistribute it and/or modify
 | 
						|
 * it under the terms of the GNU General Public License as published by
 | 
						|
 * the Free Software Foundation, either version 3 of the License, or
 | 
						|
 * (at your option) any later version.
 | 
						|
 *
 | 
						|
 * This program is distributed in the hope that it will be useful,
 | 
						|
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
						|
 * GNU General Public License for more details.
 | 
						|
 *
 | 
						|
 * You should have received a copy of the GNU General Public License
 | 
						|
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
						|
 */
 | 
						|
import at.jku.fim.rubanetra.protocol.activity.*;
 | 
						|
 | 
						|
// using the MVEL expression language, see http://mvel.codehaus.org/
 | 
						|
dialect  "mvel"
 | 
						|
 | 
						|
/**
 | 
						|
 * This global variable constitutes the default output writer that is used to write derived facts, i.e. Activity objects,
 | 
						|
 * to the final output stream.
 | 
						|
 */
 | 
						|
global at.jku.fim.rubanetra.output.OutputWriterStrategy outputWriter;
 | 
						|
 | 
						|
/**
 | 
						|
 * This rule will ensure that all encountered OutputActivityEvents will be written to the final output stream,
 | 
						|
 * as long as the enclosed Activity 'toOutput' is not null and the global 'outputWriter' exists.
 | 
						|
 * The encountered, valid OutputActivityEvent will be retracted afterwards.
 | 
						|
 * This behaviour is useful to free memory in case the default event expiration time is not defined or
 | 
						|
 * set to a high value.
 | 
						|
 */
 | 
						|
rule "Write to OutputStream (event-based)"
 | 
						|
    when
 | 
						|
        $outEvent : OutputActivityEvent(toOutput != null)
 | 
						|
    then
 | 
						|
        if (outputWriter != null) {
 | 
						|
            outputWriter.writeActivity($outEvent.getToOutput());
 | 
						|
        }
 | 
						|
        retract($outEvent);
 | 
						|
end
 |