public abstract class AbstractApplication extends Object implements Application
This class is a convenient parent class for Application
developers that require simple access to the most
commonly used jDISC APIs.
A simple hello world application could be implemented like this:
class HelloApplication extends AbstractApplication { @Inject public HelloApplication(BundleInstaller bundleInstaller, ContainerActivator activator, CurrentContainer container) { super(bundleInstaller, activator, container); } @Override public void start() { ContainerBuilder builder = newContainerBuilder(); ServerProvider myServer = new MyHttpServer(); builder.serverProviders().install(myServer); builder.serverBindings().bind("http://*/*", new MyHelloWorldHandler()); activateContainer(builder); myServer.start(); myServer.release(); } }
Modifier and Type | Field and Description |
---|---|
private ContainerActivator |
activator |
private BundleInstaller |
bundleInstaller |
private CurrentContainer |
container |
private CountDownLatch |
destroyed |
Modifier | Constructor and Description |
---|---|
protected |
AbstractApplication(BundleInstaller bundleInstaller,
ContainerActivator activator,
CurrentContainer container) |
Modifier and Type | Method and Description |
---|---|
DeactivatedContainer |
activateContainer(ContainerBuilder builder) |
void |
awaitTermination() |
boolean |
awaitTermination(int timeout,
TimeUnit unit) |
CurrentContainer |
container() |
void |
destroy()
This method is called by the
ApplicationLoader after first calling Application.stop() , and all previous
DeactivatedContainer s have terminated. |
List<org.osgi.framework.Bundle> |
installAndStartBundle(Iterable<String> locations) |
List<org.osgi.framework.Bundle> |
installAndStartBundle(String... locations) |
boolean |
isTerminated() |
ContainerBuilder |
newContainerBuilder() |
void |
stop()
This method is called by the
ApplicationLoader after the corresponding signal has been issued by the
controlling start script. |
void |
stopAndUninstallBundle(org.osgi.framework.Bundle... bundles) |
void |
stopAndUninstallBundle(Iterable<org.osgi.framework.Bundle> bundles) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
start
private final CountDownLatch destroyed
private final BundleInstaller bundleInstaller
private final ContainerActivator activator
private final CurrentContainer container
@Inject protected AbstractApplication(BundleInstaller bundleInstaller, ContainerActivator activator, CurrentContainer container)
public void stop()
Application
This method is called by the ApplicationLoader
after the corresponding signal has been issued by the
controlling start script. Once this method returns, all calls to ContainerActivator.activateContainer(ContainerBuilder)
will throw ApplicationNotReadyException
s. Use
this method to prepare for termination (see Application.destroy()
).
stop
in interface Application
public final void destroy()
Application
This method is called by the ApplicationLoader
after first calling Application.stop()
, and all previous
DeactivatedContainer
s have terminated. Use this method to shut down all Application components such as
ClientProvider
s and ServerProvider
s.
destroy
in interface Application
public final List<org.osgi.framework.Bundle> installAndStartBundle(String... locations) throws org.osgi.framework.BundleException
org.osgi.framework.BundleException
public final List<org.osgi.framework.Bundle> installAndStartBundle(Iterable<String> locations) throws org.osgi.framework.BundleException
org.osgi.framework.BundleException
public final void stopAndUninstallBundle(org.osgi.framework.Bundle... bundles) throws org.osgi.framework.BundleException
org.osgi.framework.BundleException
public final void stopAndUninstallBundle(Iterable<org.osgi.framework.Bundle> bundles) throws org.osgi.framework.BundleException
org.osgi.framework.BundleException
public final ContainerBuilder newContainerBuilder()
public final DeactivatedContainer activateContainer(ContainerBuilder builder)
public final CurrentContainer container()
public final boolean isTerminated()
public final boolean awaitTermination(int timeout, TimeUnit unit) throws InterruptedException
InterruptedException
public final void awaitTermination() throws InterruptedException
InterruptedException
Copyright © 2017. All rights reserved.