-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com-myrobotlab:MyRobotLab/myrobotlab…
… into jmonkey-updates
- Loading branch information
Showing
193 changed files
with
1,806 additions
and
1,104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.myrobotlab.config; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import org.myrobotlab.codec.CodecUtils; | ||
import org.myrobotlab.framework.StartYml; | ||
import org.myrobotlab.io.FileIO; | ||
import org.myrobotlab.service.Runtime; | ||
import org.myrobotlab.service.config.RuntimeConfig; | ||
|
||
public class ConfigUtils { | ||
|
||
/** | ||
* This gets the current resource root without starting a Runtime instance if | ||
* not already started. The resource root depends on config, if Runtime is | ||
* running the logic and current config name is already available. If Runtime | ||
* is not running, we need to go through a series of steps to deterime where | ||
* the resource root is configured. | ||
* | ||
* @return | ||
*/ | ||
public static String getResourceRoot() { | ||
|
||
String resource = "resource"; | ||
|
||
// check if runtime is running | ||
if (!Runtime.isAvailable()) { | ||
// check for start.yml | ||
|
||
File checkStartYml = new File("start.yml"); | ||
StartYml startYml = new StartYml(); | ||
if (checkStartYml.exists()) { | ||
String yml; | ||
try { | ||
yml = FileIO.toString("start.yml"); | ||
startYml = CodecUtils.fromYaml(yml, StartYml.class); | ||
|
||
// see if autostart is on with a config | ||
if (startYml.enable) { | ||
// use that config to find runtime.yml | ||
|
||
File runtimeYml = new File(Runtime.ROOT_CONFIG_DIR + File.separator + startYml.config + File.separator + "runtime.yml"); | ||
if (runtimeYml.exists()) { | ||
// parse that file look for resource: entry in file | ||
RuntimeConfig config = (RuntimeConfig) CodecUtils.readServiceConfig(runtimeYml.getAbsolutePath()); | ||
resource = config.resource; | ||
} | ||
|
||
} else { | ||
// start.yml enable = false / so we'll use default config | ||
File runtimeYml = new File(Runtime.ROOT_CONFIG_DIR + File.separator + "default" + File.separator + "runtime.yml"); | ||
if (runtimeYml.exists()) { | ||
// parse that file look for resource: entry in file | ||
RuntimeConfig config = (RuntimeConfig) CodecUtils.readServiceConfig(runtimeYml.getAbsolutePath()); | ||
resource = config.resource; | ||
} | ||
} | ||
|
||
} catch (IOException e) { | ||
// problem getting or parsing | ||
// going to assume default "resource" | ||
} | ||
} // no startYml | ||
return resource; | ||
} else { | ||
// Runtime is available - ask it | ||
return Runtime.getInstance().getConfig().resource; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.