Revision: 5747
          http://jnode.svn.sourceforge.net/jnode/?rev=5747&view=rev
Author:   fduminy
Date:     2010-05-12 10:28:24 +0000 (Wed, 12 May 2010)

Log Message:
-----------
removed dependencies on PluginRegistryModel by using PluginRegistry interface 
instead

Signed-off-by: Fabien DUMINY <fabien.dum...@webmails.com>

Modified Paths:
--------------
    trunk/cli/src/commands/org/jnode/command/system/PluginCommand.java
    trunk/core/src/core/org/jnode/boot/InitJarProcessor.java
    trunk/core/src/core/org/jnode/boot/Main.java
    trunk/core/src/core/org/jnode/plugin/PluginRegistry.java
    trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java
    trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java

Modified: trunk/cli/src/commands/org/jnode/command/system/PluginCommand.java
===================================================================
--- trunk/cli/src/commands/org/jnode/command/system/PluginCommand.java  
2010-04-03 19:17:29 UTC (rev 5746)
+++ trunk/cli/src/commands/org/jnode/command/system/PluginCommand.java  
2010-05-12 10:28:24 UTC (rev 5747)
@@ -147,7 +147,7 @@
     }
 
     private void loadPlugin(String id, String version) throws PluginException {
-        mgr.getRegistry().loadPlugin(mgr.getLoaderManager(), id, version);
+        mgr.getRegistry().loadPlugin(mgr.getLoaderManager(), id, version, 
true); //resolve=true
         out.format(fmt_load, id, version);
     }
     
@@ -156,11 +156,11 @@
         final List<PluginReference> refs = reg.unloadPlugin(id);
         for (PluginReference ref : refs) {
             if (reg.getPluginDescriptor(ref.getId()) == null) {
-                reg.loadPlugin(mgr.getLoaderManager(), ref.getId(), 
ref.getVersion());
+                reg.loadPlugin(mgr.getLoaderManager(), ref.getId(), 
ref.getVersion(), true); //resolve=true
             }
         }
         if (reg.getPluginDescriptor(id) == null) {
-            reg.loadPlugin(mgr.getLoaderManager(), id, version);
+            reg.loadPlugin(mgr.getLoaderManager(), id, version, true); 
//resolve=true
         }
         out.format(fmt_reload, id, version);
     }

Modified: trunk/core/src/core/org/jnode/boot/InitJarProcessor.java
===================================================================
--- trunk/core/src/core/org/jnode/boot/InitJarProcessor.java    2010-04-03 
19:17:29 UTC (rev 5746)
+++ trunk/core/src/core/org/jnode/boot/InitJarProcessor.java    2010-05-12 
10:28:24 UTC (rev 5747)
@@ -33,7 +33,7 @@
 import org.jnode.plugin.PluginDescriptor;
 import org.jnode.plugin.PluginException;
 import org.jnode.plugin.PluginLoader;
-import org.jnode.plugin.model.PluginRegistryModel;
+import org.jnode.plugin.PluginRegistry;
 import org.jnode.system.BootLog;
 import org.jnode.system.MemoryResource;
 import org.jnode.util.JarBuffer;
@@ -72,7 +72,7 @@
      *
      * @param piRegistry
      */
