From version 1.1
edited by David Nestle
on 2019/03/01 19:38
To version 2.1
edited by David Nestle
on 2019/03/02 10:36
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,1 +1,41 @@
1 -TODO
1 += Introduction =
2 +
3 +Besides GUI implementations via the OGEMA widget framework console commands are another standard way for administration access to applications. For systems with a weak communication / internet connection or other restrictions regarding web GUI access console commands are the core tool for administration.
4 +
5 += Console Access Implementation =
6 +
7 +There are two usual ways to implement console commands. The first and simpler options provides a class that declares to register the required service via annotations. This requires a constructor without arguments - references to the application accessed via console usually have to be provided via static variables if not available as OSGi service itself. The second and more flexible/recommended way is to register the service explicitly. This needs some more support from the app providing the console access.
8 +
9 +Example for simple service definition:
10 +
11 +{{code language="java"}}
12 +@Component(specVersion = "1.2")
13 +@Properties( {
14 + @Property(name = "osgi.command.scope", value = "logtransfer"),
15 + @Property(name = "osgi.command.function", value = { "sendlogs", "setlastupdatetime" })
16 +})
17 +@Service(ShellCommandsLTS.class)
18 +@Descriptor("Log transfer commands")
19 +public class ShellCommandsLTS {
20 +
21 + public static SPLogTransfer app;
22 +
23 + @Descriptor("send new log data now (for testing purposes, blocks while searching for files)")
24 + public void sendlogs() throws IOException {
25 + app.logTransfer.transferNewLogs();
26 + }
27 +
28 + @Descriptor("set the last update time for all series")
29 + public void setlastupdatetime(@Descriptor("full ISO8601 format") String iso8601datetime) {
30 + ZonedDateTime time = ZonedDateTime.parse(iso8601datetime);
31 + app.logTransfer.getLogs().forEach(s -> s.setLastTransferTime(time.toInstant().toEpochMilli()));
32 + }
33 +}
34 +
35 +{{/code}}
36 +
37 +Example for recommended implementation:
38 +
39 +See [[activate-logmodus/ShellCommandsLTS>>https://github.com/ogema/ogema-widgets-extended/blob/master/src/activate-log-modus/src/main/java/org/ogema/tools/app/logtransfercontrol/ShellCommandsLTS.java]] .
40 +
41 +