1 2 27 28 package org.objectweb.ccm.filetransfer.cif; 29 30 32 41 42 public class ProgImpl 43 extends org.objectweb.ccm.filetransfer.ProgSessionComposition.ComponentImpl 44 implements java.lang.Runnable , java.awt.event.ActionListener { 45 51 52 private String name_; 53 54 private String prog_dir; 55 private String [] fileList = null; 56 57 58 private Thread the_prog; 59 60 61 private java.awt.Frame frame_; 62 private java.awt.Button button_start; 63 64 65 private java.awt.TextArea textArea_; 66 67 73 74 public ProgImpl() { 75 76 77 } 78 79 85 91 97 103 public void configuration_complete() 104 throws org.omg.Components.InvalidConfiguration { 105 106 if (name_ == null) 108 throw new org.omg.Components.InvalidConfiguration(); 109 110 132 the_prog = new java.lang.Thread (this); 134 the_prog.start(); 135 136 137 } 138 139 145 150 public void ccm_remove() throws org.omg.Components.CCMException { 151 152 } 153 154 160 165 public void the_name(String n) { 166 name_ = n; 167 168 } 169 170 175 public String the_name() { 176 return name_; 177 } 178 179 185 public void send_files() { 186 187 189 190 java.io.File currentdir = new java.io.File (System.getProperty("user.dir")); 191 currentdir = new java.io.File (currentdir.getParent()); 192 java.io.File path = new java.io.File (currentdir.getParent() + "/IMAGE/Send/" + name_); 193 System.out.println(path); 194 195 196 fileList = path.list(); 197 198 for (int i = 0; i < fileList.length; i++) { 200 201 202 203 java.io.File testfile = new java.io.File (path + "/" + fileList[i]); 204 if (testfile.isFile()) { 205 206 java.io.FileInputStream inStream = null; 210 211 try { 212 213 214 System.out.println( 215 "Sending " 216 + path 217 + "\\" 218 + fileList[i] 219 + " from " 220 + name_ 221 + " to Channel component"); 222 inStream = 223 new java.io.FileInputStream (path + "/" + fileList[i]); 224 } catch (java.io.FileNotFoundException ex) { 225 System.err.println( 226 "Can't open file " + fileList[i] + ex.getMessage()); 227 228 } 229 230 byte[] file = null; 231 try { 232 file = new byte[inStream.available()]; 233 inStream.read(file); 234 inStream.close(); 235 } catch (java.io.IOException ex) { 236 System.err.println( 237 "Can't read from " + fileList[i] + ex.getMessage()); 238 239 } 240 241 245 get_context().push_to_channels(new ImagesImpl(file, fileList[i])); 246 247 249 try { 251 Thread.sleep(2000); 252 } catch (InterruptedException ex) { 253 } 255 } 256 } 257 258 } 259 260 public void run() { 261 262 for (int j = 0; j < 100; j++) { 263 this.send_files(); 264 265 } 266 267 } 268 269 275 280 public void actionPerformed(java.awt.event.ActionEvent e) { 281 282 the_prog = new java.lang.Thread (this); 284 the_prog.start(); 285 286 } 287 288 } 289 | Popular Tags |