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

nyla.solutions.commas.remote.RemoteCommandProcessor Maven / Gradle / Ivy

The newest version!
package nyla.solutions.commas.remote;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.concurrent.Callable;

import nyla.solutions.core.exception.CommunicationException;


/**
 * Generic runner to execute a RemoteCommand.
 * 
 * This is usage when using the Worker Thread for multi-cast calls
 * 
 * @author Gregory Green
 *
 * @param 
 * @param 
 */
public class RemoteCommandProcessor  implements Runnable, Callable
{
	/**
	 * 
	 * @param remoteCommand the remote command to execute
	 * @param input the input the pass to the remote command
	 */
	public RemoteCommandProcessor(RemoteCommand  remoteCommand,InputType input)
	{
		this.remoteCommand = remoteCommand;
		this.input = input;
	}// --------------------------------------------------------

	/**
	 * Execute the remote command
	 * @see java.lang.Runnable#run()
	 */
	@Override
	public void run()
	{
		try
		{
			this.results = call();
			
		}
		catch (RemoteException e)
		{
			throw new CommunicationException(e);
		}

	}// --------------------------------------------------------
	@Override
	public ReturnType call() throws RemoteException
	{
		// TODO Auto-generated method stub
		return this.remoteCommand.execute(input);
	}
	
	/**
	 * @return the results
	 */
	public ReturnType getResults()
	{
		return results;
	}



	private final RemoteCommand remoteCommand;
	private final InputType input;
	private ReturnType results;
	

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy