package commons.application;
import basics.application.Args;
import basics.application.Binder;
import basics.application.Config;
import commons.utl.CtxUtl;
/**
 * Generic starter for a console application. Uses conf/cmd.properties and program args for
 * configuration.
 * @author ks
 */
public class Launcher
{

public static final String SEPARATOR_CMD = " ";

public static void main (String[] _args) throws Exception
{
   Application.createNewContext();
   CtxUtl.addPropertiesToEnv(Application.ctx(), new Config(GLOBAL.KEY_CONFIG_APPLICATION).getProperties());
   String starter = Application.ctx().env().get(GLOBAL.KEY_CONFIG_STARTABLE, commons.application.MockApp.class.getName());
   Args prgArgs = new Args(_args);
   Binder.register(prgArgs.getOption(GLOBAL.KEY_CONFIG_STARTABLE, starter));
   Startable startable = (Startable) Binder.createNew(Startable.class);
   startable.setup(prgArgs);
   startable.start();
}
}
