[jboss-osgi-commits] JBoss-OSGI SVN: r97934 - in projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src: main/java/org/jboss/osgi/framework/deployers and 7 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Thu Dec 17 03:47:53 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-12-17 03:47:52 -0500 (Thu, 17 Dec 2009)
New Revision: 97934

Modified:
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiBundleStateDeployer.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateRemoveDeployer.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/FrameworkTest.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java
   projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java
Log:
Bundle.update() - WIP

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -77,9 +77,6 @@
    /** The bundle manager */
    private OSGiBundleManager bundleManager;
 
-   /** The osgi metadata */
-   private OSGiMetaData osgiMetaData;
-
    /** The bundle context */
    private BundleContext bundleContext;
 
@@ -89,27 +86,7 @@
    /** The bundle state */
    private AtomicInteger state = new AtomicInteger(Bundle.UNINSTALLED);
 
-   /** The cached symbolic name */
-   private String symbolicName;
-   
-   /** The cached version */
-   private Version version;
-
    /**
-    * Create a new BundleState for the system bundle.
-    * 
-    * @param osgiMetaData the osgi metadata
-    * @throws IllegalArgumentException for a null parameter
-    */
-   AbstractBundleState(OSGiMetaData osgiMetaData)
-   {
-      if (osgiMetaData == null)
-         throw new IllegalArgumentException("Null osgi metadata");
-
-      this.osgiMetaData = osgiMetaData;
-   }
-
-   /**
     * Get the bundleManager.
     * 
     * @return the bundleManager.
@@ -118,26 +95,21 @@
    {
       if (bundleManager == null)
          throw new IllegalStateException("Bundle not installed: " + getCanonicalName());
-      
+
       return bundleManager;
    }
 
    public String getSymbolicName()
    {
+      String symbolicName = getOSGiMetaData().getBundleSymbolicName();
       if (symbolicName == null)
-      {
-         symbolicName = osgiMetaData.getBundleSymbolicName();
-         if (symbolicName == null)
-            throw new IllegalStateException("Cannot obtain " + Constants.BUNDLE_SYMBOLICNAME);
-      }
+         throw new IllegalStateException("Cannot obtain " + Constants.BUNDLE_SYMBOLICNAME);
       return symbolicName;
    }
 
    public Version getVersion()
    {
-      if (version == null)
-         version = osgiMetaData.getBundleVersion();
-      
+      Version version = getOSGiMetaData().getBundleVersion();
       return version;
    }
 
@@ -202,7 +174,7 @@
       List<Bundle> bundles = new ArrayList<Bundle>(bundleStates.size());
       for (AbstractBundleState bundleState : bundleStates)
          bundles.add(bundleState.getBundleInternal());
-      
+
       return bundles.toArray(new Bundle[bundles.size()]);
    }
 
@@ -221,10 +193,7 @@
     * 
     * @return the osgiMetaData.
     */
-   public OSGiMetaData getOSGiMetaData()
-   {
-      return osgiMetaData;
-   }
+   public abstract OSGiMetaData getOSGiMetaData();
 
    @SuppressWarnings("rawtypes")
    public Dictionary getHeaders()
@@ -376,7 +345,7 @@
       }
 
       if (references.isEmpty())
-         return null;      
+         return null;
       return references.toArray(new ServiceReference[references.size()]);
    }
 
@@ -510,13 +479,6 @@
       stop(0);
    }
 
