Class ClientDriver


  • public abstract class ClientDriver
    extends java.lang.Object

    This class provides a unified way to set up and run a ClientApplication. It provides you with a programmable interface to instantiate and run the whole jDISC framework as if it was started as a Daemon, and it provides you with a thread in which to run your application logic. Once your return from the Runnable.run() method, the ClientProvider will initiate Application shutdown.

    A ClientApplication is typically a self-contained JAR file that bundles all of its dependencies, and contains a single "main" method. The typical implementation of that method is:

     public static void main(String[] args) throws Exception {
         ClientDriver.runApplication(MyApplication.class);
     }
     

    Alternatively, the ClientApplication can be created up front:

     public static void main(String[] args) throws Exception {
         MyApplication app = new MyApplication();
         (... configure app ...)
         ClientDriver.runApplication(app);
     }
     

    Because all of the dependencies of a ClientApplication is expected to be part of the application JAR, the OSGi framework created by this ClientDriver is disabled. Calling any method on that framework will throw an exception. If you need OSGi support, use either of the runApplicationWithOsgi() methods.

    Author:
    Simon Thoresen Hult
    • Constructor Detail

      • ClientDriver

        public ClientDriver()
    • Method Detail

      • runApplication

        public static void runApplication​(ClientApplication app,
                                          com.google.inject.Module... guiceModules)
                                   throws java.lang.Exception

        Creates and runs the given ClientApplication.

        Parameters:
        app - The ClientApplication to inject.
        guiceModules - The Guice Modules to install prior to startup.
        Throws:
        java.lang.Exception - If an exception was thrown by the ClientApplication.
      • runApplication

        public static void runApplication​(java.lang.Class<? extends ClientApplication> appClass,
                                          com.google.inject.Module... guiceModules)
                                   throws java.lang.Exception

        Creates and runs an instance of the given ClientApplication class.

        Parameters:
        appClass - The ClientApplication class to inject.
        guiceModules - The Guice Modules to install prior to startup.
        Throws:
        java.lang.Exception - If an exception was thrown by the ClientApplication.
      • runApplicationWithOsgi

        public static void runApplicationWithOsgi​(java.lang.String cachePath,
                                                  java.lang.Class<? extends ClientApplication> appClass,
                                                  com.google.inject.Module... guiceModules)
                                           throws java.lang.Exception

        Creates and runs an instance of the the given ClientApplication class with OSGi support.

        Parameters:
        cachePath - The path to use for the OSGi bundle cache.
        appClass - The ClientApplication class to inject.
        guiceModules - The Guice Modules to install prior to startup.
        Throws:
        java.lang.Exception - If an exception was thrown by the ClientApplication.