[jboss-cvs] JBossAS SVN: r99805 - in projects/jboss-osgi: projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 22 10:29:54 EST 2010


Author: thomas.diesler at jboss.com
Date: 2010-01-22 10:29:53 -0500 (Fri, 22 Jan 2010)
New Revision: 99805

Added:
   projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java
   projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java
Removed:
   projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiNativeCodePolicyDeployer.java
Modified:
   projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Log:
Add OSGiModuleDeployer
Initialize NativeLibraries when policy is created

Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2010-01-22 15:29:53 UTC (rev 99805)
@@ -180,7 +180,6 @@
   <bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
   <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
   <bean name="OSGiNativeCodeMetaDataDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodeMetaDataDeployer" />
-  <bean name="OSGiNativeCodePolicyDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodePolicyDeployer" />
 
   <!--
   ********************************
@@ -199,10 +198,18 @@
   <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.deployers.OSGiBundleClassLoadingDeployer">
+  <bean name="OSGiClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
+  <bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
+    <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+    <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
+  </bean>
+  <bean name="OSGiModuleDeployer" class="org.jboss.osgi.framework.deployers.OSGiModuleDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+  </bean>
+  <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
    
   <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
     <incallback method="addModule" state="Configured" />
@@ -214,9 +221,6 @@
     </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>

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java	2010-01-22 15:29:53 UTC (rev 99805)
@@ -23,11 +23,24 @@
 
 // $Id$
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.jboss.classloader.spi.NativeLibraryProvider;
 import org.jboss.classloading.spi.dependency.Module;
 import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
-import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
 import org.jboss.osgi.framework.bundle.AbstractBundleState;
 import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.metadata.NativeLibrary;
