Satellite :: Plugins

Satellite toolkit provides an homogeneous invocation mechanism for Windows and Unix background process

License

License

MIT
GroupId

GroupId

io.zatarox.satellite
ArtifactId

ArtifactId

satellite-plugin-parent
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

pom
Description

Description

Satellite :: Plugins
Satellite toolkit provides an homogeneous invocation mechanism for Windows and Unix background process

Download satellite-plugin-parent

How to add to project

<!-- https://jarcasting.com/artifacts/io.zatarox.satellite/satellite-plugin-parent/ -->
<dependency>
    <groupId>io.zatarox.satellite</groupId>
    <artifactId>satellite-plugin-parent</artifactId>
    <version>1.0.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/io.zatarox.satellite/satellite-plugin-parent/
implementation 'io.zatarox.satellite:satellite-plugin-parent:1.0.0'
// https://jarcasting.com/artifacts/io.zatarox.satellite/satellite-plugin-parent/
implementation ("io.zatarox.satellite:satellite-plugin-parent:1.0.0")
'io.zatarox.satellite:satellite-plugin-parent:pom:1.0.0'
<dependency org="io.zatarox.satellite" name="satellite-plugin-parent" rev="1.0.0">
  <artifact name="satellite-plugin-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='io.zatarox.satellite', module='satellite-plugin-parent', version='1.0.0')
)
libraryDependencies += "io.zatarox.satellite" % "satellite-plugin-parent" % "1.0.0"
[io.zatarox.satellite/satellite-plugin-parent "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.apache.maven : maven-core jar 3.3.9
org.apache.maven : maven-compat jar 3.3.9

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5

test (4)

Group / Artifact Type Version
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
junit : junit jar 4.12
org.powermock : powermock-api-mockito jar 1.6.6
org.powermock : powermock-module-junit4 jar 1.6.6

Project Modules

  • dumper
  • runner

Satellite Toolkit

Satellite is a set of utilities and Java support classes for running Java applications as server processes. Commonly known as 'daemon' processes in Unix terminology, on Windows they are called 'services'.

Build Status Coverage Status Maven Central

Requirements

Compilation process is performed under Linux. Cross-compilation fanboy :-)

  • Gradle 4.4.x
  • Java Development Kit >= 7
  • Clang 5.x
  • mingw-w64-x86-64-dev (gcc 5.x)
  • libc6-dev-i386

Satellite in action

Writing an independent OS background process become pretty simple. The first step is to implement a java interface who manage background process behaviors. The second step require Phobos or Deimos depending if you are under Windows or Linux. The Daemon behavior has been designed as the same manner as Windows service. Under Windows, only certain service state transitions are valid. The following diagram shows the valid transitions (credits to Microsoft) :

Dependency

In your project, add the Satellite API dependency (Maven POM):

<dependency>
    <groupId>io.zatarox.satellite</groupId>
    <artifactId>satellite-api</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <scope>provided</scope>
</dependency>

Core of the background process

This is the facade of your service. Attention : calls on these methods are synchronous.

import io.zatarox.satellite.*;

public final class FooBackgroundProcess implements BackgroundProcess {

    @Override
    public void initialize(BackgroundContext dc) throws BackgroundException, Exception {
        System.err.println("Initialized");
    }

    @Override
    public void resume() throws Exception {
        System.err.println("Started...");
    }

    @Override
    public void pause() throws Exception {
        System.err.println("Stopped !");
    }

    @Override
    public void shutdown() {
        System.err.println("Destroyed");
    }
}

Main jar assembly

Finally, add a manifest entry in your main jar (and dependency jars OFC).

<plugin>
  <artifactId>maven-jar-plugin</artifactId>
    <version>3.0.2</version>
        <configuration>
        <archive>
            <index>true</index>
            <manifestEntries>
                <Background-Process-Class>io.zatarox.satellite.FooBackgroundProcess</Background-Process-Class>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

Sample

To a look to the sample project submodule to see how to get binary frontends from Gradle

Inspiration

This project is based on Apache Commons Daemon.

Versions

Version
1.0.0