nyla.solutions.global.patterns.command.MacroExecutable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nyla.solutions.global Show documentation
Show all versions of nyla.solutions.global Show documentation
Nyla Solutions Global Java API provides support for basic application
utilities (application configuration, data encryption, debugger and text
processing).
The newest version!
package nyla.solutions.global.patterns.command;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import nyla.solutions.global.exception.RequiredException;
import nyla.solutions.global.patterns.command.Environment;
import nyla.solutions.global.patterns.command.Executable;
import nyla.solutions.global.patterns.command.MacroExecutable;
/**
*
* 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;
}