[izpack-changes] r1675 - in izpack-src/trunk/src/lib/com/izforge/izpack: . compiler installer

noreply at berlios.de noreply at berlios.de
Fri Jan 5 09:00:38 CET 2007


Author: dreil
Date: 2007-01-05 09:00:33 +0100 (Fri, 05 Jan 2007)
New Revision: 1675

Added:
   izpack-src/trunk/src/lib/com/izforge/izpack/installer/IUnpacker.java
   izpack-src/trunk/src/lib/com/izforge/izpack/installer/UnpackerFactory.java
Modified:
   izpack-src/trunk/src/lib/com/izforge/izpack/Info.java
   izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java
   izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java
   izpack-src/trunk/src/lib/com/izforge/izpack/installer/Unpacker.java
Log:
Completed option to select Unpacker implementation



Modified: izpack-src/trunk/src/lib/com/izforge/izpack/Info.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/Info.java	2007-01-04 13:17:58 UTC (rev 1674)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/Info.java	2007-01-05 08:00:33 UTC (rev 1675)
@@ -66,6 +66,8 @@
      */
     private String packDecoderClassName = null;
     
+    private String unpackerClassName = null;
+    
     /** The constructor, deliberatly void. */
     public Info()
     {
@@ -349,4 +351,16 @@
     {
         this.packDecoderClassName = packDecoderClassName;
     }
+
+    
+    public String getUnpackerClassName()
+    {
+        return unpackerClassName;
+    }
+
+    
+    public void setUnpackerClassName(String unpackerClassName)
+    {
+        this.unpackerClassName = unpackerClassName;
+    }
 }

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java	2007-01-04 13:17:58 UTC (rev 1674)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java	2007-01-05 08:00:33 UTC (rev 1675)
@@ -346,13 +346,14 @@
             XMLElement unpacker = root.getFirstChildNamed("unpacker");
             
             if (unpacker != null){
-                unpackerclassname = requireAttribute(unpacker, "class");
+                unpackerclassname = requireAttribute(unpacker, "class");                
             }        
         }
         compiler.initPackager(packagerclassname);  
         if (root != null){
             compiler.getPackager().addConfigurationInformation(root);
         }
+        compiler.addProperty("UNPACKER_CLASS", unpackerclassname);
         notifyCompilerListener("loadPackager", CompilerListener.END, data);        
     }
 
@@ -1293,6 +1294,9 @@
         XMLElement slfPath = root.getFirstChildNamed("summarylogfilepath");
         if (slfPath != null) info.setSummaryLogFilePath(requireContent(slfPath));
 
+        // look for an unpacker class
+        String unpackerclass = compiler.getProperty("UNPACKER_CLASS");
+        info.setUnpackerClassName(unpackerclass);
         compiler.setInfo(info);
         notifyCompilerListener("addInfo", CompilerListener.END, data);
     }

Added: izpack-src/trunk/src/lib/com/izforge/izpack/installer/IUnpacker.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/IUnpacker.java	2007-01-04 13:17:58 UTC (rev 1674)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/IUnpacker.java	2007-01-05 08:00:33 UTC (rev 1675)
@@ -0,0 +1,31 @@
+/*
+ * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
+ * 
+ * http://www.izforge.com/izpack/
+ * http://developer.berlios.de/projects/izpack/
+ * 
+ * Copyright 2007 Dennis Reil
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *     
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.izforge.izpack.installer;
+
+public interface IUnpacker extends Runnable
+{
+    /**
+     * Return the state of the operation.
+     * 
+     * @return true if the operation was successful, false otherwise.
+     */
+    public abstract boolean getResult();
+}
\ No newline at end of file

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java	2007-01-04 13:17:58 UTC (rev 1674)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/InstallerFrame.java	2007-01-05 08:00:33 UTC (rev 1675)
@@ -1198,9 +1198,13 @@
      * @param listener The installation listener.
      */
     public void install(AbstractUIProgressHandler listener)
-    {
+    {       
+        IUnpacker unpacker = UnpackerFactory.getUnpacker(this.installdata.info.getUnpackerClassName(), installdata, listener);
+        unpacker.run();
+        /*
         Unpacker unpacker = new Unpacker(installdata, listener);
         unpacker.start();
+        */
     }
 
     /**

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/installer/Unpacker.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/Unpacker.java	2007-01-04 13:17:58 UTC (rev 1674)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/Unpacker.java	2007-01-05 08:00:33 UTC (rev 1675)
@@ -43,7 +43,7 @@
  * @author Julien Ponge
  * @author Johannes Lehtinen
  */
-public class Unpacker extends Thread
+public class Unpacker extends Thread implements IUnpacker
 {
 
     /** The installdata. */
@@ -248,7 +248,9 @@
 
     }
 
-    /** The run method. */
+    /* (non-Javadoc)
+     * @see com.izforge.izpack.installer.IUnpacker#run()
+     */
     public void run()
     {
         addToInstances();
@@ -568,10 +570,8 @@
         }
     }
 
-    /**
-     * Return the state of the operation.
-     * 
-     * @return true if the operation was successful, false otherwise.
+    /* (non-Javadoc)
+     * @see com.izforge.izpack.installer.IUnpacker#getResult()
      */
     public boolean getResult()
     {

Added: izpack-src/trunk/src/lib/com/izforge/izpack/installer/UnpackerFactory.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/installer/UnpackerFactory.java	2007-01-04 13:17:58 UTC (rev 1674)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/installer/UnpackerFactory.java	2007-01-05 08:00:33 UTC (rev 1675)
@@ -0,0 +1,66 @@
+/*
+ * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
+ * 
+ * http://www.izforge.com/izpack/
+ * http://developer.berlios.de/projects/izpack/
+ * 
+ * Copyright 2007 Dennis Reil
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *     
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.izforge.izpack.installer;
+
+import java.lang.reflect.Constructor;
+
+import com.izforge.izpack.util.AbstractUIProgressHandler;
+import com.izforge.izpack.util.Debug;
+
+
+/**
+ * A Factory for getting unpacker instances. 
+ * 
+ * @author Dennis Reil, <Dennis.Reil at reddot.de>
+ */
+public abstract class UnpackerFactory
+{
+    /**
+     * Returns an instance of the desired unpacker class
+     * @param unpackerclassname
+     * @param installdata
+     * @param listener
+     * @return
+     */
+    public static IUnpacker getUnpacker(String unpackerclassname, AutomatedInstallData installdata, AbstractUIProgressHandler listener){
+        IUnpacker unpackerobj = null;
+        try
+        {
+            Class unpackerclass = Class.forName(unpackerclassname);
+            Class[] parametertypes = {AutomatedInstallData.class, AbstractUIProgressHandler.class};
+            Constructor unpackerconstructor = unpackerclass.getConstructor(parametertypes);
+            Object[] parameter = {installdata,listener};
+            unpackerobj = (IUnpacker) unpackerconstructor.newInstance(parameter);            
+        }        
+        catch (NoSuchMethodException e)
+        {
+            Debug.trace("Can't load unpacker: " + unpackerclassname);
+            Debug.trace("Unpacker doesn't implement the desired method");
+            Debug.trace(e);
+        }
+        catch (Exception e)
+        {
+            Debug.trace("Can't load unpacker: " + unpackerclassname);
+            Debug.trace(e);
+        }                
+        return unpackerobj;
+    }
+}




More information about the izpack-changes mailing list