1 23 package com.sun.enterprise.tools.deployment.main; 24 25 import java.util.*; 26 import java.io.*; 27 import javax.swing.*; 29 30 import com.sun.enterprise.Version; 31 import com.sun.enterprise.util.FileUtil; 32 import com.sun.enterprise.deployment.*; 33 import com.sun.enterprise.tools.packager.ComponentPackager; 34 import com.sun.enterprise.util.LocalStringManagerImpl; 35 import com.sun.enterprise.tools.deployment.backend.JarInstaller; 36 import com.sun.enterprise.resource.ConnectorInfo; 37 import com.sun.enterprise.resource.NameNotFoundException; 38 import com.sun.enterprise.resource.DuplicateNameException; 39 import com.sun.enterprise.resource.ConfigurationPropertyException; 40 41 42 45 46 public class Main 47 { 48 49 52 53 private static LocalStringManagerImpl localStrings = 54 new LocalStringManagerImpl(Main.class); 55 56 public static String VERSION = "1.0"; 63 private static String NAME = 64 localStrings.getLocalString( 65 "enterprise.tools.deployment.main.name", 66 "Deployment tool version {0}.", 67 new Object [] { VERSION }); 68 69 private static String UI_STARTUP_MESSAGE = 70 localStrings.getLocalString( 71 "enterprise.tools.deployment.main.defaultstartupmessage", 72 "Starting Assembly tool, version {0}\n(Type 'assemblytool -help' for command line options.)", new Object [] { VERSION }); 74 75 private static String LOG_NAME = 76 localStrings.getLocalString( 77 "enterprise.tools.deployment.main.logname", 78 "Deploytool"); 79 80 82 83 84 public static String DEPLOY_APPLICATION = "-deploy"; private static String EJB_WIZARD = "-ejbWizard"; private static String PACKAGE_EJBS = "-packageEjbs"; private static String LIST_APPLICATIONS = "-listApps"; private static String NO_OVER_WRITE = "-noOverWrite"; private static String DEPLOY_CONNECTOR = "-deployConnector"; private static String UNDEPLOY_CONNECTOR = "-undeployConnector"; private static String LIST_CONNECTORS = "-listConnectors"; private static String ADD_FACTORY = "-addConnectionFactory"; private static String REMOVE_FACTORY = "-removeConnectionFactory"; 95 96 public static String UNINSTALL = "-uninstall"; 98 public static String GENERATE_SQL = "-generateSQL"; 100 public static String DONT_OVER_WRITE_SQL = "-noOverWrite"; 102 public static String UI = "-ui"; 104 public static String HELP = "-help"; 106 108 109 110 public static void main(String args[]) { 111 112 com.sun.enterprise.util.Utility.checkJVMVersion(); 113 int uiFontSize=11; 116 java.awt.Font nbDialogPlain = new java.awt.Font ("Dialog", java.awt.Font.PLAIN, uiFontSize); java.awt.Font nbSerifPlain = new java.awt.Font ("Serif", java.awt.Font.PLAIN, uiFontSize); java.awt.Font nbSansSerifPlain = new java.awt.Font ("SansSerif", java.awt.Font.PLAIN, uiFontSize); java.awt.Font nbMonospacedPlain = new java.awt.Font ("Monospaced", java.awt.Font.PLAIN, uiFontSize); UIManager.getDefaults ().put ("Button.font", nbDialogPlain); UIManager.getDefaults ().put ("ToggleButton.font", nbDialogPlain); UIManager.getDefaults ().put ("RadioButton.font", nbDialogPlain); UIManager.getDefaults ().put ("CheckBox.font", nbDialogPlain); UIManager.getDefaults ().put ("ColorChooser.font", nbDialogPlain); UIManager.getDefaults ().put ("ComboBox.font", nbDialogPlain); UIManager.getDefaults ().put ("Label.font", nbDialogPlain); UIManager.getDefaults ().put ("List.font", nbDialogPlain); UIManager.getDefaults ().put ("MenuBar.font", nbDialogPlain); UIManager.getDefaults ().put ("MenuItem.font", nbDialogPlain); UIManager.getDefaults ().put ("RadioButtonMenuItem.font", nbDialogPlain); UIManager.getDefaults ().put ("CheckBoxMenuItem.font", nbDialogPlain); UIManager.getDefaults ().put ("Menu.font", nbDialogPlain); UIManager.getDefaults ().put ("PopupMenu.font", nbDialogPlain); UIManager.getDefaults ().put ("OptionPane.font", nbDialogPlain); UIManager.getDefaults ().put ("Panel.font", nbDialogPlain); UIManager.getDefaults ().put ("ProgressBar.font", nbDialogPlain); UIManager.getDefaults ().put ("ScrollPane.font", nbDialogPlain); UIManager.getDefaults ().put ("Viewport.font", nbDialogPlain); UIManager.getDefaults ().put ("TabbedPane.font", nbDialogPlain); UIManager.getDefaults ().put ("Table.font", nbDialogPlain); UIManager.getDefaults ().put ("TableHeader.font", nbDialogPlain); UIManager.getDefaults ().put ("TextField.font", nbSansSerifPlain); UIManager.getDefaults ().put ("PasswordField.font", nbMonospacedPlain); UIManager.getDefaults ().put ("TextArea.font", nbMonospacedPlain); UIManager.getDefaults ().put ("TextPane.font", nbSerifPlain); UIManager.getDefaults ().put ("EditorPane.font", nbSerifPlain); UIManager.getDefaults ().put ("TitledBorder.font", nbDialogPlain); UIManager.getDefaults ().put ("ToolBar.font", nbDialogPlain); UIManager.getDefaults ().put ("ToolTip.font", nbSansSerifPlain); UIManager.getDefaults ().put ("Tree.font", nbDialogPlain); 153 166 167 168 if (args.length == 0) { 169 System.out.println(UI_STARTUP_MESSAGE); 170 new DeployTool(true); 171 return; 172 } else 173 if (args[0].equals(UI)) { 174 new DeployTool(true); 175 return; 176 } 177 178 if (args[0].equals("-userdir")){ if (args.length >=2){ 181 new DeployTool(true, args[1]); 182 return; 183 }else { 184 help(); 185 } 186 } 187 help(); 188 189 191 212 213 214 558 559 } 560 561 562 public static void help() { 563 564 System.out.println(localStrings.getLocalString 565 ("enterprise.tools.deployment.main.deploymenttoolversion", "The deployment tool version is {0}", new Object [] {VERSION})); 567 System.out.println(localStrings.getLocalString 568 ("enterprise.tools.deployment.main.options", 569 "Options:")); 570 System.out.print(" "); 572 612 613 System.out.println("-userdir <userdir>"); 616 System.exit(1); 617 } 618 619 public static void listApplications(String serverName) { 620 try { 621 DeployTool deployTool = new DeployTool(false); 622 JarInstaller backend = deployTool.getServerManager().getServerForName(serverName); 623 Vector deployedApps = backend.getApplicationNames(); 624 if( deployedApps.size() > 0 ) { 625 System.out.println(localStrings.getLocalString 626 ("enterprise.tools.deployment.main.followingapps", 627 "The following apps are deployed on {0}:", 628 new Object [] {serverName})); 629 for(int appIndex = 0; appIndex < deployedApps.size(); appIndex++) { 630 System.out.println("\t" + (String ) deployedApps.elementAt(appIndex)); } 632 } 633 else { 634 System.out.println(localStrings.getLocalString 635 ("enterprise.tools.deployment.main.nodeployedapps", "There are no deployed applications on {0}", new Object [] {serverName})); 638 } 639 } 640 catch(Exception e) { 641 Log.print(LOG_NAME, e.getMessage()); 643 } 644 } 645 646 static private void handleDeploymentException(Exception ex) { 647 if (ex instanceof DuplicateNameException) { 648 String msg = localStrings.getLocalString 649 ("duplicatename.exception", "", 650 new Object [] {ex.getMessage()}); 651 System.err.println(msg); 652 } else if (ex instanceof NameNotFoundException) { 653 String msg = localStrings.getLocalString 654 ("namenotfound.exception", "", 655 new Object [] {ex.getMessage()}); 656 System.err.println(msg); 657 } else if (ex instanceof ConfigurationPropertyException) { 658 String msg = localStrings.getLocalString 659 ("configproperty.exception", "", 660 new Object [] {ex.getMessage()}); 661 System.err.println(msg); 662 } else { 663 String msg = localStrings.getLocalString 664 ("generic.exception", "", 665 new Object [] {ex.toString()}); 666 System.err.println(msg); 667 } 668 } 669 670 } 671 672 | Popular Tags |