[jboss-cvs] JBossAS SVN: r94302 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk: scripts and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 2 18:54:52 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-02 18:54:52 -0400 (Fri, 02 Oct 2009)
New Revision: 94302

Added:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Removed:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/
Modified:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/.classpath
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-all.xml
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateDeployer.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleUnitTestCase.java
Log:
Preserve user's bundle location 

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/.classpath
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/.classpath	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/.classpath	2009-10-02 22:54:52 UTC (rev 94302)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry kind="lib" path="/licensed/repo/com.springsource.junit/com.springsource.junit-3.8.2.jar" sourcepath="/home/tdiesler/Download/java/junit/junit3.8.2/src.jar"/>
 	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
 	<classpathentry kind="src" output="target/classes" path="target/generated-sources/javacc"/>
 	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml	2009-10-02 22:54:52 UTC (rev 94302)
@@ -17,7 +17,7 @@
   <!-- 
      Set these VM properties in your IDE debugger 
     
-    -Dlog4j.output.dir=${workspace_loc:jboss-osgi-runtime-microcontainer/target}
+    -Dlog4j.output.dir=${workspace_loc:jboss-osgi-framework/target}
   -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-all.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-all.xml	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-all.xml	2009-10-02 22:54:52 UTC (rev 94302)
@@ -64,8 +64,18 @@
       <outputDirectory>/</outputDirectory>
     </fileSet>
     <fileSet>
-      <directory>target/test-classes/bootstrap</directory>
-      <outputDirectory>/bootstrap</outputDirectory>
+      <directory>target/test-classes</directory>
+      <outputDirectory>/</outputDirectory>
+      <includes>
+        <include>log4j.xml</include>
+      </includes>
     </fileSet>
