package com.csc.library.session;

import java.lang.reflect.Method;

import javax.naming.Context;
import javax.naming.NamingException;

import com.csc.library.process.DbReport;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.UProfile;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

public class InitialReport {

	private Context ctx = null;
	private String REPORT_NAME = "";
	private DbReport pc = null;
	private Object home = null;
	//transient private Logger logger = Logger.getLogger(InitialReport.class);
	private UProfile up=null;
	public InitialReport() {}
	public InitialReport(UProfile u) {
		this.up=u;
	}
	public DbReport getProcess() {
		try {
			this.getInitialContext();
			pc = (DbReport) this.invokeRemote();
			pc.setUProfile(this.up);
		} catch (Exception e) {
			MyLog.error(this, this.up, e);
		}
		return this.pc;
	}

	private void getInitialContext() throws NamingException {
		ctx = new MyContext().getInitialContext();
		home = ctx.lookup("ejb/process/ReportProcess");
	}

	private Object invokeRemote() throws Exception {
		Class c = home.getClass();
		Method mx = c.getDeclaredMethod("create", new Class[] {});
		return mx.invoke(home, new Object[] {});
	}
}