1 import com.coldcore.coloradoftp.core.Core; 2 import com.coldcore.coloradoftp.factory.ObjectFactory; 3 import com.coldcore.coloradoftp.factory.ObjectName; 4 import com.coldcore.coloradoftp.factory.impl.SpringFactory; 5 import org.springframework.core.io.FileSystemResource; 6 import org.springframework.core.io.Resource; 7 8 import java.io.File ; 9 10 20 public class Launcher { 21 22 private static String filename = "conf/beans.xml"; 23 24 25 public static void main(String [] args) { 26 System.out.println(); 27 System.out.println("========================================"); 28 System.out.println("ColoradoFTP - the open source FTP server"); 29 System.out.println("Make sure to visit www.coldcore.com"); 30 System.out.println("========================================"); 31 32 File file = new File (filename); 33 if (args.length > 0) file = new File (args[0]); 34 35 System.out.println("Reading configuration from: "+file.getAbsolutePath()); 36 System.out.println("To set a different configuration file use 'Launcher filename'"); 37 38 if (!file.exists()) { 39 System.out.println("Configuration file not found, terminating..."); 40 System.exit(1); 41 } 42 43 try { 44 Resource resource = new FileSystemResource(file); 45 ObjectFactory.setInternalFactory(new SpringFactory(resource)); 46 } catch (Throwable e) { 47 System.out.println("Cannot initialize object factory, terminating..."); 48 e.printStackTrace(); 49 System.exit(1); 50 } 51 System.out.println("Object factory initialized"); 52 53 Core core = null; 54 try { 55 core = (Core) ObjectFactory.getObject(ObjectName.CORE); 56 core.start(); 57 } catch (Throwable e) { 58 System.out.println("Unable to start the server, terminating..."); 59 e.printStackTrace(); 60 System.exit(1); 61 } 62 63 66 System.out.println("Server started, use Ctrl+C to kill the process"); 67 } 68 69 83 84 } 85
| Popular Tags
|