+    <fileSet>
+      <directory>src/etc/osgitck</directory>
+      <outputDirectory>/</outputDirectory>
+      <includes>
+        <include>jboss-osgi-bootstrap.xml</include>
+      </includes>
+    </fileSet>
   </fileSets>
 </assembly>

Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml	2009-10-02 22:54:52 UTC (rev 94302)
@@ -0,0 +1,175 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <!-- 
+  ********************************
+  *                              *  
+  *  OSGi Framework              *
+  *                              *
+  ********************************
+  -->
+  
+  <bean name="OSGiBundleManager" class="org.jboss.osgi.framework.bundle.OSGiBundleManager">
+    <constructor>
+      <parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
+      <parameter><inject bean="MainDeployer" /></parameter>
+    </constructor>
+    <property name="properties">
+      <map keyClass="java.lang.String" valueClass="java.lang.String">
+        <entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
+        <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+        <entry><key>org.osgi.framework.system.packages.extra</key><value>
+        
+          junit.framework;version=3.8.1,
+          
+          org.jboss.logging;version=2.0,
+          org.jboss.osgi.spi.capability;version=1.0,
+          org.jboss.osgi.spi.logging;version=1.0,
+          org.jboss.osgi.spi.management;version=1.0,
+          org.jboss.osgi.spi.service;version=1.0,
+          org.jboss.osgi.spi.testing;version=1.0,
+          org.jboss.osgi.spi.util;version=1.0,
+          
+          org.osgi.framework,
+          org.osgi.framework.launch,
+          org.osgi.service.startlevel,
+          org.osgi.service.packageadmin
+        </value></entry>
+      </map>
+    </property>
+    <incallback method="addPlugin" />
+    <uncallback method="removePlugin" />
+  </bean>
+  
+  <!-- 
+  ********************************
+  *                              *  
+  *  OSGi Framework Plugins      *
+  *                              *
+  ********************************
+  -->
+  
+  <bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="OSGiStoragePlugin" class="org.jboss.osgi.framework.plugins.internal.BundleStoragePluginImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="OSGiSystemPackages" class="org.jboss.osgi.framework.plugins.internal.SystemPackagesPluginImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  
+  <!-- 
+  ********************************
+  *                              *  
+  *  OSGi Service Plugins        *
+  *                              *
+  ********************************
+  -->
+  
+  <bean name="MicrocontainerService" class="org.jboss.osgi.framework.service.internal.MicrocontainerServiceImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="StartLevelService" class="org.jboss.osgi.framework.service.internal.StartLevelImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  
+  <!--
+  ********************************
+  *                              *  
+  *  OSGi Deployment             *
+  *                              *
+  ********************************
+  -->
+  
+  <!-- The MainDeployer -->
+  <bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
+    <property name="structuralDeployers"><inject bean="StructuralDeployers" /></property>
+    <property name="deployers"><inject bean="Deployers" /></property>
+  </bean>
+
+  <!-- The holder for deployers that determine structure -->
+  <bean name="StructuralDeployers" class="org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl">
+    <property name="structureBuilder">
+      <!-- The consolidator of the structure information -->
+      <bean name="StructureBuilder" class="org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder" />
+    </property>
+    <!-- Accept any implementor of structure deployer -->
+    <incallback method="addDeployer" />
+    <uncallback method="removeDeployer" />
+  </bean>
+
+  <!-- The holder for deployers that do real deployment -->
+  <bean name="Deployers" class="org.jboss.deployers.plugins.deployers.DeployersImpl">
+    <constructor><parameter><inject bean="jboss.kernel:service=KernelController" /></parameter></constructor>
+    <!-- Accept any implementor of deployer -->
+    <incallback method="addDeployer" />
+    <uncallback method="removeDeployer" />
+  </bean>
+
+  <!-- Bundle Structure -->
+  <bean name="BundleStructure" class="org.jboss.osgi.deployer.BundleStructureDeployer" />
+  
+  <!-- JAR & File Structure (needed for negative testing) -->
+  <bean name="JARStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure" />
+  <bean name="FileStructure" class="org.jboss.deployers.vfs.plugins.structure.file.FileStructure" />
+
+  <!-- POJO Deployment -->
+  <bean name="BeanDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanDeployer" />
+  <bean name="KernelDeploymentDeployer" class="org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer" />
+  <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer">
+    <constructor>
+      <parameter class="org.jboss.dependency.spi.Controller"><inject bean="jboss.kernel:service=KernelController" /></parameter>
+    </constructor>
+  </bean>
+
+  <!-- OSGI Deployment -->
+  <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
+  <bean name="OSGiBundleStateDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateDeployer">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="OSGiBundleActivatorDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer" />
+
+  <!--
+  ********************************
+  *                              *  
+  *  OSGi Classloading           *
+  *                              *
+  ********************************
+  -->
+  
+  <bean name="OSGiClassLoaderSystem" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderSystem" />
+  <bean name="OSGiClassLoaderDomain" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderDomain" >
+    <constructor><parameter>OSGiClassLoaderDomain</parameter></constructor>
+    <property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
+    <property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
+  </bean>
+  <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
+    <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+  </bean>
+  <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+    <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+    <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
+  </bean>
+   
+  <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+    <incallback method="addModule" state="Configured" />
+    <uncallback method="removeModule" state="Configured" />
+  </bean>
+  <bean name="ClassLoadingDefaultDeployer" class="org.jboss.deployers.plugins.classloading.ClassLoadingDefaultDeployer">
+    <property name="defaultMetaData">
+      <classloading xmlns="urn:jboss:classloading:1.0" export-all="NON_EMPTY" import-all="true" />
+    </property>
+  </bean>
+  <bean name="ClassLoaderClassPathDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderClassPathDeployer" />
+  <bean name="ClassLoaderDescribeDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+  </bean>
+  <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+    <property name="system"><inject bean="OSGiClassLoaderSystem" /></property>
+  </bean>
+
+</deployment>

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java	2009-10-02 22:54:52 UTC (rev 94302)
@@ -23,8 +23,6 @@
 
 import java.io.File;
 import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.security.Permission;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
@@ -100,7 +98,7 @@
    /** The cached symbolic name */
    private String symbolicName;
    