-   public void update() throws BundleException
-   {
-      checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
-      // [TODO] update
-      throw new UnsupportedOperationException("update");
-   }
-
    void uninstallInternal()
    {
       changeState(Bundle.UNINSTALLED);
@@ -621,8 +583,19 @@
     */
    public void changeState(int state)
    {
+      changeState(state, true);
+   }
+
+   /**
+    * Change the state of the bundle
+    * 
+    * @param state the new state
+    * @param fireEvent if true the state change fires an event
+    */
+   public void changeState(int state, boolean fireEvent)
+   {
       int previous = getState();
-      
+
       // Get the corresponding bundle event type
       int bundleEventType;
       switch (state)
@@ -658,7 +631,7 @@
          default:
             throw new IllegalArgumentException("Unknown bundle state: " + state);
       }
-      
+
       // Invoke the bundle lifecycle interceptors
       if (getBundleManager().isFrameworkActive() && getBundleId() != 0)
       {
@@ -666,12 +639,12 @@
          if (plugin != null)
             plugin.handleStateChange(state, getBundleInternal());
       }
-      
+
       this.state.set(state);
       log.debug(this + " change state=" + ConstantsHelper.bundleState(state));
 
       // Fire the bundle event
-      if (getBundleManager().isFrameworkActive())
+      if (fireEvent == true && getBundleManager().isFrameworkActive())
       {
          FrameworkEventsPlugin plugin = getBundleManager().getPlugin(FrameworkEventsPlugin.class);
          plugin.fireBundleEvent(this, bundleEventType);
@@ -735,13 +708,13 @@
    {
       if (bundle == null)
          throw new IllegalArgumentException("Null bundle");
-      
+
       if (bundle instanceof OSGiBundleWrapper)
          bundle = ((OSGiBundleWrapper)bundle).getBundleState();
-   
+
       if (bundle instanceof AbstractBundleState == false)
          throw new IllegalArgumentException("Not an AbstractBundleState: " + bundle);
-   
+
       return (AbstractBundleState)bundle;
    }
 }

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -92,6 +92,7 @@
 import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Filter;
@@ -594,7 +595,7 @@
     * @return the bundle state
     * @throws BundleException for any error
     */
-   public AbstractBundleState installBundle(URL url) throws BundleException
+   public OSGiBundleState installBundle(URL url) throws BundleException
    {
       if (url == null)
          throw new BundleException("Null url");
@@ -610,7 +611,7 @@
     * @return the bundle state
     * @throws BundleException for any error
     */
-   public AbstractBundleState installBundle(String location, InputStream input) throws BundleException
+   public OSGiBundleState installBundle(String location, InputStream input) throws BundleException
    {
       if (location == null)
          throw new BundleException("Null location");
@@ -620,23 +621,7 @@
       // Get the location URL
       if (input != null)
       {
-         try
-         {
-            BundleStoragePlugin plugin = getPlugin(BundleStoragePlugin.class);
-            String path = plugin.getStorageDir(getSystemBundle()).getCanonicalPath();
-
-            // [TODO] do properly
-            File file = new File(path + "/bundle-" + System.currentTimeMillis() + ".jar");
-            FileOutputStream fos = new FileOutputStream(file);
-            VFSUtils.copyStream(input, fos);
-            fos.close();
-
-            locationURL = file.toURI().toURL();
-         }
-         catch (IOException ex)
-         {
-            throw new BundleException("Cannot store bundle from input stream", ex);
-         }
+         locationURL = getBundleStorageLocation(input);
       }
       else
       {
@@ -657,6 +642,28 @@
       return install(root, location, false);
    }
 
+   private URL getBundleStorageLocation(InputStream input) throws BundleException
+   {
+      try
+      {
+         BundleStoragePlugin plugin = getPlugin(BundleStoragePlugin.class);
+         String path = plugin.getStorageDir(getSystemBundle()).getCanonicalPath();
+
+         // [TODO] do properly
+         File file = new File(path + "/bundle-" + System.currentTimeMillis() + ".jar");
+         FileOutputStream fos = new FileOutputStream(file);
+         VFSUtils.copyStream(input, fos);
+         fos.close();
+
+         URL locationURL = file.toURI().toURL();
+         return locationURL;
+      }
+      catch (IOException ex)
+      {
+         throw new BundleException("Cannot store bundle from input stream", ex);
+      }
+   }
+
    /**
     * Install a bundle from a virtual file.
     *  
@@ -665,7 +672,7 @@
     * @return the bundle state
     * @throws BundleException for any error
     */
-   public AbstractBundleState installBundle(VirtualFile root) throws BundleException
+   public OSGiBundleState installBundle(VirtualFile root) throws BundleException
    {
       return install(root, root.toString(), false);
    }
@@ -673,7 +680,7 @@
    /*
     * Installs a bundle from the given virtual file.
     */
-   private AbstractBundleState install(VirtualFile root, String location, boolean autoStart) throws BundleException
+   private OSGiBundleState install(VirtualFile root, String location, boolean autoStart) throws BundleException
    {
       if (location == null)
          throw new IllegalArgumentException("Null location");
@@ -693,7 +700,7 @@
     * @return the bundle state
     * @throws BundleException for any error
     */
-   public AbstractBundleState installBundle(Deployment dep) throws BundleException
+   public OSGiBundleState installBundle(Deployment dep) throws BundleException
    {
       // Create the deployment and deploy it
       try
@@ -731,38 +738,98 @@
       }
    }
 
-   private URL getLocationURL(String location) throws BundleException
+   /**
+    * Updates a bundle from an InputStream. 
+    */
+   public void updateBundle(OSGiBundleState bundleState, InputStream in) throws BundleException
    {
-      // Try location as URL
-      URL url = null;
-      try
+      // If the specified InputStream is null, the Framework must create the InputStream from which to read the updated bundle by interpreting, 
+      // in an implementation dependent manner, this bundle's Bundle-UpdateLocation Manifest header, if present, or this bundle's original location.
+      URL updateURL = bundleState.getOSGiMetaData().getBundleUpdateLocation();
+      if (in == null)
       {
-         url = new URL(location);
+         try
+         {
+            if (updateURL == null)
+               throw new IllegalStateException("Cannot obtain Bundle-UpdateLocation for: " + bundleState);
+
+            in = updateURL.openStream();
+         }
+         catch (IOException ex)
+         {
+            throw new BundleException("Cannot obtain update input stream for: " + bundleState, ex);
+         }
       }
-      catch (MalformedURLException e)
+
+      // If this bundle's state is ACTIVE, it must be stopped before the update and started after the update successfully completes. 
+      boolean activeBeforeUpdate = (bundleState.getState() == Bundle.ACTIVE);
+
+      // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown. 
+      if (bundleState.getState() == Bundle.UNINSTALLED)
+         throw new IllegalStateException("Bundle already uninstalled: " + this);
+
+      // If this bundle has exported any packages that are imported by another bundle, these packages must not be updated. 
+      // Instead, the previous package version must remain exported until the PackageAdmin.refreshPackages method has been 
+      // has been called or the Framework is relaunched. 
+
+      // If this bundle's state is ACTIVE, STARTING  or STOPPING, this bundle is stopped as described in the Bundle.stop method. 
+      // If Bundle.stop throws an exception, the exception is rethrown terminating the update.
+      if (bundleState.getState() == Bundle.ACTIVE || bundleState.getState() == Bundle.STARTING || bundleState.getState() == Bundle.STOPPING)
       {
-         // ignore
+         stopBundle(bundleState);
       }
 
-      // Try location as File
-      if (url == null)
+      // The updated version of this bundle is read from the input stream and installed. 
+      // If the Framework is unable to install the updated version of this bundle, the original version of this bundle must be restored 
+      // and a BundleException must be thrown after completion of the remaining steps.
+      String location = (updateURL != null ? updateURL.toExternalForm() : bundleState.getCanonicalName() + "/update");
+      OSGiBundleState updatedBundleState = null;
+      BundleException throwAfterUpdate = null;
+      try
       {
-         try
+         URL storageLocation = getBundleStorageLocation(in);
+         VirtualFile root = VFS.getRoot(storageLocation);
+         
+         BundleInfo info = BundleInfo.createBundleInfo(root, location);
+         Deployment dep = DeploymentFactory.createDeployment(info);
+         dep.addAttachment(OSGiBundleState.class, bundleState);
+         dep.setBundleUpdate(true);
+         dep.setAutoStart(false);
+
+         updatedBundleState = installBundle(dep);
+      }
+      catch (Exception ex)
+      {
+         if (ex instanceof BundleException)
+            throwAfterUpdate = (BundleException)ex;
+         else
+            throwAfterUpdate = new BundleException("Cannot install updated bundle from: " + location, ex);
+         
+         if (activeBeforeUpdate)
          {
-            File file = new File(location);
-            if (file.exists())
-               url = file.toURI().toURL();
+            startBundle(bundleState);
          }
-         catch (MalformedURLException e)
+      }
+
+      // If the updated version of this bundle was successfully installed, a bundle event of type BundleEvent.UPDATED is fired
+      if (updatedBundleState != null)
+      {
+         FrameworkEventsPlugin plugin = getPlugin(FrameworkEventsPlugin.class);
+         plugin.fireBundleEvent(updatedBundleState, BundleEvent.UPDATED);
+
+         // If this bundle's state was originally ACTIVE, the updated bundle is started as described in the Bundle.start method. 
+         // If Bundle.start throws an exception, a Framework event of type FrameworkEvent.ERROR is fired containing the exception
+         if (activeBeforeUpdate)
          {
-            // ignore
+            startBundle(updatedBundleState);
          }
       }
 
-      if (url == null)
-         throw new BundleException("Unable to handle location=" + location);
-
-      return url;
+      // A BundleException must be thrown after completion of the remaining steps
+      if (throwAfterUpdate != null)
+      {
+         throw throwAfterUpdate;
+      }
    }
 
    /**
@@ -823,8 +890,18 @@
       Deployment dep = unit.getAttachment(Deployment.class);
       String location = (dep != null ? dep.getLocation() : unit.getName());
 
-      OSGiBundleState bundleState = new OSGiBundleState(location, osgiMetaData, unit);
-      addBundle(bundleState);
+      // In case of Bundle.update() the OSGiBundleState should be attached
+      // we add the DeploymentUnit 
+      OSGiBundleState bundleState = (dep != null ? dep.getAttachment(OSGiBundleState.class) : null);
+      if (bundleState != null)
+         bundleState.addDeploymentUnit(unit);
+
+      // Create a new OSGiBundleState and add it to the manager
+      if (bundleState == null)
+      {
+         bundleState = new OSGiBundleState(location, unit);
+         addBundle(bundleState);
+      }
       return bundleState;
    }
 
@@ -867,7 +944,16 @@
       bundleState.setBundleManager(this);
       bundles.add(bundleState);
 
-      bundleState.changeState(Bundle.INSTALLED);
+      // Only fire the INSTALLED event if this is not an update
+      boolean fireEvent = true;
+      if (bundleState instanceof OSGiBundleState)
+      {
+         DeploymentUnit unit = ((OSGiBundleState)bundleState).getDeploymentUnit();
+         Deployment dep = unit.getAttachment(Deployment.class);
+         fireEvent = (dep == null || dep.isBundleUpdate() == false);
+      }
+      
+      bundleState.changeState(Bundle.INSTALLED, fireEvent);
 
       // Add the bundle to the resolver
       // Note, plugins are not registered when the system bundle is added 
@@ -887,6 +973,8 @@
    private void validateBundle(AbstractBundleState bundleState)
    {
       OSGiMetaData metaData = bundleState.getOSGiMetaData();
+      if (metaData == null)
+         return;
 
       String symbolicName = metaData.getBundleSymbolicName();
       if (symbolicName == null)
@@ -1201,7 +1289,7 @@
          // Resolve all INSTALLED bundles through the PackageAdmin
          PackageAdmin packageAdmin = getPlugin(PackageAdminPlugin.class);
          packageAdmin.resolveBundles(null);
-         
+
          if (bundleState.getState() != Bundle.RESOLVED)
             throw new BundleException("Cannot resolve bundle: " + bundleState);
       }
@@ -1256,7 +1344,7 @@
       // [TODO] If this bundle is in the process of being activated or deactivated then this method must wait for activation or deactivation 
       // to complete before continuing. If this does not occur in a reasonable time, a BundleException is thrown to indicate this bundle 
       // was unable to be stopped.
-      
+
       // [TODO] If the STOP_TRANSIENT option is not set then then set this bundle's persistent autostart setting to to Stopped. 
       // When the Framework is restarted and this bundle's autostart setting is Stopped, this bundle must not be automatically started. 
 
@@ -1269,7 +1357,7 @@
          DeploymentUnit unit = bundleState.getDeploymentUnit();
          deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
          deployerClient.checkComplete(unit.getName());
-         
+
          // The potential BundleException is attached by the OSGiBundleActivatorDeployer
          BundleException stopEx = unit.removeAttachment(BundleException.class);
          if (stopEx != null)
@@ -1282,7 +1370,7 @@
          Throwable cause = ex.getCause();
          if (cause instanceof BundleException)
             throw (BundleException)cause;
-         
+
          throw new BundleException("Error stopping " + bundleState, (cause != null ? cause : ex));
       }
    }
@@ -1847,6 +1935,40 @@
       }
    }
 
+   private URL getLocationURL(String location) throws BundleException
+   {
+      // Try location as URL
+      URL url = null;
+      try
+      {
+         url = new URL(location);
+      }
+      catch (MalformedURLException e)
+      {
+         // ignore
+      }
+
+      // Try location as File
+      if (url == null)
+      {
+         try
+         {
+            File file = new File(location);
+            if (file.exists())
+               url = file.toURI().toURL();
+         }
+         catch (MalformedURLException e)
+         {
+            // ignore
+         }
+      }
+
+      if (url == null)
+         throw new BundleException("Unable to handle location=" + location);
+
+      return url;
+   }
+
    /**
     * Fire a framework error
     * 

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -26,6 +26,7 @@
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.Set;
+import java.util.Stack;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.jboss.dependency.spi.ControllerContext;
@@ -59,8 +60,8 @@
    /** The bundle location */
    private String location;
 
-   /** The deployment unit */
-   private DeploymentUnit unit;
+   /** The stack of deployment units */
+   private Stack<DeploymentUnit> units = new Stack<DeploymentUnit>();
 
    /**
     * Create a new BundleState.
@@ -70,22 +71,27 @@
     * @param unit the deployment unit
     * @throws IllegalArgumentException for a null parameter
     */
-   public OSGiBundleState(String location, OSGiMetaData osgiMetaData, DeploymentUnit unit)
+   public OSGiBundleState(String location, DeploymentUnit unit)
    {
-      super(osgiMetaData);
-      
       if (location == null)
          throw new IllegalArgumentException("Null bundle location");
       if (unit == null)
-          throw new IllegalArgumentException("Null deployment unit");
+         throw new IllegalArgumentException("Null deployment unit");
 
-      this.unit = unit;
       this.location = location;
+      this.bundleId = bundleIDGenerator.incrementAndGet();
       
-      this.bundleId = bundleIDGenerator.incrementAndGet();
-      unit.getMutableMetaData().addMetaData(unit, DeploymentUnit.class);
+      addDeploymentUnit(unit);
    }
 
+   @Override
+   public OSGiMetaData getOSGiMetaData()
+   {
+      DeploymentUnit unit = getDeploymentUnit();
+      OSGiMetaData metadata = unit.getAttachment(OSGiMetaData.class);
+      return metadata;
+   }
+
    protected Set<ControllerContext> getRegisteredContexts()
    {
       return getBundleManager().getRegisteredContext(this);
@@ -97,15 +103,30 @@
    }
 
    /**
-    * Get the unit.
+    * Get the DeploymentUnit that was added last.
     * 
-    * @return the unit.
+    * Initially, an OSGiBundleState is associated with just one DeploymentUnit.
+    * A sucessful call to {@link #update()} or its variants pushes an additional
+    * DeploymentUnit to the stack.   
+    * 
+    * @return the unit that corresponds to the last sucessful update.
     */
    public DeploymentUnit getDeploymentUnit()
    {
-      return unit;
+      return units.peek();
    }
 
+   /**
+    * Add a DeploymentUnit to the stack.
+    * 
+    * @see {@link OSGiBundleManager#updateBundle(OSGiBundleState, InputStream)}
+    */
+   void addDeploymentUnit(DeploymentUnit unit)
+   {
+      unit.getMutableMetaData().addMetaData(unit, DeploymentUnit.class);
+      units.push(unit);
+   }
+
    public String getLocation()
    {
       return location;
@@ -224,11 +245,11 @@
       checkInstalled();
       if (noAdminPermission(AdminPermission.RESOURCE))
          return null;
-      
+
       // [TODO] bundle fragment
       if (resolveBundle() == false)
          return getDeploymentUnit().getResourceLoader().getResource(name);
-      
+
       return getDeploymentUnit().getClassLoader().getResource(name);
    }
 
@@ -242,7 +263,7 @@
       // [TODO] bundle fragment 
       if (resolveBundle() == false)
          return getDeploymentUnit().getResourceLoader().getResources(name);
-      
+
       return getDeploymentUnit().getClassLoader().getResources(name);
    }
 
@@ -293,7 +314,7 @@
 
             // Attach so we can call BundleActivator.stop() on this instance
             BundleActivator bundleActivator = (BundleActivator)result;
-            unit.addAttachment(BundleActivator.class, bundleActivator);
+            getDeploymentUnit().addAttachment(BundleActivator.class, bundleActivator);
 
             bundleActivator.start(getBundleContext());
          }
@@ -303,7 +324,7 @@
 
          changeState(ACTIVE);
       }
