package com.csc.library.session;

import java.lang.reflect.Method;

import javax.naming.Context;

import com.csc.library.utilities.MyLog;

/**
 * @author Architecture
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class InitialEntryProcess {
	private Context ctx = null;
	private Object entryProcess = null;
	private Object home;

	public InitialEntryProcess() {
	
	}

	public Object getEntry(String entryName) {
		try {
			entryProcess = this.invokeRemote(entryName);
		} catch (Exception e) {
			MyLog.error(this, e);
		}
		return this.entryProcess;
	}

	private Object invokeRemote(String entryName) throws Exception {
		ctx = new MyContext().getInitialContext();
		//home = ctx.lookup(entryName);
		home = ctx.lookup("ejb/entryprocess/" + entryName);
		Class c = home.getClass();
		Method mx = c.getDeclaredMethod("create", new Class[] {});
		return mx.invoke(home, new Object[] {});
	}
}