Package com.yahoo.jdisc.application
Class AbstractApplication
- java.lang.Object
-
- com.yahoo.jdisc.application.AbstractApplication
-
- All Implemented Interfaces:
Application
- Direct Known Subclasses:
AbstractClientApplication
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(); } }
- Author:
- Simon Thoresen Hult
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractApplication(BundleInstaller bundleInstaller, ContainerActivator activator, CurrentContainer container)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DeactivatedContainer
activateContainer(ContainerBuilder builder)
void
awaitTermination()
boolean
awaitTermination(int timeout, TimeUnit unit)
CurrentContainer
container()
void
destroy()
This method is called by theApplicationLoader
after first callingApplication.stop()
, and all previousDeactivatedContainer
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 theApplicationLoader
after the corresponding signal has been issued by the controlling start script.void
stopAndUninstallBundle(Iterable<org.osgi.framework.Bundle> bundles)
void
stopAndUninstallBundle(org.osgi.framework.Bundle... bundles)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.yahoo.jdisc.application.Application
start
-
-
-
-
Constructor Detail
-
AbstractApplication
@Inject protected AbstractApplication(BundleInstaller bundleInstaller, ContainerActivator activator, CurrentContainer container)
-
-
Method Detail
-
stop
public void stop()
Description copied from interface:Application
This method is called by theApplicationLoader
after the corresponding signal has been issued by the controlling start script. Once this method returns, all calls toContainerActivator.activateContainer(ContainerBuilder)
will throwApplicationNotReadyException
s. Use this method to prepare for termination (seeApplication.destroy()
).- Specified by:
stop
in interfaceApplication
-
destroy
public final void destroy()
Description copied from interface:Application
This method is called by theApplicationLoader
after first callingApplication.stop()
, and all previousDeactivatedContainer
s have terminated. Use this method to shut down all Application components such asClientProvider
s andServerProvider
s.- Specified by:
destroy
in interfaceApplication
-
installAndStartBundle
public final List<org.osgi.framework.Bundle> installAndStartBundle(String... locations) throws org.osgi.framework.BundleException
- Throws:
org.osgi.framework.BundleException
-
installAndStartBundle
public final List<org.osgi.framework.Bundle> installAndStartBundle(Iterable<String> locations) throws org.osgi.framework.BundleException
- Throws:
org.osgi.framework.BundleException
-
stopAndUninstallBundle
public final void stopAndUninstallBundle(org.osgi.framework.Bundle... bundles) throws org.osgi.framework.BundleException
- Throws:
org.osgi.framework.BundleException
-
stopAndUninstallBundle
public final void stopAndUninstallBundle(Iterable<org.osgi.framework.Bundle> bundles) throws org.osgi.framework.BundleException
- Throws:
org.osgi.framework.BundleException
-
newContainerBuilder
public final ContainerBuilder newContainerBuilder()
-
activateContainer
public final DeactivatedContainer activateContainer(ContainerBuilder builder)
-
container
public final CurrentContainer container()
-
isTerminated
public final boolean isTerminated()
-
awaitTermination
public final boolean awaitTermination(int timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
awaitTermination
public final void awaitTermination() throws InterruptedException
- Throws:
InterruptedException
-
-