/*
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 Bull S.A.
 * Contact: jonas-team@objectweb.org
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id: 
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.jtests.clients.init;


import javax.rmi.PortableRemoteObject;
import javax.naming.InitialContext;
import javax.naming.Context;
import org.objectweb.jonas.jtests.ftables.DBEnvHome;
import org.objectweb.jonas.jtests.ftables.DBEnv;
/**
 */
public class I_tables {  


 public static void main(String args[]) { 
 
	Context initialContext = null;
	try {
	    initialContext = new InitialContext();
	} catch (Exception e) {
	    System.err.println("Cannot get initial context for JNDI: " + e);
	    System.exit(2);
	}
   
 	// Connecting to DBEnvHome thru JNDI
	DBEnvHome home = null;
	try {
	    home = (DBEnvHome)PortableRemoteObject.narrow(initialContext.lookup("ftablesDBEnvHome"), DBEnvHome.class);
	} catch (Exception e) {
 	    System.err.println( "Cannot lookup DBEnvHome: " + e);
	    System.exit(2);
	}
	// tables Bean creation
	DBEnv t1 = null;
	try {
	    System.out.println("Create a bean tables");
	    t1 = home.create();
	} catch (Exception e) {
	    System.err.println("Cannot create tables Bean: " + e);
	    System.exit(2);
	}

    // Get args
	for (int argn = 0; argn < args.length; argn++) {
	    String filename = args[argn];
        // init tables
        try {
            t1.initTable(filename);
       
         } catch (Exception e) {
           System.err.println("Cannot create tables Bean: " + e);
           System.exit(2);

        }

}
}
}