-      
+
       // If the BundleActivator is invalid or throws an exception then:
       //   * This bundle's state is set to STOPPING.
       //   * A bundle event of type BundleEvent.STOPPING is fired.
@@ -318,20 +339,20 @@
          // This bundle's state is set to STOPPING
          // A bundle event of type BundleEvent.STOPPING is fired
          changeState(STOPPING);
-         
+
          // Any services registered by this bundle must be unregistered.
          // Any services used by this bundle must be released.
          // Any listeners registered by this bundle must be removed.
          stopInternal();
-         
+
          // This bundle's state is set to RESOLVED
          // A bundle event of type BundleEvent.STOPPED is fired
          destroyBundleContext();
          changeState(RESOLVED);
-         
+
          if (t instanceof BundleException)
             throw (BundleException)t;
-         
+
          throw new BundleException("Cannot start bundle: " + this, t);
       }
    }
@@ -356,21 +377,21 @@
       Throwable rethrow = null;
       if (priorState == Bundle.ACTIVE)
       {
-            BundleActivator bundleActivator = getDeploymentUnit().getAttachment(BundleActivator.class);
-            BundleContext bundleContext = getBundleContext();
-            if (bundleActivator != null && bundleContext != null)
+         BundleActivator bundleActivator = getDeploymentUnit().getAttachment(BundleActivator.class);
+         BundleContext bundleContext = getBundleContext();
+         if (bundleActivator != null && bundleContext != null)
+         {
+            try
             {
-               try
-               {
-                  bundleActivator.stop(bundleContext);
-               }
-               catch (Throwable t)
-               {
-                  rethrow = t;
-               }
+               bundleActivator.stop(bundleContext);
             }
+            catch (Throwable t)
+            {
+               rethrow = t;
+            }
+         }
       }
