1 10 package org.mmbase.module.builders.vwms; 11 12 import org.mmbase.module.core.MMBaseContext; 13 import org.mmbase.util.*; 14 import org.mmbase.util.logging.*; 15 16 27 public class FileCopier implements Runnable { 28 29 private static Logger log = Logging.getLoggerInstance(FileCopier.class.getName()); 31 32 36 Thread kicker = null; 37 40 int sleepTime=8888; 41 44 Queue files; 45 46 51 public FileCopier(Queue files) { 52 this.files=files; 53 init(); 54 } 55 56 60 public void init() { 61 this.start(); 62 } 63 64 65 68 public void start() { 69 70 if (kicker == null) { 71 kicker = MMBaseContext.startThread(this,"FileCopier"); 72 } 73 } 74 75 78 public void stop() { 79 80 kicker = null; 81 } 82 83 87 public void run () { 88 if (kicker!=null) { 89 try { 90 doWork(); 91 } catch(Exception e) { 92 log.error(Logging.stackTrace(e)); 93 } 94 } 95 } 96 97 102 public void doWork() { 103 aFile2Copy afile; 105 106 log.debug("Active"); 107 while (kicker!=null) { 108 try { 109 afile=(aFile2Copy)files.get(); 110 if (afile!=null) { 111 log.info("Copying "+afile.srcpath+"/"+afile.filename); 112 SCPcopy scpcopy=new SCPcopy(afile.sshpath,afile.dstuser,afile.dsthost,afile.dstpath); 113 scpcopy.copy(afile.srcpath,afile.filename); 114 } else { 115 log.error("afile is null ?"); 116 } 117 } catch (InterruptedException e) { 118 log.debug(Thread.currentThread().getName() +" was interruped."); 119 break; 120 } 121 } 122 } 123 } 124 | Popular Tags |