1 31 package org.objectweb.proactive.ic2d; 32 import org.objectweb.proactive.core.ProActiveException; 33 import org.objectweb.proactive.core.runtime.RuntimeFactory; 34 import org.objectweb.proactive.ic2d.data.IC2DObject; 35 import org.objectweb.proactive.ic2d.data.WorldObject; 36 import org.objectweb.proactive.ic2d.gui.IC2DFrame; 37 38 52 public class IC2D { 53 54 public final static int NOTHING = 0; 55 public final static int GLOBUS = 1; 56 public final static int RSH = 2; 57 58 59 62 public static void main(String args[]) { 63 String [] hosts = null; 64 if (args.length > 0) { 65 hosts = readPropertiesFile(args[0]); 66 } 67 int options = NOTHING; 68 77 try { 78 Class.forName("org.objectweb.proactive.core.runtime.RuntimeFactory"); 80 RuntimeFactory.getDefaultRuntime(); 81 } catch (ProActiveException e1) { 82 e1.printStackTrace(); 83 } 84 catch (ClassNotFoundException e) { 85 e.printStackTrace(); 86 System.exit(1); 87 } 88 IC2DObject ic2dObject = new IC2DObject(); 89 new IC2DFrame(ic2dObject, options); 90 if (hosts != null) { 91 WorldObject worldObject = ic2dObject.getWorldObject(); 92 for (int i = 0; i<hosts.length; i++) { 93 try { 94 worldObject.addHostObject(hosts[i], System.getProperty("proactive.communication.protocol")); 96 } catch (java.rmi.RemoteException e) { 97 System.out.println("Can't create the host "+hosts[i]+", e="+e); 98 } 99 } 100 } 101 } 102 103 104 108 109 113 114 115 119 122 private static String [] readPropertiesFile(String filename) { 123 try { 124 java.io.File f = new java.io.File (filename); 125 if (! f.canRead()) return null; 126 byte[] b = getBytesFromInputStream(new java.io.FileInputStream (f)); 127 java.util.StringTokenizer tokenizer = new java.util.StringTokenizer (new String (b)); 128 int n = tokenizer.countTokens(); 129 if (n == 0) return null; 130 String [] result = new String [n]; 131 int i=0; 132 while (tokenizer.hasMoreTokens()) { 133 result[i++] = tokenizer.nextToken(); 134 } 135 return result; 136 } catch (java.io.IOException e) { 137 return null; 138 } 139 } 140 141 142 149 private static byte[] getBytesFromInputStream(java.io.InputStream in) throws java.io.IOException { 150 java.io.DataInputStream din = new java.io.DataInputStream (in); 151 byte[] bytecodes = new byte[in.available()]; 152 try { 153 din.readFully(bytecodes); 154 } finally { 155 if (din != null) din.close(); 156 } 157 return bytecodes; 158 } 159 160 161 165 } 166 | Popular Tags |