-
Notifications
You must be signed in to change notification settings - Fork 0
/
PluginApp.scala
66 lines (53 loc) · 1.24 KB
/
PluginApp.scala
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package io.simplifier.pluginapi
import io.simplifier.pluginapi.helper.PluginLogger
/**
* Abstract App Superclass for all Plugins.
* @author Christian Simon
*/
abstract class PluginApp(logfileBaseName: String) extends App with PluginLogger {
/*
* Plugin implementation
*/
val globalSettings: PluginGlobalSettings
val globals: PluginGlobals
val baseSlot: BaseProps
/*
* Startup / Shutdown
*/
/**
* Abstract def for custom init code.
*/
def init(): Unit = {}
/**
* Abstract def for custom shutdown.
*/
def shutdown(): Unit = {}
/**
* Plugin Startup.
*/
def startUpPlugin(): Unit = {
log.info("Startup Plugin ...")
globalSettings.initSettingsFromCommandline(args)
globals.init(baseSlot)
sys.addShutdownHook(pluginShutdown)
init()
}
/**
* Plugin Shutdown.
*/
def pluginShutdown(): Unit = {
log.info("Shutdown Plugin ...")
shutdown()
globals.shutdown
}
/**
* Run application (overwrite for admin calls)
*/
def runApp(): Unit = {
startUpPlugin()
}
// This sets the logfile basename, so it must be called before the first Logger is initialized!
PluginLogger.initializeClusterModeLoggingProperties(logfileBaseName)
// Run plugin ...
runApp()
}