You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by jw...@apache.org on 2012/03/06 22:03:36 UTC
svn commit: r1297721 - in /aries/trunk/subsystem:
subsystem-api/src/main/java/org/osgi/service/repository/
subsystem-api/src/main/java/org/osgi/service/resolver/
subsystem-api/src/main/java/org/osgi/service/subsystem/
subsystem-core/src/main/java/org/a...
Author: jwross
Date: Tue Mar 6 21:03:35 2012
New Revision: 1297721
URL: http://svn.apache.org/viewvc?rev=1297721&view=rev
Log:
ARIES-825: Update subsystems to latest Subsystem, Resolver, and Repository APIs.
(1) Updated Subsystems, Resolver, and Repository APIs to the latest.
(2) Fixed compile errors.
Added:
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolveContext.java
Removed:
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/Environment.java
Modified:
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/ContentNamespace.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/Repository.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/RepositoryContent.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/HostedCapability.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolutionException.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/Resolver.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/Subsystem.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/felix/FelixResourceAdapter.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemFileResource.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemStreamResource.java
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepositoryContent.java
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/ContentNamespace.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/ContentNamespace.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/ContentNamespace.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/ContentNamespace.java Tue Mar 6 21:03:35 2012
@@ -28,10 +28,8 @@ import org.osgi.resource.Namespace;
* associated with the specified directive and attribute keys are of type
* {@code String}, unless otherwise indicated.
*
- * TODO ### Not sure this is complete. Needs to by synced with 132.4.
- *
* @Immutable
- * @version $Id: 67140e8968223906b03ef68fbfff653020e564fb $
+ * @version $Id: 24fa1339b403f5e6fb8b1f639bedc8917744713e $
*/
public final class ContentNamespace extends Namespace {
@@ -42,50 +40,24 @@ public final class ContentNamespace exte
* Also, the capability attribute used to specify the unique identifier of
* the content. This identifier is the {@code SHA-256} hash of the content.
*/
- public static final String CONTENT_NAMESPACE = "osgi.content";
-
- /**
- * The mandatory capability attribute that contains the size, in bytes, of
- * the content. The value of this attribute must be of type {@code Long}.
- */
- public final String CAPABILITY_SIZE_ATTRIBUTE = "size";
-
- /**
- * The capability attribute that contains a human readable copyright notice.
- */
- public final String CAPABILITY_COPYRIGHT_ATTRIBUTE = "copyright";
-
- /**
- * The capability attribute that contains a human readable description.
- */
- public final String CAPABILITY_DESCRIPTION_ATTRIBUTE = "description";
+ public static final String CONTENT_NAMESPACE = "osgi.content";
/**
- * The capability attribute that contains a reference to the resource
- * containing the documentation for the content.
- *
+ * The capability attribute that contains the URL to the content.
*/
- public final String CAPABILITY_DOCUMENTATION_ATTRIBUTE = "documentation";
+ public static final String CAPABILITY_URL_ATTRIBUTE = "url";
/**
- * The capability attribute that contains the license name of the resource as
- * defined in the Bundle-License header.
+ * The capability attribute that contains the size, in bytes, of the
+ * content. The value of this attribute must be of type {@code Long}.
*/
- public final String CAPABILITY_LICENSE_ATTRIBUTE = "license";
+ public static final String CAPABILITY_SIZE_ATTRIBUTE = "size";
/**
* The capability attribute that defines the IANA MIME Type/Format for this
* content.
- *
- */
- public final String CAPABILITY_MIME_ATTRIBUTE = "mime";
-
- /**
- * A Requirement Directive that specifies that this Requirement is a
- * relation to another Resource with the given content type.
- *
*/
- public final String REQUIREMENT_RELATION_DIRECTIVE = "relation";
+ public static final String CAPABILITY_MIME_ATTRIBUTE = "mime";
private ContentNamespace() {
// empty
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/Repository.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/Repository.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/Repository.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/Repository.java Tue Mar 6 21:03:35 2012
@@ -28,18 +28,18 @@ import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
/**
- * Represents a repository that contains {@link Resource resources}.
+ * A repository service that contains {@link Resource resources}.
*
* <p>
- * Repositories may be registered as services and may be used as inputs to
- * resolver operations.
+ * Repositories may be registered as services and may be used as by a resolve
+ * context during resolver operations.
*
* <p>
* Repositories registered as services may be filtered using standard service
* properties.
*
* @ThreadSafe
- * @version $Id: ed526d7ce615bed833c679eb154f1b2ee57ff8fa $
+ * @version $Id: 556d89153e612c5188c74e62004fdcacdd62949e $
*/
public interface Repository {
/**
@@ -48,20 +48,16 @@ public interface Repository {
String URL = "repository.url";
/**
- * Find any capabilities that match the supplied requirements.
+ * Find the capabilities that match the specified requirements.
*
- * <p>
- * See the Resolver specification for a discussion on matching.
- *
- * @param requirements the requirements that should be matched
- *
- * @return A map of requirements to capabilities that match the supplied
- * requirements
- *
- *
- * ### is it guaranteed that each Requirement given is in the returned map?
- *
- * @throws NullPointerException if requirements is null
+ * @param requirements The requirements for which matching capabilities
+ * should be returned. Must not be {@code null}.
+ * @return A map of matching capabilities for the specified requirements.
+ * Each specified requirement must appear as a key in the map. If
+ * there are no matching capabilities for a specified requirement,
+ * then the value in the map for the specified requirement must be
+ * an empty collection. The returned map is the property of the
+ * caller and can be modified by the caller.
*/
Map<Requirement, Collection<Capability>> findProviders(
Collection< ? extends Requirement> requirements);
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/RepositoryContent.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/RepositoryContent.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/RepositoryContent.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/repository/RepositoryContent.java Tue Mar 6 21:03:35 2012
@@ -16,31 +16,27 @@
package org.osgi.service.repository;
-import java.io.*;
+import java.io.InputStream;
-import org.osgi.resource.*;
+import org.osgi.resource.Resource;
/**
- * An accessor for the content of a resource.
+ * An accessor for the default content of a resource.
*
* All {@link Resource} objects which represent resources in a
* {@link Repository} must implement this interface. A user of the resource can
* then cast the {@link Resource} object to this type and then obtain an
- * {@code InputStream} to the content of the resource.
+ * {@code InputStream} to the default content of the resource.
*
* @ThreadSafe
- * @version $Id: 45eb6e8f54d08d5491a342bfafbcc9b6465f06e0 $
+ * @version $Id: ec32a007f35510827791c7e5af99f3c5d579ce87 $
*/
public interface RepositoryContent {
/**
- * Returns a new input stream to the underlying artifact for the associated
- * resource. The given osgiContent must map to the SHA-256 that is stored
- * in the {@code osgi.content} Capability under {@code osgi.content}.
- *
- * @param osgiContent The SHA-256 of the content
+ * Returns a new input stream to the default format of this resource.
*
* @return A new input stream for associated resource.
*/
- InputStream getContent(String osgiContent) throws IOException;
+ InputStream getContent();
}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/HostedCapability.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/HostedCapability.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/HostedCapability.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/HostedCapability.java Tue Mar 6 21:03:35 2012
@@ -20,30 +20,34 @@ import org.osgi.resource.Capability;
import org.osgi.resource.Resource;
/**
+ * A capability hosted by a resource.
+ *
+ * <p>
* A HostedCapability is a Capability where the {@link #getResource()} method
* returns a Resource that hosts this Capability instead of declaring it. This
* is necessary for cases where the declared Resource of a Capability does not
- * match the runtime state. This is for example the case for fragments, when a fragment
- * attaches a host, most of its Capabilities and Requirements become hosted by
- * the attached host. Since a fragment can attach multiple hosts, a single
- * Capability can actually be hosted multiple times.
+ * match the runtime state. For example, this is the case for fragments attached
+ * to a host. Most of the fragments declared capabilities and requirements
+ * become hosted by the host resource. Since a fragment can attach to multiple
+ * hosts, a single capability can actually be hosted multiple times.
*
* @Threadsafe
- * @version $Id: 38f5d2b31ef4bfe805a207a87d452672a9ac5178 $
+ * @noimplement
+ * @version $Id: 01fa0dde20b8999c01ad2e6c01f36ce45f8ee7af $
*/
public interface HostedCapability extends Capability {
/**
* Return the Resource that hosts this Capability.
*
- * @return the hosting Resource
+ * @return The Resource that hosts this Capability.
*/
Resource getResource();
/**
- * Return the Capability of this HostedCapability.
+ * Return the Capability hosted by the Resource.
*
- * @return the Capability
+ * @return The Capability hosted by the Resource.
*/
Capability getDeclaredCapability();
}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolutionException.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolutionException.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolutionException.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolutionException.java Tue Mar 6 21:03:35 2012
@@ -34,8 +34,10 @@ import org.osgi.resource.Requirement;
* <p>
* Resolver implementations may extend this class to provide extra state
* information about the reason for the resolution failure.
+ *
+ * @version $Id: 6cbd1a0da0f9c464570bfb370ef8dca07470202e $
*/
-public class ResolutionException extends RuntimeException {
+public class ResolutionException extends Exception {
private static final long serialVersionUID = 1L;
Added: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolveContext.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolveContext.java?rev=1297721&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolveContext.java (added)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/ResolveContext.java Tue Mar 6 21:03:35 2012
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) OSGi Alliance (2011, 2012). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.service.resolver;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+import org.osgi.resource.Wire;
+import org.osgi.resource.Wiring;
+
+/**
+ * A resolve context provides resources, options and constraints to the
+ * potential solution of a {@link Resolver#resolve(ResolveContext) resolve}
+ * operation.
+ *
+ * <p>
+ * Resolve Contexts:
+ * <ul>
+ * <li>Specify the mandatory and optional resources to resolve. The mandatory
+ * and optional resources must be consistent and correct. For example, they must
+ * not violate singleton policy of the caller.</li>
+ * <li>Provide {@link Capability capabilities} that the Resolver can use to
+ * satisfy {@link Requirement requirements} via the
+ * {@link #findProviders(Requirement)} method</li>
+ * <li>Constrain solutions via the {@link #getWirings()} method. A wiring
+ * consists of a map of existing {@link Resource resources} to {@link Wire
+ * wires}.</li>
+ * <li>Filter transitive requirements that are brought in as part of a resolve
+ * operation via the {@link #isEffective(Requirement)}.</li>
+ * </ul>
+ *
+ * <p>
+ * A resolve context may be used to provide capabilities via local
+ * {@link Resource resources} and/or remote repositories.
+ *
+ * <p>
+ * A resolver may call the methods on the resolve context any number of times
+ * during a resolve operation using any thread. Implementors should ensure that
+ * this class is properly thread safe.
+ *
+ * <p>
+ * Except for {@link #insertHostedCapability(List, HostedCapability)}, the
+ * resolve context methods must be <i>idempotent</i>. This means that resources
+ * must have constant capabilities and requirements and the resolve context must
+ * return a consistent set of capabilities, wires and effective requirements.
+ *
+ * @ThreadSafe
+ * @version $Id: 08c822c21a46fbcdf01852b8206eb05d1c566bf1 $
+ */
+public abstract class ResolveContext {
+ /**
+ * Return the resources that must be resolved for this resolve context.
+ *
+ * <p>
+ * The default implementation returns an empty collection.
+ *
+ * @return The resources that must be resolved for this resolve context. May
+ * be empty if there are no mandatory resources.
+ */
+ public Collection<Resource> getMandatoryResources() {
+ return emptyCollection();
+ }
+
+ /**
+ * Return the resources that the resolver should attempt to resolve for this
+ * resolve context. Inability to resolve one of the specified resources will
+ * not result in a resolution exception.
+ *
+ * <p>
+ * The default implementation returns an empty collection.
+ *
+ * @return The resources that the resolver should attempt to resolve for
+ * this resolve context. May be empty if there are no mandatory
+ * resources.
+ */
+ public Collection<Resource> getOptionalResources() {
+ return emptyCollection();
+ }
+
+ private static <T> Collection<T> emptyCollection() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * Find Capabilities that match the given Requirement.
+ * <p>
+ * The returned list contains {@link Capability} objects where the Resource
+ * must be the declared Resource of the Capability. The Resolver can then
+ * add additional {@link HostedCapability} objects with the
+ * {@link #insertHostedCapability(List, HostedCapability)} method when it,
+ * for example, attaches fragments. Those {@link HostedCapability} objects
+ * will then use the host's Resource which likely differs from the declared
+ * Resource of the corresponding Capability.
+ *
+ * <p>
+ * The returned list is in priority order such that the Capabilities with a
+ * lower index have a preference over those with a higher index. The
+ * resolver must use the
+ * {@link #insertHostedCapability(List, HostedCapability)} method to add
+ * additional Capabilities to maintain priority order. In general, this is
+ * necessary when the Resolver uses Capabilities declared in a Resource but
+ * that must originate from an attached host.
+ *
+ * <p>
+ * Each returned Capability must match the given Requirement. This implies
+ * that the filter in the Requirement must match as well as any namespace
+ * specific directives. For example, the mandatory attributes for the
+ * {@code osgi.wiring.package} namespace.
+ *
+ * @param requirement The requirement that a resolver is attempting to
+ * satisfy. Must not be {@code null}.
+ * @return A list of {@link Capability} objects that match the specified
+ * requirement.
+ */
+ public abstract List<Capability> findProviders(Requirement requirement);
+
+ /**
+ * Add a {@link HostedCapability} to the list of capabilities returned from
+ * {@link #findProviders(Requirement)}.
+ *
+ * <p>
+ * This method is used by the {@link Resolver} to add Capabilities that are
+ * hosted by another Resource to the list of Capabilities returned from
+ * {@link #findProviders(Requirement)}. This function is necessary to allow
+ * fragments to attach to hosts, thereby changing the origin of a
+ * Capability. This method must insert the specified HostedCapability in a
+ * place that makes the list maintain the preference order. It must return
+ * the index in the list of the inserted {@link HostedCapability}.
+ *
+ * @param capabilities The list returned from
+ * {@link #findProviders(Requirement)}. Must not be {@code null}.
+ * @param hostedCapability The HostedCapability to insert in the specified
+ * list. Must not be {@code null}.
+ * @return The index in the list of the inserted HostedCapability.
+ *
+ */
+ public abstract int insertHostedCapability(List<Capability> capabilities,
+ HostedCapability hostedCapability);
+
+ /**
+ * Test if a given requirement should be wired in the resolve operation. If
+ * this method returns {@code false}, then the resolver should ignore this
+ * requirement during the resolve operation.
+ *
+ * <p>
+ * The primary use case for this is to test the {@code effective} directive
+ * on the requirement, though implementations are free to use any effective
+ * test.
+ *
+ * @param requirement The Requirement to test. Must not be {@code null}.
+ * @return {@code true} if the requirement should be considered as part of
+ * the resolve operation.
+ */
+ public abstract boolean isEffective(Requirement requirement);
+
+ /**
+ * Returns an unmodifiable map of existing wirings for resources.
+ *
+ * <p>
+ * Multiple calls to this method for this resolve context must return the
+ * same result.
+ *
+ * @return The existing wirings in this resolve context.
+ */
+ public abstract Map<Resource, Wiring> getWirings();
+}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/Resolver.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/Resolver.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/Resolver.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/resolver/Resolver.java Tue Mar 6 21:03:35 2012
@@ -20,7 +20,6 @@
package org.osgi.service.resolver;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -28,82 +27,48 @@ import org.osgi.resource.Resource;
import org.osgi.resource.Wire;
/**
- * A resolver is a service interface that can be used to find resolutions for
- * specified {@link Resource resources} based on a supplied {@link Environment}.
- *
+ * A resolver service resolves the specified resources in the context supplied
+ * by the caller.
+ *
* @ThreadSafe
- * @version $Id: a844927600988c6e4690c5bdf055e828f7a206a3 $
+ * @noimplement
+ * @version $Id: 871a5f8f97eba146fc1b8657e84a41b571533fbb $
*/
public interface Resolver {
/**
- * Attempt to resolve the resources based on the specified environment and
- * return any new resources and wires to the caller.
- *
+ * Resolve the specified resolve context and return any new resources and
+ * wires to the caller.
+ *
* <p>
* The resolver considers two groups of resources:
* <ul>
- * <li>Mandatory - any resource in the mandatory group must be resolved, a
- * failure to satisfy any mandatory requirement for these resources will
- * result in a {@link ResolutionException}</li>
- * <li>Optional - any resource in the optional group may be resolved, a
- * failure to satisfy a mandatory requirement for a resource in this group
- * will not fail the overall resolution but no resources or wires will be
- * returned for this resource.</li>
+ * <li>Mandatory - any resource in the
+ * {@link ResolveContext#getMandatoryResources() mandatory group} must be
+ * resolved. A failure to satisfy any mandatory requirement for these
+ * resources will result in throwing a {@link ResolutionException}</li>
+ * <li>Optional - any resource in the
+ * {@link ResolveContext#getOptionalResources() optional group} may be
+ * resolved. A failure to satisfy a mandatory requirement for a resource in
+ * this group will not fail the overall resolution but no resources or wires
+ * will be returned for that resource.</li>
* </ul>
- *
- * <h3>Delta</h3>
+ *
* <p>
* The resolve method returns the delta between the start state defined by
- * {@link Environment#getWirings()} and the end resolved state, i.e. only
- * new resources and wires are included. To get the complete resolution the
- * caller can merge the start state and the delta using something like the
- * following:
- *
- * <pre>
- * Map<Resource, List<Wire>> delta = resolver.resolve(env, resources, null);
- * Map<Resource, List<Wire>> wiring = env.getWiring();
- *
- * for (Map.Entry<Resource, List<Wire>> e : delta.entrySet()) {
- * Resource res = e.getKey();
- * List<Wire> newWires = e.getValue();
- *
- * List<Wire> currentWires = wiring.get(res);
- * if (currentWires != null) {
- * newWires.addAll(currentWires);
- * }
- *
- * wiring.put(res, newWires);
- * }
- * </pre>
- *
- * <h3>Consistency</h3>
- * <p>
- * For a given resolve operation the parameters to the resolve method should
- * be considered immutable. This means that resources should have constant
- * capabilities and requirements and an environment should return a
- * consistent set of capabilities, wires and effective requirements.
- *
+ * {@link ResolveContext#getWirings()} and the end resolved state. That is,
+ * only new resources and wires are included.
+ *
* <p>
- * The behavior of the resolver is not defined if resources or the
- * environment supply inconsistent information.
- *
- * @param environment the environment into which to resolve the requirements
- * @param mandatoryResources The resources that must be resolved during this
- * resolution step or null if no resources must be resolved
- * @param optionalResources Any resources which the resolver should attempt
- * to resolve but that will not cause an exception if resolution is
- * impossible or null if no resources are optional.
- *
- * @return the new resources and wires required to satisfy the requirements
+ * The behavior of the resolver is not defined if the specified resolve
+ * context supplies inconsistent information.
*
- * TODO I assume the list is mutable?
- *
- * @throws ResolutionException if the resolution cannot be satisfied for any
- * reason
- * @throws NullPointerException if environment is null
+ * @param context The resolve context for the resolve operation. Must not be
+ * {@code null}.
+ * @return The new resources and wires required to satisfy the specified
+ * resolve context. The returned map is the property of the caller
+ * and can be modified by the caller.
+ * @throws ResolutionException If the resolution cannot be satisfied.
*/
- Map<Resource, List<Wire>> resolve(Environment environment,
- Collection< ? extends Resource> mandatoryResources,
- Collection< ? extends Resource> optionalResources)
+ Map<Resource, List<Wire>> resolve(ResolveContext context)
throws ResolutionException;
}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/Subsystem.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/Subsystem.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/Subsystem.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/Subsystem.java Tue Mar 6 21:03:35 2012
@@ -37,7 +37,7 @@ import org.osgi.resource.Resource;
* <ul>
* <li>{@link SubsystemConstants#SUBSYSTEM_TYPE_APPLICATION Application} - An
* implicitly scoped subsystem. Nothing is exported, and imports are computed
- * based on any unsatisfied content dependencies.</li>
+ * based on any unsatisfied content requirements.</li>
* <li>{@link SubsystemConstants#SUBSYSTEM_TYPE_COMPOSITE Composite} - An
* explicitly scoped subsystem. The sharing policy is defined by metadata within
* the subsystem archive.</li>
@@ -57,12 +57,11 @@ import org.osgi.resource.Resource;
* root subsystem, must have at least one {@link #getParents() parent}.
* Subsystems become children of the subsystem in which they are installed.
* Unscoped subsystems have more than one parent if they are installed in more
- * than one subsystem within the same region. A scoped subsystem always has only
- * one parent. The subsystem graph may be thought of as is an acyclic digraph
- * with one and only one source vertex, which is the root subsystem. The edges
- * have the child as the head and parent as the tail.
+ * than one subsystem within the same region. The subsystem graph may be thought
+ * of as is an acyclic digraph with one and only one source vertex, which is the
+ * root subsystem. The edges have the child as the head and parent as the tail.
* <p/>
- * A subsystem has several unique identifiers.
+ * A subsystem has several identifiers.
* <ul>
* <li>{@link #getLocation() Location} - An identifier specified by the client
* as part of installation. It is guaranteed to be unique within the same
@@ -426,8 +425,8 @@ public interface Subsystem {
* The subsystem symbolic name conforms to the same grammar rules as the
* bundle symbolic name and is derived from one of the following, in order.
* <ul>
- * <li>The value of the {@link SubsystemConstants#SUBSYSTEM_CONTENT
- * Subsystem-Content} header, if specified.
+ * <li>The value of the {@link SubsystemConstants#SUBSYSTEM_SYMBOLICNAME
+ * Subsystem-SymbolicName} header, if specified.
* </li>
* <li>The subsystem URI if passed as the {@code location} along with
* the {@code content} to the {@link #install(String, InputStream)
@@ -540,8 +539,12 @@ public interface Subsystem {
* <ol>
* <li>Uninstall all resources installed as part of this operation.</li>
* <li>Change the state to INSTALL_FAILED.</li>
+ * <li>Change the state to UNINSTALLING.</li>
+ * <li>All content and dependencies which may have been installed by
+ * the installing process must be uninstalled.
+ * <li>Change the state to UNINSTALLED.</li>
* <li>Unregister the subsystem service.</li>
- * <li>Uninstall the region context bundle.</li>
+ * <li>If the subsystem is a scoped subsystem then, uninstall the region context bundle.</li>
* <li>Throw a SubsystemException with the specified cause.</li>
* </ol>
* The following steps are required to install a subsystem.
@@ -636,7 +639,7 @@ public interface Subsystem {
* <tr align="center">
* <td>RESOLVED</td>
* <td>If this subsystem is in the process of being<br/>
- * started, Wait. Otherwise, Uninstall.</td>
+ * started, Wait. Otherwise, Start.</td>
* </tr>
* <tr align="center">
* <td>STARTING</td>
@@ -673,8 +676,6 @@ public interface Subsystem {
* <ol>
* <li>Stop all resources that were started as part of this operation.
* </li>
- * <li>Disable the export sharing policy.
- * </li>
* <li>Change the state to either INSTALLED or RESOLVED.
* </li>
* <li>Throw a SubsystemException with the specified cause.
@@ -896,10 +897,11 @@ public interface Subsystem {
* <p/>
* The following steps are required to uninstall this subsystem.
* <ol>
+ * <li>Change the state to INSTALLED.
* <li>Change the state to UNINSTALLING.
* </li>
- * <li>For each resource, decrement the reference count by one. If the
- * reference count is zero, uninstall the resource. All content
+ * <li>For each referenced resource, decrement the reference count by one.
+ * If the reference count is zero, uninstall the resource. All content
* resources must be uninstalled before any dependencies. If
* an error occurs while uninstalling a resource, an uninstall
* failure results with that error as the cause.
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/osgi/service/subsystem/SubsystemConstants.java Tue Mar 6 21:03:35 2012
@@ -125,9 +125,9 @@ public class SubsystemConstants {
/**
* The name of the service property for the subsystem {@link
* Subsystem#getSymbolicName() symbolic name}.
- * It is defined to be "subsystem.symbolicname".
+ * It is defined to be "subsystem.symbolicName".
*/
- public static final String SUBSYSTEM_SYMBOLICNAME_PROPERTY = "subsystem.symbolicname";
+ public static final String SUBSYSTEM_SYMBOLICNAME_PROPERTY = "subsystem.symbolicName";
/**
* Manifest header identifying the subsystem type.
Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java Tue Mar 6 21:03:35 2012
@@ -894,7 +894,7 @@ public class AriesSubsystem implements S
constituents.add(subsystem);
return subsystem;
}
- subsystem = new AriesSubsystem(location, ssr.getContent(null), this);
+ subsystem = new AriesSubsystem(location, ssr.getContent(), this);
installSubsystemResource(subsystem, coordination, false);
return subsystem;
}
@@ -918,7 +918,7 @@ public class AriesSubsystem implements S
revision = (BundleRevision)resource;
}
else {
- InputStream content = ((RepositoryContent)resource).getContent(null);
+ InputStream content = ((RepositoryContent)resource).getContent();
String location = provisionTo.getSubsystemId() + "@" + provisionTo.getSymbolicName() + "@" + ResourceHelper.getSymbolicNameAttribute(resource);
Bundle bundle = provisionTo.region.installBundle(location, content);
revision = bundle.adapt(BundleRevision.class);
@@ -976,7 +976,7 @@ public class AriesSubsystem implements S
}
else if (resource instanceof SubsystemFileResource) {
SubsystemFileResource sfr = (SubsystemFileResource)resource;
- subsystem = (AriesSubsystem)install(sfr.getLocation(), sfr.getContent(null), coordination);
+ subsystem = (AriesSubsystem)install(sfr.getLocation(), sfr.getContent(), coordination);
return;
}
else if (resource instanceof SubsystemDirectoryResource) {
@@ -986,7 +986,7 @@ public class AriesSubsystem implements S
}
else if (resource instanceof RepositoryContent) {
String location = getSubsystemId() + "@" + getSymbolicName() + "@" + ResourceHelper.getSymbolicNameAttribute(resource);
- subsystem = (AriesSubsystem)install(location, ((RepositoryContent)resource).getContent(null), coordination);
+ subsystem = (AriesSubsystem)install(location, ((RepositoryContent)resource).getContent(), coordination);
return;
}
else {
Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/felix/FelixResourceAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/felix/FelixResourceAdapter.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/felix/FelixResourceAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/obr/felix/FelixResourceAdapter.java Tue Mar 6 21:03:35 2012
@@ -13,7 +13,6 @@
*/
package org.apache.aries.subsystem.core.obr.felix;
-import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -97,8 +96,13 @@ public class FelixResourceAdapter implem
}
@Override
- public InputStream getContent(String osgiContent) throws IOException {
- return new URL(resource.getURI()).openStream();
+ public InputStream getContent() {
+ try {
+ return new URL(resource.getURI()).openStream();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
public List<Requirement> getRequirements(String namespace) {
Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/BundleResource.java Tue Mar 6 21:03:35 2012
@@ -104,8 +104,13 @@ public class BundleResource implements R
}
@Override
- public InputStream getContent(String osgiContent) throws IOException {
- return content.openStream();
+ public InputStream getContent() {
+ try {
+ return content.openStream();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
public List<Requirement> getRequirements(String namespace) {
Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemFileResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemFileResource.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemFileResource.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemFileResource.java Tue Mar 6 21:03:35 2012
@@ -78,8 +78,13 @@ public class SubsystemFileResource imple
}
@Override
- public InputStream getContent(String osgiContent) throws IOException {
- return new FileInputStream(file);
+ public InputStream getContent() {
+ try {
+ return new FileInputStream(file);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
public String getLocation() {
Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemStreamResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemStreamResource.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemStreamResource.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/SubsystemStreamResource.java Tue Mar 6 21:03:35 2012
@@ -96,8 +96,13 @@ public class SubsystemStreamResource imp
}
@Override
- public InputStream getContent(String osgiContent) throws IOException {
- return new ByteArrayInputStream(content);
+ public InputStream getContent() {
+ try {
+ return new ByteArrayInputStream(content);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
@Override
Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepositoryContent.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepositoryContent.java?rev=1297721&r1=1297720&r2=1297721&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepositoryContent.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepositoryContent.java Tue Mar 6 21:03:35 2012
@@ -1,7 +1,6 @@
package org.apache.aries.subsystem.itests.util;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -47,8 +46,13 @@ public class TestRepositoryContent exten
}
@Override
- public InputStream getContent(String osgiContent) throws IOException {
- return new ByteArrayInputStream(content);
+ public InputStream getContent() {
+ try {
+ return new ByteArrayInputStream(content);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
}