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.
Constructor and Description |
---|
ClientDriver() |
Modifier and Type | Method and Description |
---|---|
private static List<com.google.inject.Module> |
newModuleList(Class<? extends ClientApplication> appClass,
com.google.inject.Module... guiceModules) |
private static List<com.google.inject.Module> |
newModuleList(ClientApplication appInstance,
com.google.inject.Module... guiceModules) |
private static OsgiFramework |
newNonWorkingOsgiFramework() |
private static com.yahoo.jdisc.core.FelixFramework |
newOsgiFramework(String cachePath) |
static void |
runApplication(Class<? extends ClientApplication> appClass,
com.google.inject.Module... guiceModules)
Creates and runs an instance of the given
ClientApplication class. |
static void |
runApplication(ClientApplication app,
com.google.inject.Module... guiceModules)
Creates and runs the given
ClientApplication . |
private static void |
runApplication(OsgiFramework osgi,
List<com.google.inject.Module> modules) |
static void |
runApplicationWithOsgi(String cachePath,
Class<? extends ClientApplication> appClass,
com.google.inject.Module... guiceModules)
Creates and runs an instance of the the given
ClientApplication class with OSGi support. |
public static void runApplication(ClientApplication app, com.google.inject.Module... guiceModules) throws Exception
Creates and runs the given ClientApplication
.
app
- The ClientApplication to inject.guiceModules
- The Guice Modules
to install prior to startup.Exception
- If an exception was thrown by the ClientApplication.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.
appClass
- The ClientApplication class to inject.guiceModules
- The Guice Modules
to install prior to startup.Exception
- If an exception was thrown by the ClientApplication.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.
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.Exception
- If an exception was thrown by the ClientApplication.private static OsgiFramework newNonWorkingOsgiFramework()
private static com.yahoo.jdisc.core.FelixFramework newOsgiFramework(String cachePath)
private static List<com.google.inject.Module> newModuleList(ClientApplication appInstance, com.google.inject.Module... guiceModules)
private static List<com.google.inject.Module> newModuleList(Class<? extends ClientApplication> appClass, com.google.inject.Module... guiceModules)
private static void runApplication(OsgiFramework osgi, List<com.google.inject.Module> modules) throws Exception
Exception
Copyright © 2017. All rights reserved.