Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.osgi/resolver')
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java6
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java4
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java4
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java4
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java28
-rw-r--r--bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/VersionConstraintImpl.java34
6 files changed, 33 insertions, 47 deletions
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
index b928a918a..0e6f865d7 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverBundle.java
@@ -15,7 +15,7 @@ import java.util.Map.Entry;
import org.eclipse.osgi.internal.resolver.*;
import org.eclipse.osgi.service.resolver.*;
import org.osgi.framework.Constants;
-import org.osgi.framework.resource.ResourceConstants;
+import org.osgi.framework.namespace.IdentityNamespace;
/*
* A companion to BundleDescription from the state used while resolving.
@@ -71,7 +71,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
GenericDescription[] capabilities = getBundleDescription().getGenericCapabilities();
GenericCapability identity = null;
for (GenericDescription capability : capabilities) {
- if (ResourceConstants.IDENTITY_NAMESPACE.equals(capability.getType())) {
+ if (IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getType())) {
identity = new GenericCapability(this, capability);
break;
}
@@ -388,7 +388,7 @@ public class ResolverBundle extends VersionSupplier implements Comparable<Resolv
List<GenericCapability> hostCapabilities = new ArrayList<GenericCapability>(newGenericCapabilities.length);
if (newGenericCapabilities.length > 0 && dynamicAttach) {
for (GenericDescription capability : newGenericCapabilities) {
- if (!ResourceConstants.IDENTITY_NAMESPACE.equals(capability.getType())) {
+ if (!IdentityNamespace.IDENTITY_NAMESPACE.equals(capability.getType())) {
GenericDescription hostCapabililty = new GenericDescriptionImpl(getBundleDescription(), capability);
hostCapabilities.add(new GenericCapability(this, hostCapabililty));
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
index 346a7eda9..0f0653a66 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/module/ResolverImpl.java
@@ -27,7 +27,7 @@ import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.resource.ResourceConstants;
+import org.osgi.framework.namespace.IdentityNamespace;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRevision;
@@ -760,7 +760,7 @@ public class ResolverImpl implements Resolver {
}
private BundleCapability getIdentity(ResolverBundle bundle) {
- List<BundleCapability> identities = bundle.getBundleDescription().getDeclaredCapabilities(ResourceConstants.IDENTITY_NAMESPACE);
+ List<BundleCapability> identities = bundle.getBundleDescription().getDeclaredCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
return identities.size() == 1 ? identities.get(0) : bundle.getCapability();
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
index 233688919..73ca260b3 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/BundleDescriptionImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,8 +22,8 @@ import org.eclipse.osgi.framework.util.KeyedElement;
import org.eclipse.osgi.internal.loader.BundleLoaderProxy;
import org.eclipse.osgi.service.resolver.*;
import org.osgi.framework.*;
-import org.osgi.framework.resource.*;
import org.osgi.framework.wiring.*;
+import org.osgi.resource.*;
public final class BundleDescriptionImpl extends BaseDescriptionImpl implements BundleDescription, KeyedElement {
static final String[] EMPTY_STRING = new String[0];
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java
index 34a9c71ab..e887f0622 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/GenericSpecificationImpl.java
@@ -15,7 +15,7 @@ import java.util.*;
import org.eclipse.osgi.framework.internal.core.FilterImpl;
import org.eclipse.osgi.service.resolver.*;
import org.osgi.framework.*;
-import org.osgi.framework.resource.ResourceConstants;
+import org.osgi.resource.Namespace;
public class GenericSpecificationImpl extends VersionConstraintImpl implements GenericSpecification {
private Filter matchingFilter;
@@ -176,7 +176,7 @@ public class GenericSpecificationImpl extends VersionConstraintImpl implements G
if ((resolution & GenericSpecification.RESOLUTION_OPTIONAL) != 0)
result.put(Constants.RESOLUTION_DIRECTIVE, Constants.RESOLUTION_OPTIONAL);
if ((resolution & GenericSpecification.RESOLUTION_MULTIPLE) != 0)
- result.put(ResourceConstants.REQUIREMENT_CARDINALITY_DIRECTIVE, ResourceConstants.REQUIREMENT_CARDINALITY_MULTIPLE);
+ result.put(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_MULTIPLE);
if (matchingFilter != null) {
result.put(Constants.FILTER_DIRECTIVE, matchingFilter.toString());
}
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
index bde0d203f..b6964980a 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/StateBuilder.java
@@ -20,7 +20,9 @@ import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.*;
-import org.osgi.framework.resource.ResourceConstants;
+import org.osgi.framework.namespace.BundleNamespace;
+import org.osgi.framework.namespace.IdentityNamespace;
+import org.osgi.resource.Namespace;
/**
* This class builds bundle description objects from manifests
@@ -33,7 +35,7 @@ public class StateBuilder {
private static final String[] DEFINED_FRAGMENT_HOST_DIRECTIVES = {Constants.EXTENSION_DIRECTIVE};
static final String[] DEFINED_BSN_DIRECTIVES = {Constants.SINGLETON_DIRECTIVE, Constants.FRAGMENT_ATTACHMENT_DIRECTIVE, Constants.MANDATORY_DIRECTIVE};
static final String[] DEFINED_BSN_MATCHING_ATTRS = {Constants.BUNDLE_VERSION_ATTRIBUTE, Constants.OPTIONAL_ATTRIBUTE, Constants.REPROVIDE_ATTRIBUTE};
- private static final String[] DEFINED_REQUIRE_CAPABILITY_DIRECTIVES = {Constants.RESOLUTION_DIRECTIVE, Constants.FILTER_DIRECTIVE, ResourceConstants.REQUIREMENT_CARDINALITY_DIRECTIVE};
+ private static final String[] DEFINED_REQUIRE_CAPABILITY_DIRECTIVES = {Constants.RESOLUTION_DIRECTIVE, Constants.FILTER_DIRECTIVE, Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE};
private static final String[] DEFINED_REQUIRE_CAPABILITY_ATTRS = {};
private static final String[] DEFINED_OSGI_VALIDATE_HEADERS = {Constants.IMPORT_PACKAGE, Constants.DYNAMICIMPORT_PACKAGE, Constants.EXPORT_PACKAGE, Constants.FRAGMENT_HOST, Constants.BUNDLE_SYMBOLICNAME, Constants.REQUIRE_BUNDLE};
static final String GENERIC_REQUIRE = "Eclipse-GenericRequire"; //$NON-NLS-1$
@@ -628,8 +630,8 @@ public class StateBuilder {
int resolution = 0;
if (Constants.RESOLUTION_OPTIONAL.equals(resolutionDirective))
resolution |= GenericSpecification.RESOLUTION_OPTIONAL;
- String cardinality = element.getDirective(ResourceConstants.REQUIREMENT_CARDINALITY_DIRECTIVE);
- if (ResourceConstants.REQUIREMENT_CARDINALITY_MULTIPLE.equals(cardinality))
+ String cardinality = element.getDirective(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE);
+ if (Namespace.CARDINALITY_MULTIPLE.equals(cardinality))
resolution |= GenericSpecification.RESOLUTION_MULTIPLE;
spec.setResolution(resolution);
spec.setAttributes(getAttributes(element, DEFINED_REQUIRE_CAPABILITY_ATTRS));
@@ -700,8 +702,8 @@ public class StateBuilder {
for (ManifestElement element : osgiCapabilities) {
String[] namespaces = element.getValueComponents();
for (String namespace : namespaces) {
- if (ResourceConstants.IDENTITY_NAMESPACE.equals(namespace))
- throw new BundleException("A bundle is not allowed to define a capability in the " + ResourceConstants.IDENTITY_NAMESPACE + " name space."); //$NON-NLS-1$ //$NON-NLS-2$
+ if (IdentityNamespace.IDENTITY_NAMESPACE.equals(namespace))
+ throw new BundleException("A bundle is not allowed to define a capability in the " + IdentityNamespace.IDENTITY_NAMESPACE + " name space."); //$NON-NLS-1$ //$NON-NLS-2$
GenericDescriptionImpl desc = new GenericDescriptionImpl();
desc.setType(namespace);
@@ -737,8 +739,8 @@ public class StateBuilder {
if (colonIdx > 0) {
name = genericNames[j].substring(0, colonIdx);
desc.setType(genericNames[j].substring(colonIdx + 1));
- if (ResourceConstants.IDENTITY_NAMESPACE.equals(desc.getType()))
- throw new BundleException("A bundle is not allowed to define a capability in the " + ResourceConstants.IDENTITY_NAMESPACE + " name space."); //$NON-NLS-1$ //$NON-NLS-2$
+ if (IdentityNamespace.IDENTITY_NAMESPACE.equals(desc.getType()))
+ throw new BundleException("A bundle is not allowed to define a capability in the " + IdentityNamespace.IDENTITY_NAMESPACE + " name space."); //$NON-NLS-1$ //$NON-NLS-2$
}
Map<String, Object> mapAttrs = getAttributes(equinoxCapabilities[i], new String[] {Constants.VERSION_ATTRIBUTE});
Dictionary<String, Object> attrs = mapAttrs == null ? new Hashtable<String, Object>() : new Hashtable<String, Object>(mapAttrs);
@@ -888,14 +890,14 @@ public class StateBuilder {
if (description.getSymbolicName() == null)
return null;
GenericDescriptionImpl result = new GenericDescriptionImpl();
- result.setType(ResourceConstants.IDENTITY_NAMESPACE);
+ result.setType(IdentityNamespace.IDENTITY_NAMESPACE);
Dictionary<String, Object> attributes = new Hashtable<String, Object>(description.getDeclaredAttributes());
// remove osgi.wiring.bundle and bundle-version attributes
- attributes.remove(ResourceConstants.WIRING_BUNDLE_NAMESPACE);
+ attributes.remove(BundleNamespace.BUNDLE_NAMESPACE);
attributes.remove(Constants.BUNDLE_VERSION_ATTRIBUTE);
- attributes.put(ResourceConstants.IDENTITY_NAMESPACE, description.getSymbolicName());
- attributes.put(ResourceConstants.IDENTITY_TYPE_ATTRIBUTE, description.getHost() == null ? ResourceConstants.IDENTITY_TYPE_BUNDLE : ResourceConstants.IDENTITY_TYPE_FRAGMENT);
- attributes.put(ResourceConstants.IDENTITY_VERSION_ATTRIBUTE, description.getVersion());
+ attributes.put(IdentityNamespace.IDENTITY_NAMESPACE, description.getSymbolicName());
+ attributes.put(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, description.getHost() == null ? IdentityNamespace.TYPE_BUNDLE : IdentityNamespace.TYPE_FRAGMENT);
+ attributes.put(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, description.getVersion());
result.setAttributes(attributes);
Map<String, String> directives = new HashMap<String, String>(description.getDeclaredDirectives());
// remove defaults directive values
diff --git a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/VersionConstraintImpl.java b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/VersionConstraintImpl.java
index 34f7698b6..1cc7e5eeb 100644
--- a/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/VersionConstraintImpl.java
+++ b/bundles/org.eclipse.osgi/resolver/src/org/eclipse/osgi/internal/resolver/VersionConstraintImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,13 +17,14 @@ import java.util.Map;
import org.eclipse.osgi.framework.internal.core.Constants;
import org.eclipse.osgi.internal.resolver.BaseDescriptionImpl.BaseCapability;
import org.eclipse.osgi.service.resolver.*;
-import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.service.resolver.extras.SpecificationReference;
import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.*;
-import org.osgi.framework.resource.Capability;
-import org.osgi.framework.resource.ResourceConstants;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.namespace.AbstractWiringNamespace;
import org.osgi.framework.wiring.*;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Namespace;
abstract class VersionConstraintImpl implements VersionConstraint {
@@ -179,14 +180,14 @@ abstract class VersionConstraintImpl implements VersionConstraint {
// now we must do the generic thing
if (!namespace.equals(capability.getNamespace()))
return false;
- String filterSpec = getDirectives().get(ResourceConstants.REQUIREMENT_FILTER_DIRECTIVE);
+ String filterSpec = getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE);
try {
if (filterSpec != null && !FrameworkUtil.createFilter(filterSpec).matches(capability.getAttributes()))
return false;
} catch (InvalidSyntaxException e) {
return false;
}
- return hasMandatoryAttributes(ManifestElement.getArrayFromList(capability.getDirectives().get(ResourceConstants.CAPABILITY_MANDATORY_DIRECTIVE)));
+ return hasMandatoryAttributes(ManifestElement.getArrayFromList(capability.getDirectives().get(AbstractWiringNamespace.CAPABILITY_MANDATORY_DIRECTIVE)));
}
public BundleRevision getResource() {
@@ -209,27 +210,10 @@ abstract class VersionConstraintImpl implements VersionConstraint {
return addFilterAttribute(filter, attr, value, true);
}
- static private final Version MAX_VERSION = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
-
- // TODO this is coupled to the implementation detail of version range for open range check
- // TODO we need to create a new method on VersionRange to get a filter string and likely should add a FilterBuilder.
static StringBuffer addFilterAttribute(StringBuffer filter, String attr, Object value, boolean escapeWildCard) {
if (value instanceof VersionRange) {
VersionRange range = (VersionRange) value;
- if (range.getIncludeMinimum()) {
- filter.append('(').append(attr).append(">=").append(escapeValue(range.getMinimum(), escapeWildCard)).append(')'); //$NON-NLS-1$
- } else {
- filter.append("(!(").append(attr).append("<=").append(escapeValue(range.getMinimum(), escapeWildCard)).append("))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- // only include the maximum check if this is not an open range
- // this check is a bit hacky because we have no method on VersionRange to check if the range really is open
- if (!(MAX_VERSION.equals(range.getMaximum()) && range.getIncludeMaximum())) {
- if (range.getIncludeMaximum()) {
- filter.append('(').append(attr).append("<=").append(escapeValue(range.getMaximum(), escapeWildCard)).append(')'); //$NON-NLS-1$
- } else {
- filter.append("(!(").append(attr).append(">=").append(escapeValue(range.getMaximum(), escapeWildCard)).append("))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
+ filter.append(range.toFilterString(attr));
} else {
filter.append('(').append(attr).append('=').append(escapeValue(value, escapeWildCard)).append(')');
}

Back to the top