@@ -0,0 +1,1916 @@
+package com.github.sbugat.ec2tools.launcher;%0A%0Aimport java.lang.reflect.InvocationTargetException;%0Aimport java.lang.reflect.Method;%0A%0Aimport org.slf4j.ext.XLogger;%0Aimport org.slf4j.ext.XLoggerFactory;%0A%0Aimport com.github.sbugat.ec2tools.EC2StartStopMain;%0Aimport com.google.inject.Guice;%0Aimport com.google.inject.Injector;%0A%0Apublic class MainLauncher %7B%0A%0A%09/** SLF4J XLogger. */%0A%09private static final XLogger log = XLoggerFactory.getXLogger(EC2StartStopMain.class);%0A%0A%09private static final String MAIN_METHOD_NAME = %22main%22;%0A%0A%09public static void launcher(@SuppressWarnings(%22rawtypes%22) final Class classToLaunch, final String args%5B%5D) throws Exception %7B%0A%0A%09%09log.entry(classToLaunch, args);%0A%0A%09%09final Injector injector = Guice.createInjector();%0A%09%09@SuppressWarnings(%22unchecked%22)%0A%09%09final Object classInstance = injector.getInstance(classToLaunch);%0A%09%09for (final Method method : classToLaunch.getDeclaredMethods()) %7B%0A%0A%09%09%09if (MAIN_METHOD_NAME.equals(method.getName())) %7B%0A%0A%09%09%09%09try %7B%0A%09%09%09%09%09method.invoke(classInstance, (Object) args);%0A%09%09%09%09%09return;%0A%09%09%09%09%7D%0A%09%09%09%09catch (final IllegalAccessException e) %7B%0A%09%09%09%09%09log.error(%22Cannot call method %7B%7D in the class %7B%7D%22, MAIN_METHOD_NAME, classToLaunch, e);%0A%09%09%09%09%09log.exit(e);%0A%09%09%09%09%09throw e;%0A%09%09%09%09%7D%0A%09%09%09%09catch (final IllegalArgumentException e) %7B%0A%09%09%09%09%09log.error(%22Cannot call method %7B%7D in the class %7B%7D%22, MAIN_METHOD_NAME, classToLaunch, e);%0A%09%09%09%09%09log.exit(e);%0A%09%09%09%09%09throw e;%0A%09%09%09%09%7D%0A%09%09%09%09catch (final InvocationTargetException e) %7B%0A%09%09%09%09%09log.error(%22Cannot call method %7B%7D in the class %7B%7D%22, MAIN_METHOD_NAME, classToLaunch, e);%0A%09%09%09%09%09log.exit(e);%0A%09%09%09%09%09throw e;%0A%09%09%09%09%7D%0A%09%09%09%09catch (final Exception e) %7B%0A%09%09%09%09%09log.error(%22Execution error in method %7B%7D of the class %7B%7D%22, MAIN_METHOD_NAME, classToLaunch, e);%0A%09%09%09%09%09log.exit(e);%0A%09%09%09%09%09throw e;%0A%09%09%09%09%7D%0A%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09final NoSuchMethodException noSuchMethodException = new NoSuchMethodException(MAIN_METHOD_NAME);%0A%09%09log.exit(noSuchMethodException);%0A%09%09throw noSuchMethodException;%0A%09%7D%0A%7D%0A

Add main launcher