⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jumpinstallertool.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. */package com.sun.jumpimpl.module.installer;import com.sun.jump.common.JUMPAppModel;import com.sun.jump.common.JUMPApplication;import com.sun.jump.common.JUMPContent;import com.sun.jump.executive.JUMPExecutive;import com.sun.jump.module.JUMPModuleFactory;import com.sun.jump.module.download.JUMPDownloadDescriptor;import com.sun.jump.module.download.JUMPDownloadDestination;import com.sun.jump.module.download.JUMPDownloadException;import com.sun.jump.module.download.JUMPDownloadModule;import com.sun.jump.module.download.JUMPDownloadModuleFactory;import com.sun.jump.module.download.JUMPDownloader;import com.sun.jump.module.installer.JUMPInstallerModule;import com.sun.jump.module.installer.JUMPInstallerModuleFactory;import com.sun.jumpimpl.module.download.DownloadDestinationImpl;import com.sun.jumpimpl.module.download.OTADiscovery;import java.io.File;import java.net.MalformedURLException;import java.net.URISyntaxException;import java.net.URL;import java.util.HashMap;import java.util.Hashtable;import java.util.Iterator;import java.util.Properties;import java.util.Vector;/** * This class is an installation tool for downloading, * installing, uninstalling, and listing content in the * content store application repository. * * This class should be routinely modified with more * features as development continues. * * The current supported commands are: *    list, info, install, install_all, uninstall, uninstall_all * * The commands install and uninstall will provide the user with an interactive * way to choose files to be installed or uninstalled.  The command install_all * and uninstall_all will install or uninstall all content without interactive * with the user. * * Usage: *   <cvm>  <system properties> -cp <classpath> com.sun.jumpimpl.module.installer.JUMPInstallerTool -ProvisioningServerURL <url of provisioning server> <options> -command <command> *     <system properties> is optional, but it should be known that contentstore.root *         can be overridden here if desired. *         For example, -Dcontentstore.root=<repository dir> can be specified *     <command> can currently be list, info, install, install_all, uninstall, and uninstall_all *     <options> *        -verbose:  print debugging messages * * Ex: *   cvm -cp $JUMP_JARS com.sun.jumpimpl.module.installer.JUMPInstallerTool -command list *   cvm -Dcontentstore.root=data2 -cp $JUMP_JARS com.sun.jumpimpl.module.installer.JUMPInstallerTool -command install *   cvm -cp $JUMP_JARS com.sun.jumpimpl.module.installer.JUMPInstallerTool -command uninstall *   cvm -cp $JUMP_JARS com.sun.jumpimpl.module.installer.JUMPInstallerTool -verbose -command install_all *   cvm -cp $JUMP_JARS com.sun.jumpimpl.module.installer.JUMPInstallerTool -command uninstall_all * */public class JUMPInstallerTool {        /**     * xlet installer module object     */    protected JUMPInstallerModule xletInstaller = null;    /**     * midlet installer module object     */    protected JUMPInstallerModule midletInstaller = null;    /**     * main installer module object     */    protected JUMPInstallerModule mainInstaller = null;    /**     * holds download module object     */    protected JUMPDownloadModule downloadModule = null;    /**     * URL used for Provisioning Server location     */    protected String ProvisioningServer = null;    /**     * The current command to be run     */    protected String Command = null;    /**     * Sub-values for the current command to be run     */    protected String Value = null;    /**     * Whether or not to print debug messages     */    protected boolean Verbose = false;    /**     * URL containing the content to be installed.     */    protected String ContentURL = null;    /**     * URI of the descriptor file of the content to be installed     */    protected String DescriptorURI = null;    /**     * The protocol of the content.  The value should be either:     *   ota/midp or ota/oma     */    protected String Protocol = null;    /**     * The application type of an installed content     */    protected String Type = null;    /**     * The id of an installed content.     */    protected String Id = null;    /**     * The current root of content store where applications are located     */    private String repository = null;    /**     * The property name holding the root of content store     */    private static final String repositoryProperty = "contentstore.root";            private Hashtable parseArgs(String args[]) {        if (args == null) {            return null;        }        Hashtable argTable = new Hashtable();        String arg = null;                // The options -ContentURL, -DescriptorURI, and -Protocol are not        // yet functional yet as our download implementation's createDescriptor        // methods assume an http connection.        for (int i = 0; i < args.length; i++) {            if (args[i].equals("-ProvisioningServerURL")) {                arg = args[++i];                argTable.put("ProvisioningServerURL", arg);            } else if (args[i].equals("-command")) {                arg = args[++i];                argTable.put("Command", arg);            } else if (args[i].equals("-verbose")) {                System.setProperty("installer.verbose", "true");                argTable.put("Verbose", "true");            } else if (args[i].equals("-ContentURL")) {                arg = args[++i];                argTable.put("ContentURL", arg);            } else if (args[i].equals("-DescriptorURI")) {                arg = args[++i];                argTable.put("DescriptorURI", arg);            } else if (args[i].equals("-Protocol")) {                arg = args[++i];                argTable.put("Protocol", arg);            } else if (args[i].equals("-id")) {                arg = args[++i];                argTable.put("Id", arg);            } else if (args[i].equals("-type")) {                arg = args[++i];                argTable.put("Type", arg);            }        }        return argTable;    }        /**     * Creates a new instance of JUMPInstallerTool     * @param args arguments for the tool     */    public JUMPInstallerTool(String[] args) {        Hashtable hash = parseArgs(args);        this.Command = (String)hash.get("Command");        String verbose = (String)hash.get("Verbose");        if (verbose != null && verbose.equals("true")) {            this.Verbose = true;        }                this.ProvisioningServer = (String)hash.get("ProvisioningServerURL");                // The three lines of code below, along with usage of the fields,        // is for a future case where the tool will allow local installations.        this.ContentURL = (String)hash.get("ContentURL");        this.DescriptorURI = (String)hash.get("DescriptorURI");        this.Protocol = (String)hash.get("Protocol");        this.Type = (String)hash.get("Type");        this.Id = (String)hash.get("Id");                trace("");        trace("=============================================");        trace("JUMPInstallerTool Settings");        trace("--------------------------");        trace("");        trace("   Command: " + Command);        trace("App Server: " + ProvisioningServer);        trace("        ID: " + Id);        trace("      Type: " + Type);        trace("=============================================");        trace("");                if (!setup()) {            System.exit(-1);        };                if (Command != null) {            doCommand();        }    }        private void usage() {        System.out.println("Usage:");        System.out.println("  <cvm> <system properties> -cp <classpath> com.sun.jumpimpl.module.installer.JUMPInstallerTool <options>  -command <command>");        System.out.println("Available commands that can be used are:  list, install, install_all, uninstall, and uninstall_all.");        System.out.println("Available options: -verbose");        System.out.println("");        System.out.println("Ex:");        System.out.println("  cvm -cp $JUMP_JARS com.sun.jumpimpl.module.installer.JUMPInstallerTool -verbose -command list");        System.out.println("");    }        private void trace(String str) {        if (this.Verbose) {            System.out.println(str);        }    }        private boolean setup() {                repository = System.getProperty(repositoryProperty);        if (repository != null) {            // test setup, make a repository root            File file = new File(repository);            if (!file.exists()) {                System.out.println("ERROR: " + repository + " directory not found.");                return false;            }        }                if (JUMPExecutive.getInstance() == null) {            JUMPModuleFactory factory = null;            factory = new com.sun.jumpimpl.module.installer.InstallerFactoryImpl();            factory.load(com.sun.jumpimpl.process.JUMPModulesConfig.getProperties());            factory = new com.sun.jumpimpl.module.contentstore.StoreFactoryImpl();            factory.load(com.sun.jumpimpl.process.JUMPModulesConfig.getProperties());            factory = new com.sun.jumpimpl.module.download.DownloadModuleFactoryImpl();            factory.load(com.sun.jumpimpl.process.JUMPModulesConfig.getProperties());        }                return true;    }        private JUMPInstallerModule createInstaller(JUMPAppModel type) {                JUMPInstallerModule module = null;                if (type == JUMPAppModel.MAIN) {            module = JUMPInstallerModuleFactory.getInstance().getModule(JUMPAppModel.MAIN);        } else if (type == JUMPAppModel.XLET) {            module = JUMPInstallerModuleFactory.getInstance().getModule(JUMPAppModel.XLET);        } else if (type == JUMPAppModel.MIDLET) {            module = JUMPInstallerModuleFactory.getInstance().getModule(JUMPAppModel.MIDLET);        }                if (module == null)  {            return null;        }                return module;    }        private void doCommand() {        if (Command.equals("install")) {            if (DescriptorURI != null) {                doInstall(DescriptorURI);            } else {                doInstall(ProvisioningServer, true);            }        } else if (Command.equals("install_all")) {            doInstall(ProvisioningServer, false);        } else if (Command.equals("list")) {            doList();        } else if (Command.equals("uninstall")) {            if (Id != null && Type != null) {                doUninstall(JUMPAppModel.fromName(Type), Integer.parseInt(Id));            } else {                doUninstall(true);            }        } else if (Command.equals("uninstall_all")) {            doUninstall(false);        } else if (Command.equals("info")) {            doInfo();        }    }        private void error() {        System.out.println("ERROR: Could not install.");        if (!this.Verbose) {            System.out.println("==> Please run with -verbose for more information.");        }    }        /**     * Print out information pertaining to each application in a list.     */    public void doInfo() {        System.out.println("");        System.out.println("---------------------------------");        System.out.println("Applications Within Content Store");        System.out.println("---------------------------------");        System.out.println("");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -