FileDocCategorySizeDatePackage
DownloadFileSource.javaAPI DocGlassfish v2 API3841Fri May 04 22:23:28 BST 2007com.sun.enterprise.management.deploy

DownloadFileSource

public final class DownloadFileSource extends Object
This class is responsible for generating a File for downloading, given a moduleID and filename within that module. The file may be pre-existing, in which case isTempFile() should return false, or it may be a generated temporary file, in which case isTempFile() should return true. If isTempFile() returns true, the caller will delete the file at some point.

Fields Summary
private final String
mModuleID
private final String
mFilename
Constructors Summary
public DownloadFileSource(String moduleID, String filename)

		mModuleID	= moduleID;
		mFilename	= filename;
	
Methods Summary
private java.io.FilecreateDownloadFile(java.lang.String moduleID, java.lang.String filename)
This implementation is for testing; the real one needs to find or produce a file corresponding to the requested module and filename.

		final String	name	= "./" + moduleID + "_" + filename + System.currentTimeMillis();
		
		final File theFile	= new File( name );
		theFile.createNewFile();
		
		final FileOutputStream	out	= new FileOutputStream( theFile );
		
		final byte[]	temp	= new byte[ 1024 * 1024 ];
		
		long	remaining	= temp.length * 10;
		while ( remaining != 0 )
		{
			out.write( temp );
			assert( remaining >= temp.length );
			remaining	-= temp.length;
		}
		
		out.close();
		
		return( theFile );
	
public java.io.FilegetDownloadFile()

		return( createDownloadFile( mModuleID, mFilename ) );
	
public booleanisTempFile()

		return( true );