summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-11-13 17:09:20 +0100
committerSimon Rettberg2019-11-13 17:09:20 +0100
commita27c3540994bf3c5188baab45d1012af653cb00d (patch)
tree46f5acfd23bc08d7898a9deca4878752ad18e39f
parentBoundedLog type + serializer (diff)
downloadtaskman-lite-a27c3540994bf3c5188baab45d1012af653cb00d.tar.gz
taskman-lite-a27c3540994bf3c5188baab45d1012af653cb00d.tar.xz
taskman-lite-a27c3540994bf3c5188baab45d1012af653cb00d.zip
Get rid of class loader hack, use command line instead
-rw-r--r--daemon/src/main/java/org/openslx/taskmanager/App.java20
-rw-r--r--daemon/src/main/java/org/openslx/taskmanager/util/ClassLoaderHack.java36
-rwxr-xr-xdaemon/taskmanager.sh8
3 files changed, 8 insertions, 56 deletions
diff --git a/daemon/src/main/java/org/openslx/taskmanager/App.java b/daemon/src/main/java/org/openslx/taskmanager/App.java
index c7dfa18..6b281d6 100644
--- a/daemon/src/main/java/org/openslx/taskmanager/App.java
+++ b/daemon/src/main/java/org/openslx/taskmanager/App.java
@@ -1,7 +1,5 @@
package org.openslx.taskmanager;
-import java.io.File;
-import java.io.IOException;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
@@ -10,7 +8,6 @@ import org.apache.log4j.BasicConfigurator;
import org.openslx.taskmanager.main.Taskmanager;
import org.openslx.taskmanager.network.NetworkHandler;
import org.openslx.taskmanager.network.RequestParser;
-import org.openslx.taskmanager.util.ClassLoaderHack;
/**
* Hello world!
@@ -23,23 +20,6 @@ public class App
{
BasicConfigurator.configure();
// Load all task plugins
- Thread.currentThread().setContextClassLoader( ClassLoader.getSystemClassLoader() );
- File folder = new File( "./plugins" );
- if ( !folder.exists() ) {
- System.out.println( "No plugin folder found - nothing to do." );
- System.exit( 1 );
- }
- for ( File file : folder.listFiles() ) {
- if ( !file.isFile() || !file.toString().endsWith( ".jar" ) )
- continue;
- try {
- ClassLoaderHack.addFile( file );
- } catch ( IOException e ) {
- e.printStackTrace();
- System.out.println( "Could not add plugin: " + file.toString() );
- System.exit( 1 );
- }
- }
Environment.load( "config/environment" );
List<Thread> threads = new ArrayList<>();
Taskmanager tm = new Taskmanager();
diff --git a/daemon/src/main/java/org/openslx/taskmanager/util/ClassLoaderHack.java b/daemon/src/main/java/org/openslx/taskmanager/util/ClassLoaderHack.java
index 0a3160c..2557fcb 100644
--- a/daemon/src/main/java/org/openslx/taskmanager/util/ClassLoaderHack.java
+++ b/daemon/src/main/java/org/openslx/taskmanager/util/ClassLoaderHack.java
@@ -1,43 +1,7 @@
package org.openslx.taskmanager.util;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-
public class ClassLoaderHack
{
- @SuppressWarnings( "rawtypes" )
- private static final Class[] parameters = new Class[] { URL.class };
-
- public static void addFile( String s ) throws IOException
- {
- File f = new File( s );
- addFile( f );
- }
-
- public static void addFile( File f ) throws IOException
- {
- addURL( f.toURI().toURL() );
- }
-
- public static void addURL( URL u ) throws IOException
- {
- URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader();
- Class<URLClassLoader> sysclass = URLClassLoader.class;
-
- try {
- Method method = sysclass.getDeclaredMethod( "addURL", parameters );
- method.setAccessible( true );
- method.invoke( sysloader, new Object[] { u } );
- System.out.println( "Loaded " + u.toString() );
- } catch ( Throwable t ) {
- t.printStackTrace();
- throw new IOException( "Error, could not add URL to system classloader" );
- }
-
- }
/**
* Get Class meta-object for given class in package. Only return class if it's somehow
diff --git a/daemon/taskmanager.sh b/daemon/taskmanager.sh
new file mode 100755
index 0000000..269701d
--- /dev/null
+++ b/daemon/taskmanager.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+jars=
+for i in plugins/*.jar; do
+ jars="${jars}:$i"
+done
+exec java -Xmx80M -cp "taskmanager.jar${jars}" org.openslx.taskmanager.App
+