1 5 package ve.luz.ica.jackass.tools; 6 7 import java.io.BufferedReader ; 8 import java.io.InputStream ; 9 import java.io.InputStreamReader ; 10 11 import org.apache.commons.logging.Log; 12 import org.apache.commons.logging.LogFactory; 13 import org.omg.CORBA.ORB ; 14 import org.omg.PortableServer.POA ; 15 import org.omg.PortableServer.POAHelper ; 16 17 import ve.luz.ica.jackass.deploy.Deployer; 18 import ve.luz.ica.jackass.deploy.DeployerHelper; 19 import ve.luz.ica.remoteio.FileUtil; 20 import ve.luz.ica.remoteio.RemoteFile; 21 22 26 public final class DeployTool 27 { 28 private static final Log LOG = LogFactory.getLog(DeployTool.class); 29 30 33 private DeployTool() 34 { 35 } 36 37 41 public static void main(String [] args) 42 { 43 try 44 { 45 ORB orb = org.omg.CORBA.ORB.init(args, null); 46 org.omg.CORBA.Object poaObj = orb.resolve_initial_references("RootPOA"); 47 POA poa = POAHelper.narrow(poaObj); 48 poa.the_POAManager().activate(); 49 50 Deployer deployer = null; 51 org.omg.CORBA.Object obj = null; 52 53 if (args.length < 1) 54 { 55 System.out.println("Usage: deploytool operation <deployment file name>"); 56 return; 57 } 58 59 String deployerIor = System.getProperty("Deployer"); 60 if (deployerIor == null) 61 { 62 InputStream is = ClassLoader.getSystemResourceAsStream("jackass.deployers"); 63 InputStreamReader isr = new InputStreamReader (is); 64 java.io.BufferedReader myInput = new BufferedReader (isr); 65 deployerIor = myInput.readLine(); 66 } 67 68 obj = orb.string_to_object(deployerIor); 69 deployer = DeployerHelper.narrow(obj); 70 71 if (args[0].equals("d") || args[0].equals("deploy")) 72 { 73 System.out.println("Deploying "+args[1]); 74 RemoteFile remoteFile = FileUtil.createRemoteFile(args[1], poa); 75 deployer.deploy(remoteFile); 76 System.out.println("Deployment complete"); 77 } 78 else if (args[0].equals("u") || args[0].equals("undeploy")) 79 { 80 System.out.println("Undeploying "+args[1]); 81 deployer.undeploy(args[1]); 82 System.out.println("Undeployment complete"); 83 } 84 else 85 { 86 System.out.println("Usage: deploytool operation <deployment file name>"); 87 return; 88 } 89 } 90 catch (Exception e) 91 { 92 System.out.println("Error deploying application " + e.getMessage()); 93 if (LOG.isErrorEnabled()) LOG.error("Error deploying application ", e); 94 } 95 96 } 97 } 98 | Popular Tags |