+import org.jboss.osgi.framework.metadata.NativeLibraryMetaData;
+import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
+import org.jboss.virtual.VFSUtils;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -38,31 +51,118 @@
  */
 public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
 {
-   public OSGiClassLoaderPolicy(AbstractBundleState bundleState, VirtualFile[] roots)
+   public OSGiClassLoaderPolicy(AbstractBundleState absBundleState, VirtualFile[] roots)
    {
       super(roots);
       
-      if (bundleState == null)
+      if (absBundleState == null)
          throw new IllegalArgumentException("Null bundleState");
 
-      if (bundleState instanceof AbstractDeployedBundleState)
+      if (absBundleState instanceof AbstractDeployedBundleState)
       {
-         AbstractDeployedBundleState depBundleState = (AbstractDeployedBundleState)bundleState;
+         AbstractDeployedBundleState depBundleState = (AbstractDeployedBundleState)absBundleState;
          Module module = depBundleState.getDeploymentUnit().getAttachment(Module.class);
-         if (module instanceof VFSDeploymentClassLoaderPolicyModule == false)
-            throw new IllegalStateException("Not an instance of VFSDeploymentClassLoaderPolicyModule: " + module);
+         if (module instanceof OSGiModule == false)
+            throw new IllegalStateException("Not an instance of OSGiModule: " + module);
 
-         VFSDeploymentClassLoaderPolicyModule vfsModule = (VFSDeploymentClassLoaderPolicyModule)module;
-         String[] packageNames = vfsModule.getPackageNames();
+         OSGiModule osgiModule = (OSGiModule)module;
+         String[] packageNames = osgiModule.getPackageNames();
          setExportedPackages(packageNames);
-         setIncluded(vfsModule.getIncluded());
-         setExcluded(vfsModule.getExcluded());
-         setExcludedExport(vfsModule.getExcludedExport());
-         setExportAll(vfsModule.getExportAll());
-         setImportAll(vfsModule.isImportAll());
-         setCacheable(vfsModule.isCacheable());
-         setBlackListable(vfsModule.isBlackListable());
-         setDelegates(vfsModule.getDelegates());
+         setIncluded(osgiModule.getIncluded());
+         setExcluded(osgiModule.getExcluded());
+         setExcludedExport(osgiModule.getExcludedExport());
+         setExportAll(osgiModule.getExportAll());
+         setImportAll(osgiModule.isImportAll());
+         setCacheable(osgiModule.isCacheable());
+         setBlackListable(osgiModule.isBlackListable());
+         setDelegates(osgiModule.getDelegates());
+
+         // NativeCode-Library handling
+         OSGiClassLoadingMetaData classLoadingMetaData = osgiModule.getClassLoadingMetaData();
+         NativeLibraryMetaData libMetaData = classLoadingMetaData.getNativeLibraries();
+         if (libMetaData != null && libMetaData.getNativeLibraries() != null)
+         {
+            OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
+            
+            // Add the native library mappings to the OSGiClassLoaderPolicy
+            for (NativeLibrary library : libMetaData.getNativeLibraries())
+            {
+               String libpath = library.getLibraryPath();
+               String libfile = new File(libpath).getName();
+               String libname = libfile.substring(0, libfile.lastIndexOf('.'));
+               
+               // Add the library provider to the policy
+               NativeLibraryProvider libProvider = new OSGiNativeLibraryProvider(bundleState, libname, libpath);
+               addNativeLibrary(libProvider);
+               
+               // [TODO] why does the TCK use 'Native' to mean 'libNative' ? 
+               if (libname.startsWith("lib"))
+               {
+                  libname = libname.substring(3);
+                  libProvider = new OSGiNativeLibraryProvider(bundleState, libname, libpath);
+                  addNativeLibrary(libProvider);
+               }
+            }
+         }
       }
    }
+
+   static class OSGiNativeLibraryProvider implements NativeLibraryProvider
+   {
+      private OSGiBundleState bundleState;
+      private String libpath;
+      private String libname;
+      private File libraryFile;
+      
+      OSGiNativeLibraryProvider(OSGiBundleState bundleState, String libname, String libpath)
+      {
+         this.bundleState = bundleState;
+         this.libpath = libpath;
+         this.libname = libname;
+         
+         // If a native code library in a selected native code clause cannot be found
+         // within the bundle then the bundle must fail to resolve
+         URL entryURL = bundleState.getEntry(libpath);
+         if (entryURL == null)
+            throw new IllegalStateException("Cannot find native library: " + libpath);
+      }
+      
+      public String getLibraryName()
+      {
+         return libname;
+      }
+
+      public String getLibraryPath()
+      {
+         return libpath;
+      }
+      
+      public File getLibraryLocation() throws IOException
+      {
+         if (libraryFile == null)
+         {
+            // Get the virtual file for entry for the library
+            VirtualFile fileSource = bundleState.getRoot().getChild(libpath);
+            
+            // Create a unique local file location
+            libraryFile = getUniqueLibraryFile(bundleState, libpath);
+            libraryFile.deleteOnExit();
+            
+            // Copy the native library to the bundle storage area
+            FileOutputStream fos = new FileOutputStream(libraryFile);
+            VFSUtils.copyStream(fileSource.openStream(), fos);
+            fos.close();
+         }
+         return libraryFile;
+      }
+
+      private File getUniqueLibraryFile(final OSGiBundleState bundleState, final String libpath)
+      {
+         OSGiBundleManager bundleManager = bundleState.getBundleManager();
+         String timestamp = new SimpleDateFormat("-yyyyMMdd-HHmmssSSS").format(new Date(bundleState.getLastModified()));
+         String uniquePath = new StringBuffer(libpath).insert(libpath.lastIndexOf("."), timestamp).toString();
+         BundleStoragePlugin plugin = bundleManager.getPlugin(BundleStoragePlugin.class);
+         return plugin.getDataFile(bundleState, uniquePath);
+      }
+   }
 }

Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java	2010-01-22 15:29:53 UTC (rev 99805)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.framework.classloading;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
+
+/**
+ * The {@link Module} that represents and OSGi bundle deployment.
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @version $Revision$
+ */
+public class OSGiModule extends VFSDeploymentClassLoaderPolicyModule
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private OSGiClassLoadingMetaData metaData;
+   
+   public OSGiModule(DeploymentUnit unit, ClassLoadingMetaData metaData)
+   {
+      super(unit);
+      
+      if (metaData instanceof OSGiClassLoadingMetaData == false)
+         throw new IllegalStateException("Not an instance of OSGiClassLoadingMetaData: " + metaData);
+      
+      this.metaData = (OSGiClassLoadingMetaData)metaData;
+   }
+
+   public OSGiClassLoadingMetaData getClassLoadingMetaData()
+   {
+      return metaData;
+   }
+}


Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java	2010-01-22 15:29:53 UTC (rev 99805)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.framework.deployers;
+
+import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer;
+import org.jboss.osgi.framework.classloading.OSGiModule;
+
+/**
+ * The OSGiModuleDeployer creates the {@link OSGiModule}.
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @version $Revision$
+ */
+public class OSGiModuleDeployer extends VFSClassLoaderDescribeDeployer
+{
+   @Override
+   protected ClassLoaderPolicyModule createModule(DeploymentUnit unit, ClassLoadingMetaData metaData) throws DeploymentException
+   {
+      return new OSGiModule(unit, metaData);
+   }
+}


Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiNativeCodePolicyDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiNativeCodePolicyDeployer.java	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiNativeCodePolicyDeployer.java	2010-01-22 15:29:53 UTC (rev 99805)
@@ -1,161 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-// $Id: $
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.jboss.classloader.spi.ClassLoaderPolicy;
-import org.jboss.classloader.spi.NativeLibraryProvider;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-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.structure.spi.ClassLoaderFactory;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
-import org.jboss.osgi.framework.metadata.NativeLibrary;
-import org.jboss.osgi.framework.metadata.NativeLibraryMetaData;
-import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A deployer that takes care of loading native code libraries.
- * 
- * @author Thomas.Diesler at jboss.com
- * @since 19-Dec-2009
- */
-public class OSGiNativeCodePolicyDeployer extends AbstractRealDeployer
-{
-   public OSGiNativeCodePolicyDeployer()
-   {
-      setInput(ClassLoaderFactory.class);
-      addInput(ClassLoaderPolicy.class);
-      addInput(OSGiBundleState.class);
-      setStage(DeploymentStages.CLASSLOADER);
-      setTopLevelOnly(true);
-   }
-
-   @Override
-   protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
-   {
-      AbstractBundleState absBundleState = unit.getAttachment(AbstractBundleState.class);
-      if (absBundleState == null)
-         throw new IllegalStateException("No bundle state");
-
-      OSGiClassLoadingMetaData classLoadingMetaData = (OSGiClassLoadingMetaData)unit.getAttachment(ClassLoadingMetaData.class);
-      NativeLibraryMetaData libMetaData = classLoadingMetaData.getNativeLibraries();
-      if (libMetaData == null || libMetaData.getNativeLibraries() == null)
-         return;
-
-      // Add the native library mappings to the OSGiClassLoaderPolicy
-      OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
-      ClassLoaderPolicy policy = (ClassLoaderPolicy)unit.getAttachment(ClassLoaderPolicy.class);
-      for (NativeLibrary library : libMetaData.getNativeLibraries())
-      {
-         String libpath = library.getLibraryPath();
-         String libfile = new File(libpath).getName();
-         String libname = libfile.substring(0, libfile.lastIndexOf('.'));
-         
-         // Add the library provider to the policy
-         NativeLibraryProvider libProvider = new OSGiNativeLibraryProvider(bundleState, libname, libpath);
-         policy.addNativeLibrary(libProvider);
-         
-         // [TODO] why does the TCK use 'Native' to mean 'libNative' ? 
-         if (libname.startsWith("lib"))
-         {
-            libname = libname.substring(3);
-            libProvider = new OSGiNativeLibraryProvider(bundleState, libname, libpath);
-            policy.addNativeLibrary(libProvider);
-         }
-      }
-   }
-   
-   static class OSGiNativeLibraryProvider implements NativeLibraryProvider
-   {
-      private OSGiBundleState bundleState;
-      private String libpath;
-      private String libname;
-      private File libraryFile;
-      
-      OSGiNativeLibraryProvider(OSGiBundleState bundleState, String libname, String libpath)
-      {
-         this.bundleState = bundleState;
-         this.libpath = libpath;
-         this.libname = libname;
-         
-         // If a native code library in a selected native code clause cannot be found
-         // within the bundle then the bundle must fail to resolve
-         URL entryURL = bundleState.getEntry(libpath);
-         if (entryURL == null)
-            throw new IllegalStateException("Cannot find native library: " + libpath);
-      }
-      
-      public String getLibraryName()
-      {
-         return libname;
-      }
-
-      public String getLibraryPath()
-      {
-         return libpath;
-      }
-      
-      public File getLibraryLocation() throws IOException
-      {
-         if (libraryFile == null)
-         {
-            // Get the virtual file for entry for the library
-            VirtualFile fileSource = bundleState.getRoot().getChild(libpath);
-            
-            // Create a unique local file location
-            libraryFile = getUniqueLibraryFile(bundleState, libpath);
-            libraryFile.deleteOnExit();
-            
-            // Copy the native library to the bundle storage area
-            FileOutputStream fos = new FileOutputStream(libraryFile);
-            VFSUtils.copyStream(fileSource.openStream(), fos);
-            fos.close();
-         }
-         return libraryFile;
-      }
-
-      private File getUniqueLibraryFile(final OSGiBundleState bundleState, final String libpath)
-      {
-         OSGiBundleManager bundleManager = bundleState.getBundleManager();
-         String timestamp = new SimpleDateFormat("-yyyyMMdd-HHmmssSSS").format(new Date(bundleState.getLastModified()));
-         String uniquePath = new StringBuffer(libpath).insert(libpath.lastIndexOf("."), timestamp).toString();
-         BundleStoragePlugin plugin = bundleManager.getPlugin(BundleStoragePlugin.class);
-         return plugin.getDataFile(bundleState, uniquePath);
-      }
-   }
-}

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java	2010-01-22 15:29:53 UTC (rev 99805)
@@ -26,8 +26,8 @@
 import org.jboss.osgi.spi.framework.OSGiBootstrap;
 import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
 import org.jboss.osgi.testing.OSGiTest;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -41,32 +41,31 @@
  */
 public class NativeCodeTestCase extends OSGiTest
 {
-   private Framework framework;
-   private BundleContext context;
+   private static Framework framework;
 
-   @Before
-   public void setUp() throws Exception
+   @BeforeClass
+   public static void beforeClass() throws Exception
    {
       OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
       framework = bootProvider.getFramework();
       framework.start();
-      
-      context = framework.getBundleContext();
    }
 
-   @After
-   public void tearDown() throws Exception
+   @AfterClass
+   public static void afterClass() throws Exception
    {
       if (framework != null)
       {
          framework.stop();
-         framework.waitForStop(5000);
+         framework = null;
       }
    }
 
    @Test
    public void testNativeCode() throws Exception
    {
+      BundleContext context = framework.getBundleContext();
+      
       Bundle bundleA = context.installBundle(getTestArchivePath("simple-nativecode.jar"));
       assertBundleState(Bundle.INSTALLED, bundleA.getState());
 

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml	2010-01-22 15:29:53 UTC (rev 99805)
@@ -153,7 +153,6 @@
   <bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
   <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
   <bean name="OSGiNativeCodeMetaDataDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodeMetaDataDeployer" />
-  <bean name="OSGiNativeCodePolicyDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodePolicyDeployer" />
 
   <!--
   ********************************
@@ -172,13 +171,17 @@
   <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.deployers.OSGiBundleClassLoadingDeployer">
+  <bean name="OSGiClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
   <bean name="OSGiFragmentClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentClassLoadingDeployer">
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+    <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
+  <bean name="OSGiModuleDeployer" class="org.jboss.osgi.framework.deployers.OSGiModuleDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+  </bean>
   <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
    
   <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
@@ -191,9 +194,6 @@
     </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>

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml	2010-01-22 15:29:53 UTC (rev 99805)
@@ -189,7 +189,6 @@
   <bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
   <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
   <bean name="OSGiNativeCodeMetaDataDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodeMetaDataDeployer" />
-  <bean name="OSGiNativeCodePolicyDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodePolicyDeployer" />
 
   <!--
   ********************************
@@ -199,15 +198,16 @@
   ********************************
   -->
   
+  <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="ClassLoaderSystem"/></property>
+    <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="ClassLoaderSystem"/></property>
+    <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
   </bean>
-  <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
+  <bean name="OSGiClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
@@ -215,6 +215,24 @@
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
+  <bean name="OSGiModuleDeployer" class="org.jboss.osgi.framework.deployers.OSGiModuleDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+  </bean>
   <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
+   
+  <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="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+    <property name="system"><inject bean="OSGiClassLoaderSystem" /></property>
+  </bean>
 
 </deployment>
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml	2010-01-22 15:29:53 UTC (rev 99805)
@@ -209,7 +209,6 @@
   <bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
   <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
   <bean name="OSGiNativeCodeMetaDataDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodeMetaDataDeployer" />
-  <bean name="OSGiNativeCodePolicyDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodePolicyDeployer" />
 
   <!--
   ********************************
@@ -228,7 +227,7 @@
   <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.deployers.OSGiBundleClassLoadingDeployer">
+  <bean name="OSGiClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
@@ -236,6 +235,9 @@
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
+  <bean name="OSGiModuleDeployer" class="org.jboss.osgi.framework.deployers.OSGiModuleDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+  </bean>
   <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
    
   <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
@@ -248,9 +250,6 @@
     </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>

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2010-01-22 15:29:53 UTC (rev 99805)
@@ -192,7 +192,6 @@
   <bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
   <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
   <bean name="OSGiNativeCodeMetaDataDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodeMetaDataDeployer" />
-  <bean name="OSGiNativeCodePolicyDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodePolicyDeployer" />
 
   <!--
   ********************************
@@ -211,7 +210,7 @@
   <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.deployers.OSGiBundleClassLoadingDeployer">
+  <bean name="OSGiClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
@@ -219,6 +218,9 @@
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
+  <bean name="OSGiModuleDeployer" class="org.jboss.osgi.framework.deployers.OSGiModuleDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+  </bean>
   <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
    
   <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
@@ -231,9 +233,6 @@
     </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>

Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2010-01-22 15:29:25 UTC (rev 99804)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml	2010-01-22 15:29:53 UTC (rev 99805)
@@ -81,7 +81,7 @@
   <bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
     <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
   </bean>
-  <bean name="OSGiServiceManager" class="org.jboss.osgi.framework.bundle.ServiceManagerPluginImpl">
+  <bean name="OSGiServiceManagerPlugin" class="org.jboss.osgi.framework.bundle.ServiceManagerPluginImpl">
     <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
   </bean>
   <bean name="OSGiStoragePlugin" class="org.jboss.osgi.framework.plugins.internal.BundleStoragePluginImpl">
@@ -179,7 +179,6 @@
   <bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
   <bean name="OSGiManifestParsingDeployer" class="org.jboss.osgi.framework.deployers.OSGiManifestParsingDeployer" />
   <bean name="OSGiNativeCodeMetaDataDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodeMetaDataDeployer" />
-  <bean name="OSGiNativeCodePolicyDeployer" class="org.jboss.osgi.framework.deployers.OSGiNativeCodePolicyDeployer" />
 
   <!--
   ********************************
@@ -198,7 +197,7 @@
   <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.deployers.OSGiBundleClassLoadingDeployer">
+  <bean name="OSGiClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
@@ -206,6 +205,9 @@
     <property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
     <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
   </bean>
+  <bean name="OSGiModuleDeployer" class="org.jboss.osgi.framework.deployers.OSGiModuleDeployer">
+    <property name="classLoading"><inject bean="ClassLoading" /></property>
+  </bean>
   <bean name="OSGiFragmentAttachmentDeployer" class="org.jboss.osgi.framework.deployers.OSGiFragmentAttachmentDeployer"/>
    
   <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
@@ -218,9 +220,6 @@
     </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>




More information about the jboss-cvs-commits mailing list