-   /** The cached */
+   /** The cached version */
    private Version version;
 
    /**
@@ -585,52 +583,14 @@
    {
       checkValidBundleContext();
       checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
-      // [TODO] installBundle
-      throw new UnsupportedOperationException("installBundle");
-   }
 
-   public Bundle installBundle(String location) throws BundleException
-   {
-      checkValidBundleContext();
-      checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
-
-      URL url = getLocationURL(location);
-      AbstractBundleState bundleState = getBundleManager().install(url);
+      AbstractBundleState bundleState = getBundleManager().install(location, input);
       return bundleState.getBundleInternal();
    }
 
-   private URL getLocationURL(String location) throws BundleException
+   public Bundle installBundle(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.toURL();
-         }
-         catch (MalformedURLException e)
-         {
-            // ignore
-         }
-      }
-
-      if (url == null)
-         throw new BundleException("Unable to handle location=" + location);
-
-      return url;
+      return installBundle(location, null);
    }
 
    @Override

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2009-10-02 22:54:52 UTC (rev 94302)
@@ -23,7 +23,11 @@
 
 import static org.jboss.osgi.spi.Constants.PROPERTY_AUTO_START;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -71,6 +75,7 @@
 import org.jboss.osgi.framework.resolver.BundleResolver;
 import org.jboss.util.collection.ConcurrentSet;
 import org.jboss.virtual.VFS;
+import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -99,6 +104,9 @@
    /** The bundle manager's bean name: OSGiBundleManager */
    public static final String BEAN_BUNDLE_MANAGER = "OSGiBundleManager";
 
+   /** The string representation of this bundle's location identifier. */
+   private static final String PROPERTY_BUNDLE_LOCATION = "org.jboss.osgi.bundle.location";
+
    /** The framework version */
    private static String OSGi_FRAMEWORK_VERSION = "r4v42"; // [TODO] externalise
 
@@ -375,36 +383,91 @@
    {
       if (url == null)
          throw new BundleException("Null url");
+      
+      VirtualFile root;
+      try
+      {
+         root = VFS.getRoot(url);
+      }
+      catch (IOException e)
+      {
+         throw new BundleException("Invalid bundle location=" + url, e);
+      }
 
+      return install(root, null);
+   }
+
+   /**
+    * Install a bundle 
+    * 
+    * @param location the bundle's location identifier
+    * @param input an optional input stream to read the bundle content from
+    * @return the bundle state
+    * @throws BundleException for any error
+    */
+   public AbstractBundleState install(String location, InputStream input) throws BundleException
+   {
+      if (location == null)
+         throw new BundleException("Null location");
+
+      // Get the location URL
+      URL locationURL = getLocationURL(location);
+      if (input != null)
+      {
+         try
+         {
+            BundleStoragePlugin plugin = getPlugin(BundleStoragePlugin.class);
+            String path = plugin.getStorageDir(getSystemBundle()).getCanonicalPath();
+
+            // [TODO] do properly
+            File file = new File(path + "/installBundle-" + 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);
+         }
+      }
+
+      // Get the root file
+      VirtualFile root;
       try
       {
-         VirtualFile root = VFS.getRoot(url);
-         return install(root);
+         root = VFS.getRoot(locationURL);
       }
       catch (IOException e)
       {
-         throw new BundleException("Error installing bundle from location=" + url, e);
+         throw new BundleException("Invalid bundle location=" + locationURL, e);
       }
+
+      return install(root, location);
    }
 
    /**
-    * Install a bundle
+    * Install a bundle 
+    * @param root the virtual file that point to the bundle
+    * @param location the optional bundle location
     * 
-    * @param file the virtual file
     * @return the bundle state
     * @throws BundleException for any error
     */
-   public AbstractBundleState install(VirtualFile file) throws BundleException
+   public AbstractBundleState install(VirtualFile root, String location) throws BundleException
    {
-      if (file == null)
-         throw new BundleException("Null file");
+      if (location == null)
+         location = root.toString();
 
+      // Create the deployment and deploy it
       try
       {
-         VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(file);
+         VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root);
          MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
          att.addAttachment(PROPERTY_AUTO_START, Boolean.FALSE);
-         
+         att.addAttachment(PROPERTY_BUNDLE_LOCATION, location);
+
          deployerClient.deploy(deployment);
          try
          {
@@ -423,10 +486,44 @@
       }
       catch (Exception e)
       {
-         throw new BundleException("Error installing bundle from location=" + file, e);
+         throw new BundleException("Error installing bundle from location=" + root, e);
       }
    }
 
