1
package gnu.io.installer;
4
import java.util.Enumeration;
5
import java.util.prefs.*;
7
import gnu.io.installer.util.*;
10
public abstract class RXTXInstaller {
12
static Preferences sysPref = Preferences.systemRoot();
13
Preferences checkPref = null;
14
protected File jarFolder,libFolder;
15
InstallInstruction inst = new InstallInstruction();
17
public abstract void runPreProcess();
18
public abstract void runPostProcess();
21
public void install(){
22
initInstallation(RXTXInstaller.class);
25
for(Enumeration e = inst.getKeys();e.hasMoreElements();){
26
File f = (File)e.nextElement();
27
InstallUtil.installPart(sysPref,checkPref,inst.getPath(f),f);
34
protected void finishInstallation(){
35
if(checkPref == null) return;
37
checkPref.removeNode();
41
public InstallInstruction getInstallInstruction(){
45
public static RXTXInstaller getInstance() {
46
String osName = System.getProperty("os.name").toLowerCase();
47
if(osName.startsWith("mac")){
48
return new gnu.io.installer.macosx.MACOSXRXTXInstaller();
53
protected void initInstallation(Class rootClass){
55
if(rootClass == null) return;
57
Preferences.importPreferences(rootClass.getResourceAsStream("installer.pref"));
58
String checkPrefName = "/check";
59
checkPref = (sysPref.nodeExists(checkPrefName))?sysPref.node(checkPrefName):null;
62
System.out.println("Throwable "+t);
66
public void addLibResource(String path,String resource){
67
if(libFolder == null || path == null || resource == null) return;
68
File libFile = new File(libFolder,path);
69
addResource(libFile,resource);
72
public void addJarResource(String path,String resource){
73
if(jarFolder == null || path == null || resource == null) return;
74
File jarFile = new File(jarFolder,path);
75
addResource(jarFile,resource);
78
public void addResource(File path,String resource){
79
if(inst == null) inst = new InstallInstruction();
80
inst.addResource(path,resource);
83
public static void main(String args[]) {
84
RXTXInstaller installer = RXTXInstaller.getInstance();
85
if(installer != null) installer.install();