com.twitter.common.application
Class AppLauncher

java.lang.Object
  extended by com.twitter.common.application.AppLauncher

public final class AppLauncher
extends Object

An application launcher that sets up a framework for pluggable binding modules. This class should be called directly as the main class, with a command line argument -app_class which is the canonical class name of the application to execute. If your application uses command line arguments all Arg fields annotated with CmdLine will be discovered and command line arguments will be validated against this set, parsed and applied. A bootstrap module will be automatically applied (AppLauncherModule), which provides overridable default bindings for things like quit/abort hooks and a health check function. A LifecycleModule is also automatically applied to perform startup and shutdown actions.


Method Summary
static void launch(Class<? extends Application> appClass, Predicate<Field> argFilter, List<String> args)
          Used to launch an application with a restricted set of @CmdLine Args considered for parsing.
static void launch(Class<? extends Application> appClass, Predicate<Field> argFilter, String... args)
          A convenience for main wrappers.
static void launch(Class<? extends Application> appClass, String... args)
          A convenience for main wrappers.
static void main(String... args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(String... args)
                 throws IllegalAccessException,
                        InstantiationException
Throws:
IllegalAccessException
InstantiationException

launch

public static void launch(Class<? extends Application> appClass,
                          String... args)
A convenience for main wrappers. Equivalent to:
   AppLauncher.launch(appClass, ArgFilters.SELECT_ALL, Arrays.asList(args));
 

Parameters:
appClass - The application class to instantiate and launch.
args - The command line arguments to parse.
See Also:
ArgFilters

launch

public static void launch(Class<? extends Application> appClass,
                          Predicate<Field> argFilter,
                          String... args)
A convenience for main wrappers. Equivalent to:
   AppLauncher.launch(appClass, argFilter, Arrays.asList(args));
 

Parameters:
appClass - The application class to instantiate and launch.
argFilter - A filter that selects the @CmdLine Args to enable for parsing.
args - The command line arguments to parse.
See Also:
ArgFilters

launch

public static void launch(Class<? extends Application> appClass,
                          Predicate<Field> argFilter,
                          List<String> args)
Used to launch an application with a restricted set of @CmdLine Args considered for parsing. This is useful if the classpath includes annotated fields you do not wish arguments to be parsed for.

Parameters:
appClass - The application class to instantiate and launch.
argFilter - A filter that selects the @CmdLine Args to enable for parsing.
args - The command line arguments to parse.
See Also:
ArgFilters