File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
server/src/main/java/net/laprun/sustainability/power Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ public class PowerMeasurer {
2121 @ Inject
2222 PowerSensor sensor ;
2323
24+ @ Inject
25+ Persistence persistence ;
26+
2427 @ ConfigProperty (name = "net.laprun.sustainability.power.sampling-period" , defaultValue = DEFAULT_SAMPLING_PERIOD )
2528 Duration samplingPeriod ;
2629
@@ -32,7 +35,7 @@ public Multi<SensorMeasure> stream(String pid) throws Exception {
3235 }
3336
3437 public void startTrackingApp (String appName , String pid ) throws Exception {
35- stream (pid ).subscribe ().with (m -> Persistence .save (m , appName ));
38+ stream (pid ).subscribe ().with (m -> persistence .save (m , appName ));
3639 }
3740
3841 private RegisteredPID track (String pid ) throws Exception {
Original file line number Diff line number Diff line change 11package net .laprun .sustainability .power .persistence ;
22
3+ import jakarta .enterprise .context .ApplicationScoped ;
34import jakarta .transaction .Transactional ;
45
56import net .laprun .sustainability .power .SensorMeasure ;
67
7- public enum Persistence {
8- ;
8+ @ ApplicationScoped
9+ public class Persistence {
910
1011 @ Transactional
11- public static Measure save (SensorMeasure measure , String appName ) {
12+ public Measure save (SensorMeasure measure , String appName ) {
1213 final var persisted = new Measure ();
1314 persisted .components = measure .components ();
1415 persisted .appName = appName ;
You can’t perform that action at this time.
0 commit comments