+   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;
+   }
+
    /**
     * Uninstall a bundle
     * 
@@ -471,7 +568,11 @@
       if (osgiMetaData == null)
          throw new IllegalStateException("Cannot obtain OSGi metadata");
 
-      OSGiBundleState bundleState = new OSGiBundleState(osgiMetaData, unit);
+      String location = (String)unit.getAttachment(PROPERTY_BUNDLE_LOCATION);
+      if (location == null)
+         throw new IllegalStateException("Cannot obtain bundle location");
+
+      OSGiBundleState bundleState = new OSGiBundleState(location, osgiMetaData, unit);
       addBundle(bundleState);
       return bundleState;
    }
@@ -613,15 +714,30 @@
     */
    public AbstractBundleState getBundleByLocation(String location)
    {
+      if (location == null)
+         throw new IllegalArgumentException("Null location");
+
       AbstractBundleState result = null;
+
       for (AbstractBundleState aux : bundles)
       {
          String auxLocation = aux.getLocation();
-         if (auxLocation.equals(location))
+         if (location.equals(auxLocation))
          {
             result = aux;
             break;
          }
+         
+         // Fallback to the deployment name
+         else if (aux instanceof OSGiBundleState)
+         {
+            DeploymentUnit unit = ((OSGiBundleState)aux).getDeploymentUnit();
+            if (location.equals(unit.getName()))
+            {
+               result = aux;
+               break;
+            }
+         }
       }
       return result;
    }
@@ -755,7 +871,7 @@
 
       if (registeredServices.isEmpty())
          return null;
-      
+
       // Don't check assignabilty for the system bundle
       if (bundle.getBundleId() == 0)
          checkAssignable = false;
@@ -796,7 +912,7 @@
       // If multiple such services exist, the service with the highest ranking (as specified in its SERVICE_RANKING property) is returned.
       // If there is a tie in ranking, the service with the lowest service ID (as specified in its SERVICE_ID property); 
       // that is, the service that was registered first is returned.
-      
+
       long bestId = 0;
       int bestRanking = 0;
       ServiceReference bestMatch = null;
@@ -829,13 +945,13 @@
       Collection<OSGiServiceState> services = getServices(bundle, clazz, filter, checkAssignable);
       if (services == null || services.isEmpty())
          return null;
-      
+
       ServiceReference[] result = new ServiceReference[services.size()];
-      
+
       int i = 0;
       for (OSGiServiceState service : services)
          result[i++] = service.getReferenceInternal();
-      
+
       return result;
    }
 
@@ -855,7 +971,7 @@
       Filter filter = NoFilter.INSTANCE;
       if (filterStr != null)
          filter = FrameworkUtil.createFilter(filterStr);
-      
+
       return getServiceReferences(bundle, clazz, filter, checkAssignable);
    }
 

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java	2009-10-02 22:54:52 UTC (rev 94302)
@@ -57,22 +57,32 @@
    /** The bundle id */
    private long bundleId;
 
+   /** The bundle location */
+   private String location;
+
    /** The deployment unit */
    private DeploymentUnit unit;
-
+   
    /**
     * Create a new BundleState.
     * 
+    * @param location The string representation of this bundle's location identifier 
     * @param osgiMetaData the osgi metadata
     * @param unit the deployment unit
     * @throws IllegalArgumentException for a null parameter
     */
-   public OSGiBundleState(OSGiMetaData osgiMetaData, DeploymentUnit unit)
+   public OSGiBundleState(String location, OSGiMetaData osgiMetaData, 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();
       unit.getMutableMetaData().addMetaData(unit, DeploymentUnit.class);
    }
@@ -94,14 +104,7 @@
 
    public String getLocation()
    {
-      checkAdminPermission(AdminPermission.METADATA);
-
-      URL url = getOSGiMetaData().getBundleUpdateLocation();
-      if (url != null)
-         return url.toString();
-
-      DeploymentUnit unit = getDeploymentUnit();
-      return unit.getName();
+      return location;
    }
 
    public URL getEntry(String path)

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateDeployer.java	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateDeployer.java	2009-10-02 22:54:52 UTC (rev 94302)
@@ -21,7 +21,6 @@
 */
 package org.jboss.osgi.framework.deployers;
 
