aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1187486 - in /aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core: archive/SubsystemContentHeader.java archive/VersionRangeAttribute.java internal/OsgiIdentityRequirement.java
Date Fri, 21 Oct 2011 18:26:01 GMT
Author: jwross
Date: Fri Oct 21 18:26:00 2011
New Revision: 1187486

URL: http://svn.apache.org/viewvc?rev=1187486&view=rev
Log:
ARIES-763: Remove OSGi VersionRange dependency.

Removed dependency on org.osgi.framework.VersionRange. Replaced with org.apache.aries.util.VersionRange.

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemContentHeader.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionRangeAttribute.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/OsgiIdentityRequirement.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemContentHeader.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemContentHeader.java?rev=1187486&r1=1187485&r2=1187486&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemContentHeader.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemContentHeader.java
Fri Oct 21 18:26:00 2011
@@ -19,9 +19,9 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 
+import org.apache.aries.util.VersionRange;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
-import org.osgi.framework.VersionRange;
 
 public class SubsystemContentHeader extends AbstractHeader {
 	public static class Content {

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionRangeAttribute.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionRangeAttribute.java?rev=1187486&r1=1187485&r2=1187486&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionRangeAttribute.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/VersionRangeAttribute.java
Fri Oct 21 18:26:00 2011
@@ -13,11 +13,32 @@
  */
 package org.apache.aries.subsystem.core.archive;
 
+import org.apache.aries.util.VersionRange;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
-import org.osgi.framework.VersionRange;
 
 public class VersionRangeAttribute extends AbstractAttribute {
+	public static String toFilterString(VersionRange range) {
+		String version = Constants.VERSION_ATTRIBUTE;
+		Version min = range.getMinimumVersion();
+		Version max = range.getMaximumVersion();
+		StringBuilder sb = new StringBuilder();
+		if (max != null)
+			sb.append("(&");
+		if (range.isMinimumExclusive())
+			sb.append("(!(").append(version).append("<=").append(min).append("))");
+		else
+			sb.append('(').append(version).append(">=").append(min).append(')');
+		if (max != null) {
+			if (range.isMaximumExclusive())
+				sb.append("(!(").append(version).append(">=").append(range.getMaximumVersion()).append("))");
+			else
+				sb.append('(').append(version).append("<=").append(max).append(')');
+			sb.append(')');
+		}
+		return sb.toString();
+	}
+	
 	private final VersionRange range;
 	
 	public VersionRangeAttribute() {
@@ -31,7 +52,7 @@ public class VersionRangeAttribute exten
 	}
 	
 	public StringBuilder appendToFilter(StringBuilder builder) {
-		return builder.append(range.toFilterString(Constants.VERSION_ATTRIBUTE));
+		return builder.append(toFilterString(range));
 	}
 
 	public VersionRange getVersionRange() {

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/OsgiIdentityRequirement.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/OsgiIdentityRequirement.java?rev=1187486&r1=1187485&r2=1187486&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/OsgiIdentityRequirement.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/OsgiIdentityRequirement.java
Fri Oct 21 18:26:00 2011
@@ -17,12 +17,13 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.aries.subsystem.core.archive.VersionRangeAttribute;
+import org.apache.aries.util.VersionRange;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.Version;
-import org.osgi.framework.VersionRange;
 import org.osgi.framework.resource.Capability;
 import org.osgi.framework.resource.Requirement;
 import org.osgi.framework.resource.Resource;
@@ -46,7 +47,7 @@ public class OsgiIdentityRequirement imp
 	private static Filter createFilter(String symbolicName, VersionRange versionRange, String
type) {
 		return createFilter(
 				symbolicName,
-				versionRange.toFilterString(ResourceConstants.IDENTITY_VERSION_ATTRIBUTE),
+				VersionRangeAttribute.toFilterString(versionRange),
 				type);
 	}
 	



Mime
View raw message