-      
+
       // Any services registered by this bundle must be unregistered
       getBundleManager().unregisterContexts(this);
 
@@ -393,26 +414,48 @@
       }
 
       // [TODO] Any listeners registered by this bundle must be removed
-      
+
       // If this bundle's state is UNINSTALLED, because this bundle was uninstalled while the 
       // BundleActivator.stop method was running, a BundleException must be thrown
       if (getState() == Bundle.UNINSTALLED)
          throw new BundleException("Bundle uninstalled during activator stop: " + this);
-      
+
       // This bundle's state is set to RESOLVED
       // A bundle event of type BundleEvent.STOPPED is fired
       destroyBundleContext();
       changeState(RESOLVED);
-      
+
       if (rethrow != null)
          throw new BundleException("Error during stop of bundle: " + this, rethrow);
    }
 
+   /**
+    * Updates this bundle. 
+    * 
+    * This method performs the same function as calling update(InputStream) with a null InputStream
+    */
+   public void update() throws BundleException
+   {
+      update(null);
+   }
+
+   /**
+    * Updates this bundle from an InputStream. 
+    */
    public void update(InputStream in) throws BundleException
    {
-      checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
-      // [TODO] update
-      throw new UnsupportedOperationException("update");
+      checkAdminPermission(AdminPermission.LIFECYCLE);
+      try
+      {
+         getBundleManager().updateBundle(this, in);
+      }
+      catch (Exception ex)
+      {
+         if (ex instanceof BundleException)
+            throw (BundleException)ex;
+
+         throw new BundleException("Cannot update bundle: " + this, ex);
+      }
    }
 
    public void uninstall() throws BundleException
