summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'daemon')
-rw-r--r--daemon/src/main/java/org/openslx/taskmanager/App.java1
-rw-r--r--daemon/src/main/java/org/openslx/taskmanager/Environment.java67
2 files changed, 1 insertions, 67 deletions
diff --git a/daemon/src/main/java/org/openslx/taskmanager/App.java b/daemon/src/main/java/org/openslx/taskmanager/App.java
index d64929d..3b8eb66 100644
--- a/daemon/src/main/java/org/openslx/taskmanager/App.java
+++ b/daemon/src/main/java/org/openslx/taskmanager/App.java
@@ -6,6 +6,7 @@ import java.util.List;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
+import org.openslx.taskmanager.api.Environment;
import org.openslx.taskmanager.main.Taskmanager;
import org.openslx.taskmanager.network.NetworkHandlerTcp;
import org.openslx.taskmanager.network.NetworkHandlerUdp;
diff --git a/daemon/src/main/java/org/openslx/taskmanager/Environment.java b/daemon/src/main/java/org/openslx/taskmanager/Environment.java
deleted file mode 100644
index acbfad4..0000000
--- a/daemon/src/main/java/org/openslx/taskmanager/Environment.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.openslx.taskmanager;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.log4j.Logger;
-
-/**
- * Holds the environment that tasks running a system command *should*
- * use. The environment is read from a config file.
- */
-public class Environment
-{
-
- private static final Logger log = Logger.getLogger( Environment.class );
-
- private static Map<String, String> env = new LinkedHashMap<>();
-
- public static boolean load( String fileName )
- {
- try {
- FileReader fileReader = new FileReader( fileName );
- BufferedReader bufferedReader = new BufferedReader( fileReader );
-
- Map<String, String> env = new LinkedHashMap<>();
- String line = null;
- while ( ( line = bufferedReader.readLine() ) != null ) {
- if ( !line.matches( "^[a-zA-Z0-9_]+=" ) )
- continue;
- String[] part = line.split( "=", 2 );
- env.put( part[0], part[1] );
- }
-
- bufferedReader.close();
-
- Environment.env = env;
- log.info( "Loaded " + env.size() + " environment lines." );
- } catch ( IOException e ) {
- log.info( "Could not load environment definition from " + fileName + ". Processes might use the same environment as this thread." );
- return false;
- }
- return true;
- }
-
- public static void set( Map<String, String> environment )
- {
- environment.clear();
- environment.putAll( env );
- }
-
- public static String[] get()
- {
- // Get reference to env so it doesn't change while in this function (load() from other thread)
- Map<String, String> env = Environment.env;
- String ret[] = new String[ env.size() ];
- int i = 0;
- for ( Entry<String, String> it : env.entrySet() ) {
- ret[i++] = it.getKey() + "=" + it.getValue();
- }
- return ret;
- }
-
-}