LISTING 2

/** Created on May 24, 2005**/
package com.ibm.websphere.sample
import com.ibm.websphere.command.CacheableCommandImpl;

/** @author Pooja Gupta**/

import java.util.*;
import com.ibm.websphere.command.CacheableCommandImpl;

public class SampleCacheCommand extends CacheableCommandImpl {

	private String fileName = null;
	private String xmlResults=null;

	public SampleCacheCommand () { }   //empty constructor
	//one argument constructor
	public SampleCacheCommand  (String fileName) {
		this();
		this.fileName = fileName;
		}
	/**
	 * @see com.ibm.websphere.command.Command#isReadyToCallExecute()
	*/
	public boolean isReadyToCallExecute() {
		return fileName != null;
	}

	/**
	 * @see com.ibm.websphere.command.TargetableCommand#performExecute()
	 */
	public void performExecute() throws Exception
	{
		System.out.println("In the perform Execute of SampleCacheCommnad");
		//Reading of the file
		try
		{
		System.out.println("In the try loop of Cache Command");
		xmlResults=readfileclass.readFile(getFilename(),"");   // I am calling a function
		 to call readFile from the calss readfileclass to read in an XML file, you can
		  customize this according to your needs...whatever needs to be cached goes in here
		System.out.println("the results are "+xmlResults);
		}
		catch(Exception e)
		{System.out.println("The value of exception " +e);}	}
	//set a setter for the XMLResults variable
	public void setXmlresult(String xmlResults) {
		this.xmlResults = xmlResults;
	}
		//set a getter for the XMLResults variable
	public String getXmlresult() {
		return this.xmlResults;
	}
	//setter for the filename that needs to be read
	public void setFilename(String fileName) {
		this. fileName =  fileName;
	}

	//getter for the filename that needs to be read
	public String getFilename() {
		return this.fileName;
	}
}//end of class