@@ -424,26 +467,26 @@
    @Override
    protected void afterServiceRegistration(OSGiServiceState service)
    {
-      getBundleManager().putContext(service, unit);
+      getBundleManager().putContext(service, getDeploymentUnit());
    }
 
    @Override
    protected void beforeServiceUnregistration(OSGiServiceState service)
    {
-      getBundleManager().removeContext(service, unit);
+      getBundleManager().removeContext(service, getDeploymentUnit());
    }
 
    public static OSGiBundleState assertBundleState(Bundle bundle)
    {
       if (bundle == null)
          throw new IllegalArgumentException("Null bundle");
-      
+
       if (bundle instanceof OSGiBundleWrapper)
          bundle = ((OSGiBundleWrapper)bundle).getBundleState();
-   
+
       if (bundle instanceof OSGiBundleState == false)
          throw new IllegalArgumentException("Not an OSGiBundleState: " + bundle);
-   
+
       return (OSGiBundleState)bundle;
    }
 }

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -46,6 +46,8 @@
 {
    /** The registred contexts */
    private Set<ControllerContext> registered = new ConcurrentSet<ControllerContext>();
+   /** The osgi metadata */
+   private OSGiMetaData osgiMetaData;
 
    /**
     * Create a new OSGiSystemBundle.
@@ -53,9 +55,18 @@
     */
    public OSGiSystemState(OSGiMetaData osgiMetaData)
    {
-      super(osgiMetaData);
+      if (osgiMetaData == null)
+         throw new IllegalArgumentException("Null osgi metadata");
+      
+      this.osgiMetaData = osgiMetaData;
    }
 
+   @Override
+   public OSGiMetaData getOSGiMetaData()
+   {
+      return osgiMetaData;
+   }
+
    protected Set<ControllerContext> getRegisteredContexts()
    {
       return registered;
@@ -161,7 +172,6 @@
       });
    }
 