-import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentStage;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
@@ -79,10 +78,6 @@
       
       OSGiBundleState bundleState = bundleManager.addDeployment(unit);
       unit.addAttachment(OSGiBundleState.class, bundleState);
-      
-      ControllerContext context = unit.getAttachment(ControllerContext.class);
-      if (context == null)
-         throw new IllegalStateException("Cannot obtain ControllerContext");
    }
 
    @Override

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java	2009-10-02 22:54:52 UTC (rev 94302)
@@ -77,6 +77,7 @@
       // Install autoInstall bundles
       for (URL bundleURL : autoInstall)
       {
+         
          Bundle bundle = bundleManager.install(bundleURL);
          autoBundles.put(bundleURL, bundle);
       }

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java	2009-10-02 22:54:52 UTC (rev 94302)
@@ -77,11 +77,11 @@
    }
    
    /**
-    * Deploys the bootstrap.xml bean descriptor to setup OSGi deployers
+    * Deploys the jboss-osgi-bootstrap.xml bean descriptor to setup OSGi deployers
     */
    protected void deploy() throws Exception
    {
-      String common = "/bootstrap/bootstrap.xml";
+      String common = "/META-INF/jboss-osgi-bootstrap.xml";
       URL url = getClass().getResource(common);
       if (url == null)
          throw new IllegalStateException(common + " not found");
@@ -202,7 +202,7 @@
     */
    public Bundle addBundle(VirtualFile file) throws Exception
    {
-      AbstractBundleState bundleState = getBundleManager().install(file);
+      AbstractBundleState bundleState = getBundleManager().install(file, null);
       return bundleState.getBundleInternal();
    }
 

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleUnitTestCase.java	2009-10-02 22:26:48 UTC (rev 94301)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleUnitTestCase.java	2009-10-02 22:54:52 UTC (rev 94302)
@@ -25,8 +25,6 @@
 import java.util.Hashtable;
 import java.util.jar.Attributes;
 
-import junit.framework.Test;
-
 import org.jboss.test.osgi.OSGiTestCase;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;

Copied: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml (from rev 94274, projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml)
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2009-10-02 22:54:52 UTC (rev 94302)
@@ -0,0 +1,172 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <!-- 
+  ********************************
+  *                              *  
+  *  OSGi Framework              *
+  *                              *
+  ********************************
+  -->
+  
+  <bean name="OSGiBundleManager" class="org.jboss.osgi.framework.bundle.OSGiBundleManager">
+    <constructor>
+      <parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
+      <parameter><inject bean="MainDeployer" /></parameter>
+    </constructor>
+    <property name="properties">
+      <map keyClass="java.lang.String" valueClass="java.lang.String">
+        <entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
+        <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+        <entry><key>org.osgi.framework.system.packages.extra</key><value>
+          org.jboss.logging;version=2.0,
+          org.jboss.osgi.spi.capability;version=1.0,
+          org.jboss.osgi.spi.logging;version=1.0,
+          org.jboss.osgi.spi.management;version=1.0,
+          org.jboss.osgi.spi.service;version=1.0,
+          org.jboss.osgi.spi.testing;version=1.0,
+          org.jboss.osgi.spi.util;version=1.0,
+          
+          org.osgi.framework,
+          org.osgi.framework.launch,
+          org.osgi.service.startlevel,
+          org.osgi.service.packageadmin
+        </value></entry>
+      </map>
+    </property>
+    <incallback method="addPlugin" />
+    <uncallback method="removePlugin" />
+  </bean>
+  
+  <!-- 
+  ********************************
+  *                              *  
+  *  OSGi Framework Plugins      *
+  *                              *
+  ********************************
+  -->
+  
+  <bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="OSGiStoragePlugin" class="org.jboss.osgi.framework.plugins.internal.BundleStoragePluginImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="OSGiSystemPackages" class="org.jboss.osgi.framework.plugins.internal.SystemPackagesPluginImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  
+  <!-- 
+  ********************************
+  *                              *  
+  *  OSGi Service Plugins        *
+  *                              *
+  ********************************
+  -->
+  
+  <bean name="MicrocontainerService" class="org.jboss.osgi.framework.service.internal.MicrocontainerServiceImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="StartLevelService" class="org.jboss.osgi.framework.service.internal.StartLevelImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="PackageAdminService" class="org.jboss.osgi.framework.service.internal.PackageAdminImpl">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  
+  <!--
+  ********************************
+  *                              *  
+  *  OSGi Deployment             *
+  *                              *
+  ********************************
+  -->
+  
+  <!-- The MainDeployer -->
+  <bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
+    <property name="structuralDeployers"><inject bean="StructuralDeployers" /></property>
+    <property name="deployers"><inject bean="Deployers" /></property>
+  </bean>
+
+  <!-- The holder for deployers that determine structure -->
+  <bean name="StructuralDeployers" class="org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl">
+    <property name="structureBuilder">
+      <!-- The consolidator of the structure information -->
+      <bean name="StructureBuilder" class="org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder" />
+    </property>
+    <!-- Accept any implementor of structure deployer -->
+    <incallback method="addDeployer" />
+    <uncallback method="removeDeployer" />
+  </bean>
+
+  <!-- The holder for deployers that do real deployment -->
+  <bean name="Deployers" class="org.jboss.deployers.plugins.deployers.DeployersImpl">
+    <constructor><parameter><inject bean="jboss.kernel:service=KernelController" /></parameter></constructor>
+    <!-- Accept any implementor of deployer -->
+    <incallback method="addDeployer" />
+    <uncallback method="removeDeployer" />
+  </bean>
+
+  <!-- Bundle Structure -->
+  <bean name="BundleStructure" class="org.jboss.osgi.deployer.BundleStructureDeployer" />
+  
+  <!-- JAR & File Structure (needed for negative testing) -->
+  <bean name="JARStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure" />
+  <bean name="FileStructure" class="org.jboss.deployers.vfs.plugins.structure.file.FileStructure" />
+
+  <!-- POJO Deployment -->
+  <bean name="BeanDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanDeployer" />
+  <bean name="KernelDeploymentDeployer" class="org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer" />
+  <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer">
+    <constructor>
+      <parameter class="org.jboss.dependency.spi.Controller"><inject bean="jboss.kernel:service=KernelController" /></parameter>
+    </constructor>
+  </bean>
+
+  <!-- OSGI Deployment -->
+  <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
+  <bean name="OSGiBundleStateDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateDeployer">
+    <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+  </bean>
+  <bean name="OSGiBundleActivatorDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer" />
+
+  <!--
+  ********************************
+  *                              *  
+  *  OSGi Classloading           *
+  *                              *
+  ********************************
+  -->
+  
+  <bean name="OSGiClassLoaderSystem" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderSystem" />
+  <bean name="OSGiClassLoaderDomain" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderDomain" >
+    <constructor><parameter>OSGiClassLoaderDomain</parameter></constructor>
+    <property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
+    <property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
+  </bean>
+  <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
+    <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+  </bean>
+  <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+    <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+    <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
+  </bean>
+   
+  <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+    <incallback method="addModule" state="Configured" />
+    <uncallback method="removeModule" state="Configured" />
+  </bean>
+  <bean name="ClassLoadingDefaultDeployer" class="org.jboss.deployers.plugins.classloading.ClassLoadingDefaultDeployer">
+    <property name="defaultMetaData">
+      <classloading xmlns="urn:jboss:classloading:1.0" export-all="NON_EMPTY" import-all="true" />
+    </property>
+  </bean>
+  <bean name="ClassLoaderClassPathDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderClassPathDeployer" />
+  <bean name="ClassLoaderDescribeDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+  </bean>
+  <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+    <property name="system"><inject bean="OSGiClassLoaderSystem" /></property>
+  </bean>
+
+</deployment>




More information about the jboss-cvs-commits mailing list