Skip to content

Commit

Permalink
added launch configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ezTxmMC committed Dec 10, 2024
1 parent 71f6512 commit 96e9a7d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.smoothcloud.node;

import eu.smoothcloud.node.configuration.LaunchConfiguration;
import eu.smoothcloud.node.console.Console;
import eu.smoothcloud.node.util.ThreadManager;

Expand All @@ -9,14 +10,15 @@ public static void main(String[] args) {
new SmoothCloudNode();
}

private LaunchConfiguration launchConfiguration;
private Console console;

public SmoothCloudNode() {
ThreadManager manager = new ThreadManager(12);

System.out.println("DEBUG: Before console.start()");
manager.startTask("Console", this::startConsole);
print(console);
this.launchConfiguration = new LaunchConfiguration();
}

private void startConsole() {
Expand All @@ -27,5 +29,4 @@ private void startConsole() {
private void print(Console console) {
console.print("&eInitialize Cloud");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package eu.smoothcloud.node.configuration;

import org.json.JSONException;
import org.json.JSONObject;

public class LaunchConfiguration {
private final JSONObject jsonObject;

public LaunchConfiguration() {
this.jsonObject = new JSONObject("launcher.json");
}

public void setLanguage(String language) {
this.setValue("language", language);
}

public void setHost(String host) {
this.setValue("host", host);
}

public void setPort(int port) {
this.setValue("port", port);
}

public void setMemory(String memory) {
this.setValue("memory", memory);
}

public String getLanguage() {
return (String) this.getValue("language");
}

public String getHost() {
return (String) this.getValue("host");
}

public int getPort() {
return (int) this.getValue("port");
}

public String getMemory() {
return (String) this.getValue("memory");
}

private boolean setValue(String key, Object value) {
try {
this.jsonObject.put(key, value);
return true;
} catch (JSONException e) {
e.printStackTrace();
return false;
}
}

private Object getValue(String key) {
try {
return this.jsonObject.get(key);
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
}

0 comments on commit 96e9a7d

Please sign in to comment.