Class ClientDriver

java.lang.Object
com.yahoo.jdisc.client.ClientDriver

public abstract class ClientDriver extends 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 Details

    • ClientDriver

      public ClientDriver()
  • Method Details

    • runApplication

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

      Creates and runs the given ClientApplication.

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

      public static void runApplication(Class<? extends ClientApplication> appClass, com.google.inject.Module... guiceModules) throws 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:
      Exception - If an exception was thrown by the ClientApplication.
    • runApplicationWithOsgi

      public static void runApplicationWithOsgi(String cachePath, Class<? extends ClientApplication> appClass, com.google.inject.Module... guiceModules) throws 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:
      Exception - If an exception was thrown by the ClientApplication.