1 10 package org.jgap.distr.grid; 11 12 import org.apache.commons.cli.*; 13 import org.apache.log4j.*; 14 import org.homedns.dade.jcgrid.cmd.*; 15 import org.homedns.dade.jcgrid.server.*; 16 import java.io.*; 17 18 26 public class JGAPServer { 27 28 private final static String CVS_REVISION = "$Revision: 1.4 $"; 29 30 private final static String className = JGAPServer.class.getName(); 31 32 private static Logger log = Logger.getLogger(className); 33 34 private GridServer m_gs; 35 36 public JGAPServer(String [] args) 37 throws Exception { 38 m_gs = new GridServer(JGAPClientHandlerThread.class); 39 Options options = new Options(); 40 CommandLine cmd = MainCmd.parseCommonOptions(options, m_gs.getNodeConfig(), 41 args); 42 m_gs.start(); 45 } 47 48 public void addFile(String a_filename) throws Exception { 50 String path = m_gs.getVFSSessionPool().getPath(); 51 if (path == null) { 52 return; 53 } 54 if (path.charAt(path.length()-1) != '\\') { 55 path += "\\"; 56 } 57 copyFile(a_filename, path); 58 } 59 60 61 public static void copyFile(String source, String dest) throws Exception { 62 File destFile = new File(dest); 63 if (!destFile.isFile()) { 64 String origFilename = new File(source).getName(); 65 dest = dest + origFilename; 66 } 67 68 File inputFile = new File(source); 69 File outputFile = new File(dest); 70 71 74 FileInputStream in; 75 FileOutputStream out; 76 in = new FileInputStream(inputFile); 77 out = new FileOutputStream(outputFile); 78 79 int c; 80 81 while ( (c = in.read()) != -1) 82 out.write(c); 83 84 in.close(); 85 out.close(); 86 } 87 88 89 public static void main(String [] args) 90 throws Exception { 91 MainCmd.setUpLog4J("server", true); 92 new JGAPServer(args); 95 } 96 } 97 | Popular Tags |