-   @Override
    public void update() throws BundleException
    {
       final OSGiBundleManager bundleManager = getBundleManager();

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiBundleStateDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiBundleStateDeployer.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiBundleStateDeployer.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -21,13 +21,12 @@
 */
 package org.jboss.osgi.framework.deployers;
 
+import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
 import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
-import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.osgi.framework.bundle.OSGiBundleManager;
 import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
 
 /**
  * AbstractOSGiBundleStateDeployer.<p>
@@ -40,12 +39,6 @@
    /** The bundle manager */
    protected OSGiBundleManager bundleManager;
 
-   /**
-    * Create a new BundleStateDeployer.
-    *
-    * @param bundleManager the bundleManager
-    * @throws IllegalArgumentException for a null bundle manager
-    */
    protected AbstractOSGiBundleStateDeployer(OSGiBundleManager bundleManager)
    {
       if (bundleManager == null)

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateRemoveDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateRemoveDeployer.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateRemoveDeployer.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -21,7 +21,6 @@
 */
 package org.jboss.osgi.framework.deployers;
 
-import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.osgi.framework.bundle.OSGiBundleManager;
 import org.jboss.osgi.framework.bundle.OSGiBundleState;

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/main/java/org/jboss/osgi/framework/service/internal/DeployerServiceImpl.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -76,17 +76,17 @@
       // do nothing
    }
 
-   public Deployment createDeployment(URL url)
+   public Deployment createDeployment(URL url) throws BundleException
    {
       return delegate.createDeployment(url);
    }
 
-   public Deployment createDeployment(VirtualFile file)
+   public Deployment createDeployment(VirtualFile file) throws BundleException
    {
       return delegate.createDeployment(file);
    }
 
-   public Deployment createDeployment(BundleInfo info)
+   public Deployment createDeployment(BundleInfo info) throws BundleException
    {
       return delegate.createDeployment(info);
    }

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/FrameworkTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/FrameworkTest.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/FrameworkTest.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -169,16 +169,19 @@
 
    protected Bundle installBundle(String location) throws BundleException
    {
-      BundleContext context = getBundleManager().getSystemContext();
-      return context.installBundle(location);
+      return getBundleManager().installBundle(location, null);
    }
 
    protected Bundle installBundle(String location, InputStream instream) throws BundleException
    {
-      BundleContext context = getBundleManager().getSystemContext();
-      return context.installBundle(location, instream);
+      return getBundleManager().installBundle(location, instream);
    }
    
+   protected Bundle installBundle(VirtualFile bundleFile) throws BundleException
+   {
+      return getBundleManager().installBundle(bundleFile);
+   }
+   
    /**
     * Remove a bundle 
     * 
@@ -195,12 +198,12 @@
       return getDelegate().getDeploymentUnit(bundle);
    }
 
-   protected Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
+   protected VirtualFile assembleBundle(String name, String resources, Class<?>... packages) throws Exception
    {
       return getDelegate().assembleBundle(name, new String[] { resources }, packages);
    }
 
-   protected Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
+   protected VirtualFile assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
    {
       return getDelegate().assembleBundle(name, resourcePaths, packages);
    }

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -217,15 +217,15 @@
       return deploymentUnit;
    }
 
-   public Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
+   public VirtualFile assembleBundle(String name, String resources, Class<?>... packages) throws Exception
    {
       return assembleBundle(name, new String[] { resources }, packages);
    }
 
-   public Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
+   public VirtualFile assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
    {
       AssembledDirectory assembledDirectory = createAssembledDirectory(name, "", resourcePaths, packages);
-      return addBundle(assembledDirectory);
+      return assembledDirectory;
    }
 
    public Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath, Class<?>... packages) throws Exception

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -26,7 +26,6 @@
 import org.jboss.test.osgi.FrameworkTest;
 import org.jboss.test.osgi.bundle.support.a.FailOnStartActivator;
 import org.jboss.test.osgi.bundle.support.b.LifecycleService;
-import org.jboss.test.osgi.bundle.support.b.LifecycleServiceActivator;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.ServiceReference;
@@ -54,7 +53,7 @@
     */
    public void testServiceBundle() throws Exception
    {
-      Bundle bundleA = assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class, LifecycleServiceActivator.class);
+      Bundle bundleA = installBundle(assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class));
       try
       {
          assertBundleState(Bundle.INSTALLED, bundleA.getState());
@@ -77,7 +76,7 @@
     */
    public void testServiceNotAvailable() throws Exception
    {
-      Bundle bundleA = assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class, LifecycleServiceActivator.class);
+      Bundle bundleA = installBundle(assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class));
       try
       {
          assertBundleState(Bundle.INSTALLED, bundleA.getState());
@@ -86,7 +85,7 @@
          ServiceReference sref = getSystemBundle().getBundleContext().getServiceReference(LifecycleService.class.getName());
          assertNull("Service not available", sref);
 
-         Bundle bundleB = assembleBundle("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
+         Bundle bundleB = installBundle(assembleBundle("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class));
          try
          {
             assertBundleState(Bundle.INSTALLED, bundleB.getState());
@@ -116,13 +115,13 @@
     */
    public void testServiceAvailable() throws Exception
    {
-      Bundle bundleA = assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class, LifecycleServiceActivator.class);
+      Bundle bundleA = installBundle(assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class));
       try
       {
          bundleA.start();
          assertBundleState(Bundle.ACTIVE, bundleA.getState());
 
-         Bundle bundleB = assembleBundle("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
+         Bundle bundleB = installBundle(assembleBundle("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class));
          try
          {
             bundleB.start();
@@ -146,12 +145,12 @@
     */
    public void testServiceMakeAvailable() throws Exception
    {
-      Bundle bundleA = assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class, LifecycleServiceActivator.class);
+      Bundle bundleA = installBundle(assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class));
       try
       {
          assertBundleState(Bundle.INSTALLED, bundleA.getState());
          
-         Bundle bundleB = assembleBundle("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
+         Bundle bundleB = installBundle(assembleBundle("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class));
          try
          {
             assertBundleState(Bundle.INSTALLED, bundleB.getState());

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -21,13 +21,19 @@
 */
 package org.jboss.test.osgi.bundle;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.jar.Attributes;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
 
 import junit.framework.Test;
 
 import org.jboss.test.osgi.FrameworkTest;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -148,7 +154,37 @@
    
    public void testUpdate() throws Exception
    {
-      // TODO testUpdate
+      VirtualFile assemble1 = assembleBundle("bundle1", "/bundles/update/update-bundle1");
+      VirtualFile assemble2 = assembleBundle("bundle2", "/bundles/update/update-bundle2");
+      
+      Manifest manifest = VFSUtils.getManifest(assemble2);
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      new JarOutputStream(baos, manifest).close();
+      ByteArrayInputStream updateStream = new ByteArrayInputStream(baos.toByteArray());
+      
+      // [JBVFS-130] VFSUtils.temp(assembledDirectory) cannot create tmp dir
+      // assemble2 = VFSUtils.temp(assemble2);
+      
+      Bundle bundle = installBundle(assemble1);
+      try
+      {
+         int beforeCount = getBundleManager().getBundles().size();
+         
+         bundle.start();
+         assertBundleState(Bundle.ACTIVE, bundle.getState());
+         assertEquals("Bundle-Version", "1.0.0", bundle.getHeaders().get(Constants.BUNDLE_VERSION));
+         
+         bundle.update(updateStream);
+         assertBundleState(Bundle.ACTIVE, bundle.getState());
+         assertEquals("Bundle-Version", "1.0.1", bundle.getHeaders().get(Constants.BUNDLE_VERSION));
+         
+         int afterCount = getBundleManager().getBundles().size();
+         assertEquals("Bundle count", beforeCount, afterCount);
+      }
+      finally
+      {
+         uninstall(bundle);
+      }
    }
    
    public void testUninstall() throws Exception
@@ -158,10 +194,10 @@
    
    public void testSingleton() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundle1", "/bundles/singleton/singleton1");
+      Bundle bundle1 = installBundle(assembleBundle("bundle1", "/bundles/singleton/singleton1"));
       try
       {
-         Bundle bundle2 = assembleBundle("bundle2", "/bundles/singleton/singleton2");
+         Bundle bundle2 = installBundle(assembleBundle("bundle2", "/bundles/singleton/singleton2"));
          uninstall(bundle2);
          fail("Should not be here!");
       }
@@ -177,10 +213,10 @@
    
    public void testNotSingleton() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundle1", "/bundles/singleton/singleton1");
+      Bundle bundle1 = installBundle(assembleBundle("bundle1", "/bundles/singleton/singleton1"));
       try
       {
-         Bundle bundle2 = assembleBundle("not-singleton", "/bundles/singleton/not-singleton");
+         Bundle bundle2 = installBundle(assembleBundle("not-singleton", "/bundles/singleton/not-singleton"));
          try
          {
             assertEquals(bundle1.getSymbolicName(), bundle2.getSymbolicName());
@@ -196,7 +232,7 @@
       }
    }
    
-   @SuppressWarnings("unchecked")
+   @SuppressWarnings({ "rawtypes", "unchecked" })
    public void testGetHeaders() throws Exception
    {
       // TODO case insensistive

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -50,12 +50,12 @@
 
    public void testSimpleRequireBundle() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("simplerequirebundleA", "/bundles/classloader/simplerequirebundleA", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("simplerequirebundleA", "/bundles/classloader/simplerequirebundleA", B.class));
          try
          {
             bundle2.start();
@@ -75,12 +75,12 @@
    
    public void testSimpleRequireBundleFails() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("simplerequirebundlefails", "/bundles/classloader/simplerequirebundlefails", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("simplerequirebundlefails", "/bundles/classloader/simplerequirebundlefails", B.class));
          try
          {
             bundle2.start();
@@ -103,12 +103,12 @@
    
    public void testVersionRequireBundle() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("versionrequirebundleA", "/bundles/classloader/versionrequirebundleA", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("versionrequirebundleA", "/bundles/classloader/versionrequirebundleA", B.class));
          try
          {
             bundle2.start();
@@ -128,12 +128,12 @@
    
    public void testVersionRequireBundleFails() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("versionrequirebundlefails", "/bundles/classloader/versionrequirebundlefails", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("versionrequirebundlefails", "/bundles/classloader/versionrequirebundlefails", B.class));
          try
          {
             bundle2.start();
@@ -156,12 +156,12 @@
    
    public void testOptionalRequireBundle() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("optionalrequirebundleA", "/bundles/classloader/optionalrequirebundleA", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("optionalrequirebundleA", "/bundles/classloader/optionalrequirebundleA", B.class));
          try
          {
             bundle2.start();
@@ -181,12 +181,12 @@
    
    public void testOptionalRequireBundleFails() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("optionalrequirebundlefails", "/bundles/classloader/optionalrequirebundlefails", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("optionalrequirebundlefails", "/bundles/classloader/optionalrequirebundlefails", B.class));
          try
          {
             bundle2.start();
@@ -210,7 +210,7 @@
       //Bundle-Version: 1.0.0
       //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
       //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       
       try
       {
@@ -221,7 +221,7 @@
          //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
          //Require-Bundle: org.jboss.test.osgi.classloader.bundleA;visibility:=reexport
          //Export-Package: org.jboss.test.osgi.classloader.support.b
-         Bundle bundle2 = assembleBundle("reexportrequirebundleA", "/bundles/classloader/reexportrequirebundleA", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("reexportrequirebundleA", "/bundles/classloader/reexportrequirebundleA", B.class));
          
          try
          {
@@ -232,7 +232,7 @@
             //Bundle-Name: BundleC
             //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleC
             //Require-Bundle: org.jboss.test.osgi.classloader.bundleB
-            Bundle bundle3 = assembleBundle("reexportrequirebundleB", "/bundles/classloader/reexportrequirebundleB");
+            Bundle bundle3 = installBundle(assembleBundle("reexportrequirebundleB", "/bundles/classloader/reexportrequirebundleB"));
             
             try
             {
@@ -257,18 +257,18 @@
    
    public void testNoReExportRequireBundle() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("noreexportrequirebundleA", "/bundles/classloader/noreexportrequirebundleA", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("noreexportrequirebundleA", "/bundles/classloader/noreexportrequirebundleA", B.class));
          try
          {
             bundle2.start();
             assertLoadClass(bundle2, A.class, bundle1);
             assertLoadClass(bundle2, B.class, bundle2);
-            Bundle bundle3 = assembleBundle("reexportrequirebundleB", "/bundles/classloader/reexportrequirebundleB");
+            Bundle bundle3 = installBundle(assembleBundle("reexportrequirebundleB", "/bundles/classloader/reexportrequirebundleB"));
             try
             {
                assertLoadClassFail(bundle3, A.class);
@@ -292,12 +292,12 @@
    
    public void testAttributeRequireBundle() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("attributerequirebundleA", "/bundles/classloader/attributerequirebundleA", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("attributerequirebundleA", "/bundles/classloader/attributerequirebundleA", B.class));
          try
          {
             bundle2.start();
@@ -317,12 +317,12 @@
    
    public void testAttributeRequireBundleFails() throws Exception
    {
-      Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class));
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
-         Bundle bundle2 = assembleBundle("attributerequirebundlefails", "/bundles/classloader/attributerequirebundlefails", B.class);
+         Bundle bundle2 = installBundle(assembleBundle("attributerequirebundlefails", "/bundles/classloader/attributerequirebundlefails", B.class));
          try
          {
             bundle2.start();

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -54,7 +54,7 @@
 
    public void testGetBudleFromClass() throws Exception
    {
-      Bundle bundle = assembleBundle("smoke-assembled", "/bundles/smoke/smoke-assembled", PA.class);
+      Bundle bundle = installBundle(assembleBundle("smoke-assembled", "/bundles/smoke/smoke-assembled", PA.class));
       try
       {
          bundle.start();
@@ -68,7 +68,7 @@
          Bundle notFound = pa.getBundle(getClass());
          assertNull(notFound);
 
-         Bundle other = assembleBundle("simple", "/bundles/simple/simple-bundle1", Other.class);
+         Bundle other = installBundle(assembleBundle("simple", "/bundles/simple/simple-bundle1", Other.class));
          try
          {
             other.start();

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -57,7 +57,7 @@
 
    public void testGetServiceReferences() throws Exception
    {
-      Bundle bundle1 = assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class));
       try
       {
          bundle1.start();
@@ -174,7 +174,7 @@
    
    public void assertGetServiceReferencesNotAssignable(String className) throws Exception
    {
-      Bundle bundle1 = assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class));
       try
       {
          bundle1.start();
@@ -191,7 +191,7 @@
          ServiceReference reference1 = registration1.getReference();
          assertNotNull(reference1);
 
-         Bundle bundle2 = assembleBundle("simple2", "/bundles/simple/simple-bundle2", A.class);
+         Bundle bundle2 = installBundle(assembleBundle("simple2", "/bundles/simple/simple-bundle2", A.class));
          try
          {
             bundle2.start();
@@ -272,7 +272,7 @@
 
    public void assertGetServiceReferencesAssignable(String className) throws Exception
    {
-      Bundle bundle1 = assembleBundle("service2", "/bundles/service/service-bundle2", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("service2", "/bundles/service/service-bundle2", A.class));
       try
       {
          bundle1.start();
@@ -289,7 +289,7 @@
          ServiceReference reference1 = registration1.getReference();
          assertNotNull(reference1);
 
-         Bundle bundle2 = assembleBundle("service1", "/bundles/service/service-bundle1");
+         Bundle bundle2 = installBundle(assembleBundle("service1", "/bundles/service/service-bundle1"));
          try
          {
             bundle2.start();
@@ -362,7 +362,7 @@
    {
       String className = A.class.getName();
       
-      Bundle bundle1 = assembleBundle("service2", "/bundles/service/service-bundle2", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("service2", "/bundles/service/service-bundle2", A.class));
       try
       {
          bundle1.start();
@@ -382,7 +382,7 @@
          ServiceReference reference1 = registration1.getReference();
          assertNotNull(reference1);
 
-         Bundle bundle2 = assembleBundle("service1", "/bundles/service/service-bundle1");
+         Bundle bundle2 = installBundle(assembleBundle("service1", "/bundles/service/service-bundle1"));
          try
          {
             bundle2.start();
@@ -470,7 +470,7 @@
       String className = A.class.getName();
       String wrongClassName = B.class.getName();
       
-      Bundle bundle1 = assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class);
+      Bundle bundle1 = installBundle(assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class));
       try
       {
          bundle1.start();

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -66,7 +66,7 @@
       Deployment bean = deployBean("beanA", A.class);
       try
       {
-         Bundle bundle1 = assembleBundle("simple1", "/bundles/service/service-bundle1");
+         Bundle bundle1 = installBundle(assembleBundle("simple1", "/bundles/service/service-bundle1"));
          try
          {
             bundle1.start();
@@ -134,7 +134,7 @@
       {
          KernelControllerContext kcc = getControllerContext("C", null);
 
-         Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle3");
+         Bundle bundle1 = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle3"));
          try
          {
             bundle1.start();
@@ -191,7 +191,7 @@
       {
          KernelControllerContext kcc = getControllerContext("C", null);
 
-         Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle3");
+         Bundle bundle1 = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle3"));
          try
          {
             bundle1.start();
@@ -249,7 +249,7 @@
       Deployment bean = addBean("beanA", C.class, bmd, A.class);
       try
       {
-         Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle3");
+         Bundle bundle1 = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle3"));
          try
          {
             bundle1.start();
@@ -287,6 +287,7 @@
       }
    }
 
+   @SuppressWarnings("rawtypes")
    public void testServiceFactoryInjection() throws Throwable
    {
       BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C1", C.class.getName());
@@ -301,7 +302,7 @@
          Deployment bean2 = addBean("beanA2", null, bmd);
          try
          {
-            Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle4");
+            Bundle bundle1 = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle4"));
             try
             {
                bundle1.start();
@@ -358,6 +359,7 @@
       }
    }
 
+   @SuppressWarnings("rawtypes")
    public void testServiceFactoryMix() throws Throwable
    {
       BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C1", C.class.getName());
@@ -366,7 +368,7 @@
       Deployment bean1 = addBean("beanA1", C.class, bmd, A.class, D.class);
       try
       {
-            Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle4");
+            Bundle bundle1 = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle4"));
             try
             {
                bundle1.start();
@@ -463,7 +465,7 @@
       Deployment bean = addBean("beanA", A.class);
       try
       {
-         Bundle bundle1 = assembleBundle("simple2", "/bundles/service/service-bundle1");
+         Bundle bundle1 = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle1"));
          try
          {
             bundle1.start();

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -374,7 +374,7 @@
    
    public void testIsAssignableToErrors() throws Exception
    {
-      Bundle bundle = assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class);
+      Bundle bundle = installBundle(assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class));
       try
       {
          bundle.start();
@@ -415,7 +415,7 @@
 
    public void testNotAssignableTo() throws Exception
    {
-      Bundle bundle = assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class);
+      Bundle bundle = installBundle(assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class));
       try
       {
          bundle.start();
@@ -428,7 +428,7 @@
          ServiceReference reference = registration.getReference();
          assertNotNull(reference);
 
-         Bundle bundle2 = assembleBundle("simple2", "/bundles/simple/simple-bundle2", A.class);
+         Bundle bundle2 = installBundle(assembleBundle("simple2", "/bundles/simple/simple-bundle2", A.class));
          try
          {
             assertFalse(reference.isAssignableTo(bundle2, A.class.getName()));
@@ -454,7 +454,7 @@
       //Bundle-Name: Service2
       //Bundle-SymbolicName: org.jboss.test.osgi.service2
       //Export-Package: org.jboss.test.osgi.service.support.a
-      Bundle bundle2 = assembleBundle("service2", "/bundles/service/service-bundle2", A.class);
+      Bundle bundle2 = installBundle(assembleBundle("service2", "/bundles/service/service-bundle2", A.class));
       
       try
       {
@@ -465,7 +465,7 @@
          //Bundle-Name: Service1
          //Bundle-SymbolicName: org.jboss.test.osgi.service1
          //Import-Package: org.jboss.test.osgi.service.support.a
-         Bundle bundle1 = assembleBundle("service1", "/bundles/service/service-bundle1");
+         Bundle bundle1 = installBundle(assembleBundle("service1", "/bundles/service/service-bundle1"));
          
          try
          {

Modified: projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java	2009-12-17 08:47:28 UTC (rev 97933)
+++ projects/jboss-osgi/projects/runtime/framework/branches/tdiesler/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java	2009-12-17 08:47:52 UTC (rev 97934)
@@ -73,7 +73,7 @@
 
    public void testAssembled() throws Exception
    {
-      Bundle bundle = assembleBundle("smoke-assembled", "/bundles/smoke/smoke-assembled", A.class);
+      Bundle bundle = installBundle(assembleBundle("smoke-assembled", "/bundles/smoke/smoke-assembled", A.class));
       try
       {
          testBundle(bundle, "smoke-assembled", Bundle.INSTALLED);



More information about the jboss-osgi-commits mailing list