import java.util.Properties;
import javax.naming.*;
import javax.ejb.*;
import java.rmi.*;
import java.sql.SQLException;

/**
 * This package is EJB-part of project.
 *
 * It must contain the following:
 * @Class %Home_interface%.java
 * @Class %Remote_interface%.java
 */

public class %Name%Client {

    private %Home_interface% home;

    public %Name%Client() throws NamingException{

	home = lookupHome();
    }

    public static void main(String[] argv) {

	%Name%Client client = null;
	
	try {
	
	  client = new %Name%Client();

	} catch(NamingException ne) {
	  ne.printStackTrace();
	}

	try {

	  client.body();

        } catch(Exception e) {
	      e.printStackTrace();
	}
    }

    public void body() throws CreateException, RemoteException, RemoveException, SQLException {
          %Remote_interface% ejb = home.create();

	     //Place your code here

          ejb.remove();
    }

    private %Home_interface% lookupHome() throws NamingException {
	
	Context ctx = getInitialContext();
	%Home_interface% home = null;

	try {

	  Object homeObj = ctx.lookup("%JNDI_Name%");
	  home = (%Home_interface%) narrow(homeObj, %Home_interface%.class);

	} catch (NamingException e) {
		e.printStackTrace();
	}
	return home;
    }

    private Object narrow(Object obj, Class c) {
	return javax.rmi.PortableRemoteObject.narrow(obj, c);	
    }

    private Context getInitialContext() throws NamingException {

	Context ctx = null;
	try {

          Properties props = System.getProperties();
          props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
          props.put(Context.PROVIDER_URL, "%url%");

	  ctx = new InitialContext(props);

	} catch (NamingException e) {
		e.printStackTrace();
	}
	return ctx;
    }

}
