[jboss-cvs] JBossAS SVN: r73047 - in projects/jboss-osgi/trunk: osgi-int/src/main/org/jboss/osgi/plugins and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 5 00:20:21 EDT 2008


Author: alesj
Date: 2008-05-05 00:20:20 -0400 (Mon, 05 May 2008)
New Revision: 73047

Added:
   projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaData2ClassLoadingMetaDataDeployer.java
   projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/
   projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionComparator.java
   projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionToStringComparator.java
   projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionToVersionComparator.java
Modified:
   projects/jboss-osgi/trunk/build/pom.xml
   projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java
   projects/jboss-osgi/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml
Log:
Version comparators.
MetaData transformer.
Update of dependencies.

Modified: projects/jboss-osgi/trunk/build/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/build/pom.xml	2008-05-05 02:43:37 UTC (rev 73046)
+++ projects/jboss-osgi/trunk/build/pom.xml	2008-05-05 04:20:20 UTC (rev 73047)
@@ -31,13 +31,13 @@
   </scm>
 
   <properties>
-    <version.jboss.microcontainer>2.0.0.Beta13</version.jboss.microcontainer>
-    <version.jboss.deployers>2.0.0.Beta13</version.jboss.deployers>
+    <version.jboss.microcontainer>2.0.0.Beta14</version.jboss.microcontainer>
+    <version.jboss.deployers>2.0.0.Beta15</version.jboss.deployers>
     <version.jboss.common.core>2.2.4.GA</version.jboss.common.core>
     <version.jboss.common.logging.spi>2.0.4.GA</version.jboss.common.logging.spi>
     <version.jboss.common.logging.log4j>2.0.4.GA</version.jboss.common.logging.log4j>
     <version.osgi.r4.core>1.0</version.osgi.r4.core>
-    <version.jboss.aop>2.0.0.CR8</version.jboss.aop>
+    <version.jboss.aop>2.0.0.CR9</version.jboss.aop>
     <version.org.jboss.test>1.0.5.GA</version.org.jboss.test>
     <version.junit>4.4</version.junit>
   </properties>

Copied: projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaData2ClassLoadingMetaDataDeployer.java (from rev 71436, projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java)
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaData2ClassLoadingMetaDataDeployer.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaData2ClassLoadingMetaDataDeployer.java	2008-05-05 04:20:20 UTC (rev 73047)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classloading.plugins.metadata.PackageCapability;
+import org.jboss.classloading.plugins.metadata.PackageRequirement;
+import org.jboss.classloading.spi.metadata.Capability;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.version.VersionComparatorRegistry;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.plugins.version.OSGiVersionComparator;
+import org.jboss.osgi.plugins.version.OSGiVersionToStringComparator;
+import org.jboss.osgi.plugins.version.OSGiVersionToVersionComparator;
+import org.jboss.osgi.spi.metadata.OSGiMetaData;
+import org.jboss.osgi.spi.metadata.PackageAttribute;
+import org.jboss.osgi.spi.metadata.VersionRange;
+import org.jboss.reflect.spi.PackageInfo;
+import org.osgi.framework.Version;
+
+/**
+ * Create ClassLoading metadat from OSGi metadata.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiMetaData2ClassLoadingMetaDataDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
+{
+   static
+   {
+      VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
+      registry.registerVersionComparator(Version.class, OSGiVersionComparator.INSTANCE);
+      registry.registerVersionComparator(Version.class, String.class, OSGiVersionToStringComparator.INSTANCE);
+      registry.registerVersionComparator(Version.class, org.jboss.classloading.spi.version.Version.class, OSGiVersionToVersionComparator.INSTANCE);
+   }
+
+   public OSGiMetaData2ClassLoadingMetaDataDeployer()
+   {
+      super(OSGiMetaData.class);
+      setOutput(ClassLoadingMetaData.class);
+      setStage(DeploymentStages.DESCRIBE);
+   }
+
+   public void deploy(DeploymentUnit unit, OSGiMetaData deployment) throws DeploymentException
+   {
+      ClassLoadingMetaData clmd = new ClassLoadingMetaData();
+      clmd.setName(unit.getSimpleName());
+      Version bundleVersion = deployment.getBundleVersion();
+      if (bundleVersion != null)
+         clmd.setVersion(bundleVersion);
+      clmd.setDomain(deployment.getBundleName()); // todo
+      List<PackageAttribute> exports = deployment.getExportPackages();
+      if (exports != null && exports.isEmpty() == false)
+      {
+         List<Capability> capabilities = new ArrayList<Capability>(exports.size());
+         for (PackageAttribute pa : exports)
+         {
+            PackageInfo pi = pa.getPackageInfo();
+            VersionRange vr = pa.getVersion();
+            capabilities.add(new PackageCapability(pi.getName(), vr.getCeiling()));
+         }
+         clmd.setCapabilities(capabilities);
+      }
+      List<PackageAttribute> imports = deployment.getImportPackages();
+      if (imports != null && imports.isEmpty() == false)
+      {
+         List<Requirement> requirements = new ArrayList<Requirement>(imports.size());
+         for (PackageAttribute pa : imports)
+         {
+            PackageInfo pi = pa.getPackageInfo();
+            VersionRange vr = pa.getVersion();
+            org.jboss.classloading.spi.version.VersionRange versionRange = new org.jboss.classloading.spi.version.VersionRange(vr.getCeiling(), vr.getFloor());
+            requirements.add(new PackageRequirement(pi.getName(), versionRange));
+         }
+         clmd.setRequirements(requirements);
+      }
+      clmd.setImportAll(imports == null || imports.isEmpty());
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java	2008-05-05 02:43:37 UTC (rev 73046)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/deployers/OSGiMetaDataDeployer.java	2008-05-05 04:20:20 UTC (rev 73047)
@@ -34,14 +34,13 @@
  */
 public class OSGiMetaDataDeployer extends ManifestDeployer<OSGiMetaData>
 {
-   public OSGiMetaDataDeployer(Class<OSGiMetaData> deploymentType)
+   public OSGiMetaDataDeployer()
    {
-      super(deploymentType);
+      super(OSGiMetaData.class);
    }
 
    protected OSGiMetaData createMetaData(Manifest manifest) throws Exception
    {
       return new AbstractOSGiMetaData(manifest);
    }
-
 }

