Class ApplicationRunner


  • public abstract class ApplicationRunner
    extends Object
    Simple application runner which authorize to reload an application.
    Since:
    2.1
    Author:
    Tony Chemit - dev@tchemit.fr
    • Field Detail

      • args

        protected final String[] args
        arguments given to runner at launch time
      • runnable

        protected final Runnable runnable
        the runner to start application
      • reload

        protected boolean reload
        flag to reload the runner when closing it
      • initOnce

        protected boolean initOnce
        flag to know if application was init once.
      • startingTime

        protected long startingTime
      • mainThread

        protected Thread mainThread
    • Constructor Detail

      • ApplicationRunner

        protected ApplicationRunner​(String... args)
    • Method Detail

      • unlock

        public static void unlock()
      • launch

        public final void launch()
      • initOnce

        public void initOnce()
        To execute some code only once.

        This code will not be re-execute when reloading the runner.

      • onInit

        public void onInit()
                    throws Exception
        Hook to init runner.
        Throws:
        Exception - if any problem
      • onStart

        public void onStart()
                     throws Exception
        Hook to start runner.
        Throws:
        Exception - if any problem
      • onClose

        public void onClose​(boolean reload)
                     throws Exception
        Hook to close runner.
        Parameters:
        reload - if reload was asked
        Throws:
        Exception - if any problem
      • onShutdown

        public void onShutdown()
                        throws Exception
        Hook to shutdown launcher
        Throws:
        Exception - if any problem
      • onShutdown

        public void onShutdown​(Exception ex)
        Hook to shutdown launcher when an exception occurs on closing.
        Parameters:
        ex - the error catch while closing launcher
      • onError

        public void onError​(Exception e)
        Hook when an error occurs in runner.
        Parameters:
        e - the error catch
      • isReload

        public boolean isReload()
      • setReload

        public void setReload​(boolean reload)
      • getArgs

        public String[] getArgs()
      • close

        public final void close()