Package com.yahoo.jdisc.application
Class AbstractApplication
java.lang.Object
com.yahoo.jdisc.application.AbstractApplication
- All Implemented Interfaces:
Application
- Direct Known Subclasses:
AbstractClientApplication
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
ModifierConstructorDescriptionprotected
AbstractApplication
(BundleInstaller bundleInstaller, ContainerActivator activator, CurrentContainer container) -
Method Summary
Modifier and TypeMethodDescriptionfinal DeactivatedContainer
activateContainer
(ContainerBuilder builder) final void
final boolean
awaitTermination
(int timeout, TimeUnit unit) final CurrentContainer
final void
destroy()
This method is called by theApplicationLoader
after first callingApplication.stop()
, and all previousDeactivatedContainer
s have terminated.final List<org.osgi.framework.Bundle>
installAndStartBundle
(Iterable<String> locations) final List<org.osgi.framework.Bundle>
installAndStartBundle
(String... locations) final boolean
final ContainerBuilder
void
stop()
This method is called by theApplicationLoader
after the corresponding signal has been issued by the controlling start script.final void
stopAndUninstallBundle
(Iterable<org.osgi.framework.Bundle> bundles) final 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 Details
-
AbstractApplication
@Inject protected AbstractApplication(BundleInstaller bundleInstaller, ContainerActivator activator, CurrentContainer container)
-
-
Method Details
-
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
-
activateContainer
-
container
-
isTerminated
public final boolean isTerminated() -
awaitTermination
- Throws:
InterruptedException
-
awaitTermination
- Throws:
InterruptedException
-