aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/main/java/com/yahoo/jdisc/application/Application.java
blob: 04dbe3fc1e168885bd19b1013df0d0ae55e6a851 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.application;

import com.yahoo.jdisc.Container;
import com.yahoo.jdisc.core.ApplicationLoader;
import com.yahoo.jdisc.service.ClientProvider;
import com.yahoo.jdisc.service.ServerProvider;

/**
 * This interface defines the API of the singleton Application that runs in a jDISC instance. An Application instance
 * will always have its {@link #destroy()} method called, regardless of whether {@link #start()} or {@link #stop()}
 * threw any exceptions.
 *
 * @author Simon Thoresen Hult
 */
public interface Application {

    /**
     * This method is called by the {@link ApplicationLoader} just after creating this Application instance. Use this
     * method to start the Application's worker thread, and to activate a {@link Container}. If you attempt to call
     * {@link ContainerActivator#activateContainer(ContainerBuilder)} before this method is invoked, that call will
     * throw an {@link ApplicationNotReadyException}. If this method does not throw an exception, the {@link #stop()}
     * method will be called at some time in the future.
     */
    void start();

    /**
     * This method is called by the {@link ApplicationLoader} after the corresponding signal has been issued by the
     * controlling start script. Once this method returns, all calls to {@link
     * ContainerActivator#activateContainer(ContainerBuilder)} will throw {@link ApplicationNotReadyException}s. Use
     * this method to prepare for termination (see {@link #destroy()}).
     */
    void stop();

    /**
     * This method is called by the {@link ApplicationLoader} after first calling {@link #stop()}, and all previous
     * {@link DeactivatedContainer}s have terminated. Use this method to shut down all Application components such as
     * {@link ClientProvider}s and {@link ServerProvider}s.
     */
    void destroy();

}