KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > installer > NonInteractiveInstall


1 /*
2  * NonInteractiveInstall.java
3  *
4  * Originally written by Slava Pestov for the jEdit installer project. This work
5  * has been placed into the public domain. You may use this work in any way and
6  * for any purpose you wish.
7  *
8  * THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
9  * IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, ASSUMES
10  * _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE RESULTING FROM THE USE, MODIFICATION,
11  * OR REDISTRIBUTION OF THIS SOFTWARE.
12  */

13
14 package installer;
15
16 import java.util.Vector JavaDoc;
17
18 /*
19  * Performs non-interactive installation.
20  */

21 public class NonInteractiveInstall
22 {
23     public NonInteractiveInstall(String JavaDoc[] args)
24     {
25         String JavaDoc installDir = args[1];
26
27         installer = new Install();
28
29         OperatingSystem os = OperatingSystem.getOperatingSystem();
30         OperatingSystem.OSTask[] osTasks = os.getOSTasks(installer);
31
32         for(int i = 2; i < args.length; i++)
33         {
34             String JavaDoc arg = args[i];
35             int index = arg.indexOf('=');
36             if(index == -1)
37             {
38                 System.err.println("Invalid parameter: " + arg);
39                 continue;
40             }
41
42             String JavaDoc taskName = arg.substring(0,index);
43             String JavaDoc taskDir = arg.substring(index + 1);
44             for(int j = 0; j < osTasks.length; j++)
45             {
46                 OperatingSystem.OSTask osTask = osTasks[j];
47                 if(osTask.getName().equals(taskName))
48                 {
49                     if(taskDir.equals("off"))
50                         osTask.setEnabled(false);
51                     else
52                     {
53                         osTask.setEnabled(true);
54                         osTask.setDirectory(taskDir);
55                     }
56                     break;
57                 }
58             }
59         }
60
61         int compCount = installer.getIntegerProperty("comp.count");
62         Vector JavaDoc components = new Vector JavaDoc(compCount);
63
64         for(int i = 0; i < compCount; i++)
65         {
66             String JavaDoc fileset = installer.getProperty("comp." + i + ".fileset");
67
68             String JavaDoc osDep = installer.getProperty("comp." + i + ".os");
69             if(osDep != null)
70             {
71                 if(!os.getClass().getName().endsWith(osDep))
72                 {
73                     continue;
74                 }
75             }
76
77             components.addElement(fileset);
78         }
79
80         //
81

82         ConsoleProgress progress = new ConsoleProgress();
83         InstallThread thread = new InstallThread(
84             installer,progress,installDir,osTasks,
85             0 /* XXX */,components);
86         thread.start();
87     }
88
89     // private members
90
private Install installer;
91 }
92
Popular Tags