| 1 21 22 package com.rift.coad.daemon.deployment; 23 24 import com.rift.coad.lib.configuration.ConfigurationException; 25 import java.io.BufferedWriter ; 26 import java.io.File ; 27 import java.io.FileOutputStream ; 28 import java.io.FileWriter ; 29 import java.io.IOException ; 30 import java.rmi.RemoteException ; 31 import org.apache.log4j.Logger; 32 33 39 public class DeploymentDaemonImpl implements DeploymentDaemon { 40 41 protected Logger log = 42 Logger.getLogger(DeploymentDaemonImpl.class.getName()); 43 44 String coadLocal = ""; 45 String coadunationTmp = ""; 46 47 48 public DeploymentDaemonImpl() throws Exception { 49 try { 50 com.rift.coad.lib.configuration.Configuration coadConfig = 51 com.rift.coad.lib.configuration.ConfigurationFactory. 52 getInstance().getConfig(com.rift.coad.daemon.deployment. 53 DeploymentDaemonImpl.class); 54 coadLocal = coadConfig.getString("coadunation_deploy"); 55 coadunationTmp = coadConfig.getString("coadunation_temp"); 56 } catch (ConfigurationException ex) { 57 log.error("Failed to set jython properties :" + ex.getMessage(), 58 ex); 59 throw new Exception ("Failed to set jython properties :" + ex); 60 } 61 } 62 63 72 public void daemonDeployer(byte[] file, String name) 73 throws RemoteException , DeploymentDaemonException { 74 try { 75 File temp = File.createTempFile(name, null); 76 FileOutputStream fos = new FileOutputStream (temp); 77 fos.write(file); 78 fos.close(); 79 File supFile = new File (coadLocal + File.separator + name); 80 temp.renameTo(supFile); 81 } catch (IOException ex) { 82 log.error("Failed to copy file:" + ex, ex); 83 } 84 } 85 86 95 public void copyFile(byte[] file, String name, String location) 96 throws RemoteException { 97 try { 98 File temp = File.createTempFile(name, null); 99 FileOutputStream fos = new FileOutputStream (temp); 100 fos.write(file); 101 fos.close(); 102 File supFile = new File (location + File.separator + name); 103 temp.renameTo(supFile); 104 } catch (IOException ex) { 105 log.error("Failed to copy file:" + ex, ex); 106 } 107 } 108 109 } 110 | Popular Tags |