diff --git a/run.sh b/run.sh index 02280a6..8678a0d 100755 --- a/run.sh +++ b/run.sh @@ -12,6 +12,7 @@ fi CLASSPATH=$(IFS=:; echo "${jars[*]}") exec java \ + --enable-native-access=javafx.graphics \ --enable-preview \ -Dlog4j.configurationFile=conf/log4j2.xml \ -cp "$CLASSPATH" \ diff --git a/src/main/tjava/com/r35157/evelyn/emc/EvelynMissionControl.tjava b/src/main/tjava/com/r35157/evelyn/emc/EvelynMissionControl.tjava new file mode 100644 index 0000000..e91333e --- /dev/null +++ b/src/main/tjava/com/r35157/evelyn/emc/EvelynMissionControl.tjava @@ -0,0 +1,5 @@ +package com.r35157.evelyn.emc; + +public interface EvelynMissionControl { + void start(); +} diff --git a/src/main/tjava/com/r35157/evelyn/emc/impl/ref/EvelynMissionControlImpl.tjava b/src/main/tjava/com/r35157/evelyn/emc/impl/ref/EvelynMissionControlImpl.tjava new file mode 100644 index 0000000..a0af80d --- /dev/null +++ b/src/main/tjava/com/r35157/evelyn/emc/impl/ref/EvelynMissionControlImpl.tjava @@ -0,0 +1,36 @@ +package com.r35157.evelyn.emc.impl.ref; + +import com.r35157.evelyn.emc.EvelynMissionControl; +import javafx.application.Platform; +import javafx.scene.Scene; +import javafx.scene.control.TextArea; +import javafx.stage.Stage; + +import java.util.Objects; + +public final class EvelynMissionControlImpl/**/ implements EvelynMissionControl { + + public EvelynMissionControlImpl(/*T evelyn*/) { + //this.evelyn = Objects.requireNonNull(evelyn); + } + + @Override + public void start() { + Platform.startup(() -> { + TextArea text = new TextArea(""" + Evelyn Mission Control + + Evelyn is running. + Connected to: %s + """.formatted("Test123"/*evelyn.getClass().getName())*/)); + text.setEditable(false); + + Stage window = new Stage(); + window.setTitle("Evelyn Mission Control"); + window.setScene(new Scene(text, 600, 400)); + window.show(); + }); + } + + //private final T evelyn; +} diff --git a/src/main/tjava/com/r35157/nenjim/hubd/NenjimHub.tjava b/src/main/tjava/com/r35157/nenjim/hubd/NenjimHub.tjava index 8ff0ec8..bab6555 100644 --- a/src/main/tjava/com/r35157/nenjim/hubd/NenjimHub.tjava +++ b/src/main/tjava/com/r35157/nenjim/hubd/NenjimHub.tjava @@ -7,6 +7,11 @@ import org.jetbrains.annotations.NotNull; import java.util.HashMap; public interface NenjimHub { + /** + * Start the NenjimHub - This is the first thing to do + */ + void start() throws Exception; + /** * Starts a process based on the provided fully qualified interface name. * The actual implementation that is run is binded according to the Context. diff --git a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava index c4acd1a..be45ddd 100644 --- a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava +++ b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/Main.tjava @@ -25,7 +25,8 @@ public class Main { // TODO: Consider if we really need a Main class or we just need to move the main method to NenjimHubImpl? static void main(String[] args) throws Exception { - NenjimHubImpl nenjimHub = new NenjimHubImpl(); + NenjimHub nenjimHub = new NenjimHubImpl(); + nenjimHub.start(); /*SolanaBlockChain sbc = new SolanaBlockChainImpl(); JupiterPerpsService jupiter = new AnchorIdlJupiterPerpsServiceImpl(sbc); @@ -39,7 +40,6 @@ public class Main { ΩUSDCAmountΩ a = pos.borrowFeesDue(); }*/ //int i = 0; - nenjimHub.awaitShutdown(); /* try { log.info("Auto-starting 2 Nenjim application(s)..."); diff --git a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava index 199b649..8498731 100644 --- a/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava +++ b/src/main/tjava/com/r35157/nenjim/hubd/impl/ref/NenjimHubImpl.tjava @@ -1,5 +1,7 @@ package com.r35157.nenjim.hubd.impl.ref; +import com.r35157.evelyn.emc.EvelynMissionControl; +import com.r35157.evelyn.emc.impl.ref.EvelynMissionControlImpl; import com.r35157.jupiterperpsalarm.impl.ref.JupiterPerpsAlarmImpl; import com.r35157.nenjim.hubd.NenjimHub; import com.r35157.nenjim.hubd.journal.Journal; @@ -17,13 +19,16 @@ public class NenjimHubImpl implements NenjimHub { nextProcessId = 1; //processesScope = new StructuredTaskScope.ShutdownOnFailure(); processes = new HashMap<>(); + } + @Override + public void start() throws Exception { log.info("Starting autorun processes:"); startAutoRunProcesses(); waitForAndShutdown(); } - private void waitForAndShutdown() { + private void waitForAndShutdown() throws InterruptedException { System.out.println("Done - Now online!"); /* @@ -32,14 +37,17 @@ public class NenjimHubImpl implements NenjimHub { } catch (InterruptedException e) { throw new RuntimeException(e); } - processesScope.close(); */ + + awaitShutdown(); + System.out.println("Nenjim is now shutdown (stopped all processes)!"); } private void startAutoRunProcesses() throws Exception { startJupiterPerpsAlarm(); // TODO: Hardcoded/hacky way to auto-start but good enough for now. + startEvelynMissionControl(); // TODO: Old but more correct way to auto start plugins - but it is currently broken. /* @@ -96,7 +104,7 @@ public class NenjimHubImpl implements NenjimHub { System.out.println("NenjimHub command: 'noop'"); } - public void awaitShutdown() throws InterruptedException { + private void awaitShutdown() throws InterruptedException { shutdownLatch.await(); } @@ -115,6 +123,21 @@ public class NenjimHubImpl implements NenjimHub { thread.start(); } + private void startEvelynMissionControl() { + Thread thread = new Thread(() -> { + try { + EvelynMissionControl emc = new EvelynMissionControlImpl(); + emc.start(); + } catch (Throwable throwable) { + throwable.printStackTrace(); + } + }, "Nenjim Plugin - Evelyn Mission Control"); + + thread.setDaemon(false); + thread.start(); + + } + private static final Logger log = LoggerFactory.getLogger(NenjimHubImpl.class); private final CountDownLatch shutdownLatch = new CountDownLatch(1);