blob: c7dfa183573905293006fb94fc253cb06ef100ca (
plain) (
tree)
|
|
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();
}
}
}
|