KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > standalone > StandaloneUpdateApplication


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.standalone;
12
13 import org.eclipse.core.runtime.*;
14 import org.eclipse.osgi.util.NLS;
15 import org.eclipse.update.internal.core.*;
16
17 /**
18  * The application class used to launch standalone update commands.
19  * <p>
20  * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to
21  * change significantly before reaching stability. It is being made available at this early stage to solicit feedback
22  * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken
23  * (repeatedly) as the API evolves.
24  * </p>
25  * @since 3.0
26  */

27 public class StandaloneUpdateApplication implements IPlatformRunnable {
28
29     public final static Integer JavaDoc EXIT_ERROR = new Integer JavaDoc(1);
30     private static boolean loggedException = false;
31
32     /* (non-Javadoc)
33      * @see org.eclipse.core.boot.IPlatformRunnable#run(java.lang.Object)
34      */

35     public Object JavaDoc run(Object JavaDoc args) throws Exception JavaDoc {
36         if (args == null)
37             return EXIT_ERROR;
38         if (args instanceof String JavaDoc[]) {
39             String JavaDoc[] params = (String JavaDoc[]) args;
40             CmdLineArgs cmdLineArgs = new CmdLineArgs(params);
41             ScriptedCommand cmd = cmdLineArgs.getCommand();
42             if (cmd == null) {
43                 System.out.println(NLS.bind(Messages.Standalone_cmdFailed, (new String JavaDoc[] { Platform.getLogFileLocation().toOSString() })));
44                 return EXIT_ERROR;
45             }
46             loggedException = false;
47             boolean result = cmd.run();
48             if (result) {
49                 if (loggedException) {
50                     System.out.println(NLS.bind(Messages.Standalone_cmdCompleteWithErrors, (new String JavaDoc[] { Platform.getLogFileLocation().toOSString() })));
51                 } else {
52                     System.out.println(Messages.Standalone_cmdOK);
53                 }
54                 return IPlatformRunnable.EXIT_OK;
55             } else {
56                 if (loggedException) {
57                     System.out.println(NLS.bind(Messages.Standalone_cmdFailed, (new String JavaDoc[] { Platform.getLogFileLocation().toOSString() })));
58                 } else {
59                     System.out.println(Messages.Standalone_cmdFailedNoLog);
60                 }
61                 return EXIT_ERROR;
62             }
63         }
64         return EXIT_ERROR;
65     }
66     public static void exceptionLogged() {
67         loggedException = true;
68     }
69
70 }
71
Popular Tags