changeset 466:922020047e98

Refactor Object launchType; to LaunchDesc launchType; in JNLPFile
author Adam Domurad <adomurad@redhat.com>
date Tue, 10 Jul 2012 10:35:52 -0400
parents f4f26edeaba6
children 1ced587420b8
files ChangeLog netx/net/sourceforge/jnlp/AppletDesc.java netx/net/sourceforge/jnlp/ApplicationDesc.java netx/net/sourceforge/jnlp/InstallerDesc.java netx/net/sourceforge/jnlp/JNLPFile.java netx/net/sourceforge/jnlp/Parser.java netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
diffstat 7 files changed, 33 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jul 09 16:22:05 2012 -0400
+++ b/ChangeLog	Tue Jul 10 10:35:52 2012 -0400
@@ -1,3 +1,19 @@
+2012-07-10  Adam Domurad  <adomurad@redhat.com>
+
+	Refactor JNLPFile#launchType into its own interface type (as opposed to
+	Object), LaunchDesc.
+	* netx/net/sourceforge/jnlp/AppletDesc.java: Add override annotation to
+	getMainClass().
+	* netx/net/sourceforge/jnlp/ApplicationDesc.java: Same as above
+	* netx/net/sourceforge/jnlp/InstallerDesc.java: Same as above
+	* netx/net/sourceforge/jnlp/JNLPFile.java: Make launchType a 
+	LaunchDesc object. Update getLaunchInfo() accordingly.
+	* netx/net/sourceforge/jnlp/LaunchDesc.java: New launch description. 
+	* netx/net/sourceforge/jnlp/Parser.java
+	(getLauncher): Return type changed to LaunchDesc
+	* netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: Replace
+	occurences of instanceof with respect to launchType.
+
 2012-07-09  Deepak Bhole <dbhole@redhat.com>
 
 	* configure.ac: Bumped release number to 1.4pre
--- a/netx/net/sourceforge/jnlp/AppletDesc.java	Mon Jul 09 16:22:05 2012 -0400
+++ b/netx/net/sourceforge/jnlp/AppletDesc.java	Tue Jul 10 10:35:52 2012 -0400
@@ -25,7 +25,7 @@
  * @author <a href="mailto:jmaxwell@users.sourceforge.net">Jon A. Maxwell (JAM)</a> - initial author
  * @version $Revision: 1.8 $
  */
-public class AppletDesc {
+public class AppletDesc implements LaunchDesc {
 
     /** the applet name */
     private String name;
@@ -75,6 +75,7 @@
     /**
      * Returns the main class name in the dot-separated form (eg: foo.bar.Baz)
      */
+    @Override
     public String getMainClass() {
         return mainClass;
     }
--- a/netx/net/sourceforge/jnlp/ApplicationDesc.java	Mon Jul 09 16:22:05 2012 -0400
+++ b/netx/net/sourceforge/jnlp/ApplicationDesc.java	Tue Jul 10 10:35:52 2012 -0400
@@ -24,7 +24,7 @@
  * @author <a href="mailto:jmaxwell@users.sourceforge.net">Jon A. Maxwell (JAM)</a> - initial author
  * @version $Revision: 1.7 $
  */
-public class ApplicationDesc {
+public class ApplicationDesc implements LaunchDesc {
 
     /** the main class name and package */
     private String mainClass;
@@ -46,6 +46,7 @@
     /**
      * Returns the main class name
      */
+    @Override
     public String getMainClass() {
         return mainClass;
     }
--- a/netx/net/sourceforge/jnlp/InstallerDesc.java	Mon Jul 09 16:22:05 2012 -0400
+++ b/netx/net/sourceforge/jnlp/InstallerDesc.java	Tue Jul 10 10:35:52 2012 -0400
@@ -22,7 +22,7 @@
  * @author <a href="mailto:jmaxwell@users.sourceforge.net">Jon A. Maxwell (JAM)</a> - initial author
  * @version $Revision: 1.6 $
  */
-public class InstallerDesc {
+public class InstallerDesc implements LaunchDesc {
 
     /** the main class name and package. */
     private String mainClass;
@@ -39,6 +39,7 @@
     /**
      * Returns the main class name and package.
      */
+    @Override
     public String getMainClass() {
         return mainClass;
     }
--- a/netx/net/sourceforge/jnlp/JNLPFile.java	Mon Jul 09 16:22:05 2012 -0400
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java	Tue Jul 10 10:35:52 2012 -0400
@@ -91,7 +91,7 @@
     protected ResourcesDesc sharedResources = new ResourcesDesc(this, null, null, null);
 
     /** the application description */
-    protected Object launchType;
+    protected LaunchDesc launchType;
 
     /** the component description */
     protected ComponentDesc component;
@@ -446,7 +446,7 @@
      * Returns an object of one of the following types: AppletDesc,
      * ApplicationDesc and InstallerDesc
      */
-    public Object getLaunchInfo() {
+    public LaunchDesc getLaunchInfo() {
         return launchType;
     }
 
--- a/netx/net/sourceforge/jnlp/Parser.java	Mon Jul 09 16:22:05 2012 -0400
+++ b/netx/net/sourceforge/jnlp/Parser.java	Tue Jul 10 10:35:52 2012 -0400
@@ -609,7 +609,7 @@
      * @param parent the parent node
      * @throws ParseException if the JNLP file is invalid
      */
-    public Object getLauncher(Node parent) throws ParseException {
+    public LaunchDesc getLauncher(Node parent) throws ParseException {
         // check for other than one application type
         if (1 < getChildNodes(parent, "applet-desc").length
                 + getChildNodes(parent, "application-desc").length
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java	Mon Jul 09 16:22:05 2012 -0400
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java	Tue Jul 10 10:35:52 2012 -0400
@@ -67,6 +67,7 @@
 import net.sourceforge.jnlp.JNLPFile;
 import net.sourceforge.jnlp.JNLPMatcher;
 import net.sourceforge.jnlp.JNLPMatcherException;
+import net.sourceforge.jnlp.LaunchDesc;
 import net.sourceforge.jnlp.LaunchException;
 import net.sourceforge.jnlp.ParseException;
 import net.sourceforge.jnlp.PluginBridge;
@@ -636,8 +637,7 @@
 
                 // If jar with main class was not found and there are no more
                 // available jars, throw a LaunchException
-                if (file.getLaunchInfo() instanceof AppletDesc ||
-                    file.getLaunchInfo() instanceof ApplicationDesc) {
+                if (file.getLaunchInfo() != null) {
                     if (!foundMainJar
                             && (available == null || available.size() == 0))
                         throw new LaunchException(file, null, R("LSFatal"),
@@ -729,17 +729,14 @@
      */
     private void checkForMain(List<JARDesc> jars) throws LaunchException {
 
+        // Check launch info
         if (mainClass == null) {
-            Object obj = file.getLaunchInfo();
+            LaunchDesc launchDesc = file.getLaunchInfo();
+            if (launchDesc == null) {
+                return;
+            }
 
-            if (obj instanceof ApplicationDesc) {
-                ApplicationDesc ad = (ApplicationDesc) file.getLaunchInfo();
-                mainClass = ad.getMainClass();
-            } else if (obj instanceof AppletDesc) {
-                AppletDesc ad = (AppletDesc) file.getLaunchInfo();
-                mainClass = ad.getMainClass();
-            } else
-                return;
+            mainClass = launchDesc.getMainClass();
         }
 
         // The main class may be specified in the manifest