-    public List<PluginDescriptor> loadPlugins(PluginRegistryModel piRegistry) {
+    public List<PluginDescriptor> loadPlugins(PluginRegistry piRegistry) {
         if (jbuf == null) {
             return null;
         }
@@ -86,7 +86,7 @@
                     // Load it
                     loader.setBuffer(entry.getValue());
                     final PluginDescriptor descr = piRegistry.loadPlugin(
-                        loader, "", "", false);
+                        loader, "", "", false); //resolve=false
                     descriptors.add(descr);
                 } catch (PluginException ex) {
                     BootLog.error("Cannot load " + name, ex);

Modified: trunk/core/src/core/org/jnode/boot/Main.java
===================================================================
--- trunk/core/src/core/org/jnode/boot/Main.java        2010-04-03 19:17:29 UTC 
(rev 5746)
+++ trunk/core/src/core/org/jnode/boot/Main.java        2010-05-12 10:28:24 UTC 
(rev 5747)
@@ -23,16 +23,16 @@
 import java.lang.reflect.Method;
 import java.util.List;
 
+import org.jnode.annotation.LoadStatics;
+import org.jnode.annotation.SharedStatics;
+import org.jnode.annotation.Uninterruptible;
 import org.jnode.plugin.PluginDescriptor;
 import org.jnode.plugin.PluginManager;
+import org.jnode.plugin.PluginRegistry;
 import org.jnode.plugin.manager.DefaultPluginManager;
-import org.jnode.plugin.model.PluginRegistryModel;
 import org.jnode.system.BootLog;
 import org.jnode.vm.Unsafe;
 import org.jnode.vm.VmSystem;
-import org.jnode.annotation.LoadStatics;
-import org.jnode.annotation.SharedStatics;
-import org.jnode.annotation.Uninterruptible;
 
 /**
  * First class that is executed when JNode boots.
@@ -49,7 +49,7 @@
     /**
      *  Initialized in org.jnode.build.x86.BootImageBuilder.initMain().
      */
-    private static PluginRegistryModel pluginRegistry;
+    private static PluginRegistry pluginRegistry;
 
     /**
      * First java entry point after the assembler kernel has booted.

Modified: trunk/core/src/core/org/jnode/plugin/PluginRegistry.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/PluginRegistry.java    2010-04-03 
19:17:29 UTC (rev 5746)
+++ trunk/core/src/core/org/jnode/plugin/PluginRegistry.java    2010-05-12 
10:28:24 UTC (rev 5747)
@@ -59,10 +59,11 @@
      * @param loader
      * @param pluginId
      * @param pluginVersion
+     * @param resolve true to resolve the plugin dependencies, false otherwise
      * @return The descriptor of the loaded plugin.
      * @throws PluginException
      */
-    public PluginDescriptor loadPlugin(PluginLoader loader, String pluginId, 
String pluginVersion)
+    public PluginDescriptor loadPlugin(PluginLoader loader, String pluginId, 
String pluginVersion, boolean resolve)
         throws PluginException;
 
     /**

Modified: trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java
===================================================================
--- trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java 
2010-04-03 19:17:29 UTC (rev 5746)
+++ trunk/core/src/core/org/jnode/plugin/model/PluginRegistryModel.java 
2010-05-12 10:28:24 UTC (rev 5747)
@@ -288,29 +288,27 @@
     }
 
     /**
-     * Load a plugin from a given loader.
-     *
-     * @param loader
-     * @param pluginId
-     * @param pluginVersion
-     * @return The descriptor of the loaded plugin.
-     * @throws PluginException
+     * {...@inheritdoc}
      */
-    public PluginDescriptor loadPlugin(final PluginLoader loader, final String 
pluginId, final String pluginVersion)
+    public PluginDescriptor loadPlugin(final PluginLoader loader, final String 
pluginId, final String pluginVersion, boolean resolve)
         throws PluginException {
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             sm.checkPermission(PluginSecurityConstants.LOAD_PERM);
         }
         // Load the requested plugin
-        final HashMap<String, PluginDescriptorModel> descriptors = new 
HashMap<String, PluginDescriptorModel>();
-        final PluginDescriptorModel descr = loadPlugin(loader, pluginId, 
pluginVersion, false);
-        descriptors.put(descr.getId(), descr);
-        // Load the dependent plugins
-        loadDependencies(loader, descr, descriptors);
-
-        // Resolve the loaded descriptors.
-        resolveDescriptors(descriptors.values());
+        final PluginDescriptorModel descr = loadPluginImpl(loader, pluginId, 
pluginVersion);
+        
+        if (resolve) {
+               final HashMap<String, PluginDescriptorModel> descriptors = new 
HashMap<String, PluginDescriptorModel>();
+               descriptors.put(descr.getId(), descr);
+               // Load the dependent plugins
+               loadDependencies(loader, descr, descriptors);
+       
+               // Resolve the loaded descriptors.
+               resolveDescriptors(descriptors.values());
+        }
+        
         return descr;
     }
 
@@ -343,13 +341,13 @@
         if (descriptors.containsKey(id)) {
             return;
         }
-        final PluginDescriptorModel descr = loadPlugin(loader, id, version, 
false);
+        final PluginDescriptorModel descr = loadPluginImpl(loader, id, 
version);
         descriptors.put(descr.getId(), descr);
         loadDependencies(loader, descr, descriptors);
     }
 
     /**
-     * Load a plugin from a given loader.
+     * Load a plugin from a given loader but doesn't resolve its dependencies.
      *
      * @param loader
      * @param pluginId
@@ -357,12 +355,8 @@
      * @return The descriptor of the loaded plugin.
      * @throws PluginException
      */
-    public PluginDescriptorModel loadPlugin(final PluginLoader loader, final 
String pluginId,
-                                            final String pluginVersion, 
boolean resolve) throws PluginException {
-        final SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            sm.checkPermission(PluginSecurityConstants.LOAD_PERM);
-        }
+    private final PluginDescriptorModel loadPluginImpl(final PluginLoader 
loader, final String pluginId,
+                                            final String pluginVersion) throws 
PluginException {
         final PluginRegistryModel registry = this;
         final PluginJar pluginJar;
         try {
@@ -386,11 +380,7 @@
                 throw new PluginException(ex);
             }
         }
-        final PluginDescriptorModel descr = pluginJar.getDescriptorModel();
-        if (resolve) {
-            descr.resolve(this);
-        }
-        return descr;
+        return pluginJar.getDescriptorModel();
     }
 
     /**

Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java
===================================================================
--- trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java       
2010-04-03 19:17:29 UTC (rev 5746)
+++ trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java       
2010-05-12 10:28:24 UTC (rev 5747)
@@ -225,7 +225,7 @@
                 PluginManager mgr = InitialNaming.lookup(PluginManager.NAME);
                 PluginRegistry reg = mgr.getRegistry();
                 if (reg.getPluginDescriptor(id) == null) {
-                    reg.loadPlugin(mgr.getLoaderManager(), id, ver);
+                    reg.loadPlugin(mgr.getLoaderManager(), id, ver, true); 
//resolve=true
                 }
             } catch (Exception ex) {
                 System.out.println(ex.getMessage());


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------

_______________________________________________
Jnode-svn-commits mailing list
Jnode-svn-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits

Reply via email to