All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nyla.solutions.commas.MacroExecutable Maven / Gradle / Ivy

The newest version!
package nyla.solutions.commas;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import nyla.solutions.core.data.Environment;
import nyla.solutions.core.exception.RequiredException;

/**
 * 
 * MacroExecutable implementation of the Executable 
 * based on the command design pattern.
 * Sample Spring Configuration
 * 
 * 	
			
				 			         
			         
			         
			      
			
	
 * 
* @author Gregory Green * */ public class MacroExecutable implements Executable, CloneableExecutable { /** * Execute all given executables */ public Integer execute(Environment env) { if(this.executables == null) throw new RequiredException("Executable not set on "+this.getClass().getName()); synchronized(executables) { //execute each executable for(Iterator i = this.executables.iterator();i.hasNext();) { ((Executable)i.next()).execute(env); } } return 0; }//--------------------------------------------- /** * @return the executables */ public Collection getExecutables() { return executables; }//--------------------------------------------- /** * @param executables the executables to set */ public void setExecutables(Collection executables) { if(executables == null) throw new RequiredException("executables in MacroExecutable"); this.executables = executables; }//--------------------------------------------- /** * @return copy of MacroExecutable */ public Object clone() throws CloneNotSupportedException { MacroExecutable copy = (MacroExecutable)super.clone(); if(this.executables != null) { copy.executables = new ArrayList(this.executables); } return copy; }// ---------------------------------------------- private Collection executables = null; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy