blob: c7dfa183573905293006fb94fc253cb06ef100ca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package org.openslx.taskmanager;
import java.io.File;
import java.io.IOException;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
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!
*
*/
public class App
{
public static void main( String[] args ) throws SocketException, InterruptedException
{
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();
RequestParser parser = new RequestParser( tm );
NetworkHandler nh = new NetworkHandler( Global.LISTEN_PORT, Global.LISTEN_ADDRESS, parser );
threads.add( new Thread( tm ) );
threads.add( new Thread( nh ) );
// Wait for everything
for (Thread t : threads) {
t.start();
}
for (Thread t : threads) {
t.join();
}
}
}
|