Reference Guide

Table Of Contents
private static final String APP_DEBIAN_FILE = "debinst-sample_1.0_amd64.deb";
. . .
private void installDebian() throws IOException {
File unzipDir = appService.getAppUnzipDir(APP_ID, APP_VERSION);
File deb = new File(unzipDir, APP_DEBIAN_FILE);
. . .
Programming Your Application to Install a
Debian Package on the Controller
Determining when to install the Debian Package
The application will need to determine its state at start up to know when it should install its debian
packages. When the application is first installed, the state of the application will be INSTALLING.
Subsequent normal restarts (such as a restart of the controller) of the application will present a
state of ACTIVE. If an application has been disabledand is then subsequently enabled by the user
the state of ENABLING will be presented. If an application is upgrading, the first start of the
upgraded application will present a state of UPGRADING. Any other state at start of the
application indicates some sort of error condition which an application might or might not be able
to handle. An application must be able to handle each state. For example, if you program the
application to remove the debian package when a user disables the application, you must also
program the application to reinstall the debian package when the application is enabled. When
the application is started normally (the ACTIVE state), the application should not attempt to install
the application, but should decide if there is work it needs to do to determine that the debian
package is still installed / running.
An application uses its state to determine when to install a debian package. To install a debian
package, the application must be in either the INSTALLING state or the ENABLING state. If an
application is in an state other than INSTALLING or ENABLING, the application cannot install the
debian package.
The AppService is used to determine the current state of the application. The application
component that manages the external debian package must obtain a reference to the AppService.
You can obtain a reference to the AppService using annotations and Declarative Services, or by
using any other OSGi method. After the AppService is obtained and the current state of the
application is determined, the application can use this information to determine whether or not to
install the debian package.
The application must handle the states listed in the following switch statement code example:
// for application management
@Reference(policy = ReferencePolicy.DYNAMIC,
cardinality = ReferenceCardinality.MANDATORY_UNARY)
private volatile AppService appService;
131