/*
* Copyright (C) 2009 by TunedIT. All rights reserved.
*
*/
package org.tunedit.core;
import java.io.IOException;
import java.io.InputStream;
import java.security.PrivilegedActionException;
import java.util.List;
import org.tunedit.core.exception.TunedTesterException;
/**
* Loader of resources from TunedIT Repository.
* Used by {@link #EvaluationProcedure EvaluationProcedures} to load the resources needed
* to set up a test.
* Typically, evaluation procedure does not use ResourceLoader directly,
* but instead constructs an instance of {@link #StandardLoader}
* which encapsulates the original ResourceLoader and extends it
* with more convenient methods for accessing resources.
* In such case, original ResourceLoader is used only to create a StandardLoader.
*
* @author Marcin Wojnarski
*
*/
public interface ResourceLoader {
/**
* Downloads the resource from TunedIT Repository, saves it as a file on local disk
* (in TunedTester cache folder), opens it for reading
* and returns a <code>java.io.InputStream</code> that can be used by client
* to read the contents of the file.
* <code>InputStream</code> enables low-level byte-wise access to data.
* If you need more high-level access, e.g. you expect a text file not a binary,
* you can easily convert this byte stream into character stream
* with <code>java.io.InputStreamReader</code> class.
*
* @param fileResource TunedIT resource name of the requested resource.
* Must represent a file resource.
* @return InputStream for reading the contents of the resource.
*/
public abstract InputStream open(ResourceName fileResource) throws TunedTesterException;
/**
* Downloads the resource from TunedIT Repository, saves it as a file on local disk
* (in TunedTester cache folder), runs it as an external process
* and returns a wrapper class providing a convenient interface
*
* @param fileResource TunedIT resource name of the requested resource.
* Must represent a file resource.
* @return String Path to the downloaded file
* @throws IOException
* @throws PrivilegedActionException
*/
public abstract ExternalProcess runProcess(ResourceName fileResource, List<String> args) throws TunedTesterException;
}