Added: projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionComparator.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionComparator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionComparator.java	2008-05-05 04:20:20 UTC (rev 73047)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.version;
+
+import org.jboss.classloading.spi.version.VersionComparator;
+import org.osgi.framework.Version;
+
+/**
+ * OSGi version comparator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiVersionComparator implements VersionComparator<Version, Version>
+{
+   public static final VersionComparator<Version, Version> INSTANCE = new OSGiVersionComparator();
+
+   public int compare(Version one, Version two)
+   {
+      return one.compareTo(two);
+   }
+}
\ No newline at end of file

Added: projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionToStringComparator.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionToStringComparator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionToStringComparator.java	2008-05-05 04:20:20 UTC (rev 73047)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.plugins.version;
+
+import org.jboss.classloading.spi.version.VersionComparator;
+import org.osgi.framework.Version;
+
+/**
+ * OSGi version to String version comparator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiVersionToStringComparator implements VersionComparator<Version, String>
+{
+   public static final VersionComparator<Version,String> INSTANCE = new OSGiVersionToStringComparator();
+
+   public int compare(Version one, String two)
+   {
+      return one.compareTo(Version.parseVersion(two));
+   }
+}

Added: projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionToVersionComparator.java
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionToVersionComparator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/osgi-int/src/main/org/jboss/osgi/plugins/version/OSGiVersionToVersionComparator.java	2008-05-05 04:20:20 UTC (rev 73047)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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 two.
+*
+* 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.plugins.version;
+
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.classloading.spi.version.VersionComparator;
+
+/**
+ * OSGi two to JBoss two comparator.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class OSGiVersionToVersionComparator implements VersionComparator<org.osgi.framework.Version, Version>
+{
+   public static final VersionComparator<org.osgi.framework.Version, Version> INSTANCE = new OSGiVersionToVersionComparator();
+
+   public int compare(org.osgi.framework.Version one, Version two)
+   {
+      int result = one.getMajor() - two.getMajor();
+      if (result != 0)
+         return result;
+
+      result = one.getMinor() - two.getMinor();
+      if (result != 0)
+         return result;
+
+      result = one.getMicro() - two.getMicro();
+      if (result != 0)
+         return result;
+
+      String q1 = one.getQualifier();
+      String q2 = two.getQualifier();
+      if (q1 != null &&  q2 != null)
+         return q1.compareTo(q2);
+      return 0;
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml	2008-05-05 02:43:37 UTC (rev 73046)
+++ projects/jboss-osgi/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml	2008-05-05 04:20:20 UTC (rev 73047)
@@ -100,9 +100,7 @@
    <bean name="BundleActivatorDeployer" class="org.jboss.osgi.plugins.deployers.BundleActivatorDeployer">
    	  <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
    </bean>
-   <bean name="OSGIMetaDataDeployer" class="org.jboss.osgi.plugins.deployers.OSGiMetaDataDeployer">
-      <constructor><parameter>org.jboss.osgi.spi.metadata.OSGiMetaData</parameter></constructor>
-   </bean>
+   <bean name="OSGIMetaDataDeployer" class="org.jboss.osgi.plugins.deployers.OSGiMetaDataDeployer"/>
 
    <!-- VFS ClassLoader -->
    <bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">




More information about the jboss-cvs-commits mailing list