[jboss-cvs] JBossAS SVN: r96328 - in projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework: vfs and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 13 04:28:31 EST 2009


Author: alesj
Date: 2009-11-13 04:28:31 -0500 (Fri, 13 Nov 2009)
New Revision: 96328

Modified:
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java
Log:
Extract bundle lookup.
TODO Thomas - fix deployer service; probably needs new snapshot deploy.

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java	2009-11-13 08:29:51 UTC (rev 96327)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java	2009-11-13 09:28:31 UTC (rev 96328)
@@ -35,7 +35,6 @@
 import org.jboss.osgi.framework.bundle.OSGiBundleManager;
 import org.jboss.osgi.framework.plugins.DeployerServicePlugin;
 import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
-import org.jboss.osgi.spi.util.BundleInfo;
 import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -86,10 +85,13 @@
       return delegate.createDeployment(file);
    }
 
+/*
+   // FIXME
    public Deployment createDeployment(BundleInfo info)
    {
       return delegate.createDeployment(info);
    }
+*/
 
    public void deploy(Deployment[] bundleDeps) throws BundleException
    {

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java	2009-11-13 08:29:51 UTC (rev 96327)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/vfs/BundleVFSContext.java	2009-11-13 09:28:31 UTC (rev 96328)
@@ -41,27 +41,17 @@
  */
 public class BundleVFSContext extends AbstractVFSContext
 {
-   private String host;
+   private String name;
    private VirtualFileHandler root;
 
    public BundleVFSContext(URI rootURI, OSGiBundleManager manager) throws IOException
    {
       super(rootURI);
 
-      host = rootURI.getHost();
-      long id = Long.parseLong(host);
-      if (id == 0)
-         throw new IllegalArgumentException("Cannot handle system bundle, it's too abstract.");
+      name = parseName(rootURI);
 
-      AbstractBundleState abs = manager.getBundleById(id);
-      if (abs == null)
-         throw new IllegalArgumentException("No such bundle: " + id);
-
-      String path = rootURI.getPath();
-      if (path == null)
-         path = "";
-
-      OSGiBundleState bundleState = OSGiBundleState.class.cast(abs); // should be able to cast, as it's not system
+      OSGiBundleState bundleState = getBundleState(rootURI, manager);
+      String path = parsePath(rootURI);
       URL resource = bundleState.getEntry(path); // permission check
       if (resource == null)
          throw new IllegalArgumentException("No such resource: " + path + " in bundle: " + bundleState);
@@ -76,9 +66,56 @@
       root = new BundleHandler(this, duRoot, duFile, bundleState);
    }
 
+   /**
+    * Parse context name from uri.
+    *
+    * @param uri the uri
+    * @return parsed context's name
+    */
+   protected String parseName(URI uri)
+   {
+      return uri.getHost();
+   }
+
+   /**
+    * Parse resource path from uri.
+    *
+    * @param uri the uri
+    * @return parsed resource path
+    */
+   protected String parsePath(URI uri)
+   {
+      String path = uri.getPath();
+      if (path == null)
+         path = "";
+
+      return path;
+   }
+
+   /**
+    * Get bundle state.
+    *
+    * @param uri the uri
+    * @param manager the osgi manager
+    * @return bundle state or exception if no such bundle exists
+    */
+   protected OSGiBundleState getBundleState(URI uri, OSGiBundleManager manager)
+   {
+      String host = uri.getHost();
+      long id = Long.parseLong(host);
+      if (id == 0)
+         throw new IllegalArgumentException("Cannot handle system bundle, it's too abstract.");
+
+      AbstractBundleState abs = manager.getBundleById(id);
+      if (abs == null)
+         throw new IllegalArgumentException("No such bundle: " + id);
+
+      return OSGiBundleState.class.cast(abs); // should be able to cast, as it's not system
+   }
+
    public String getName()
    {
-      return host;
+      return name;
    }
 
    public VirtualFileHandler getRoot() throws IOException




More information about the jboss-cvs-commits mailing list