You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gc...@apache.org on 2011/05/12 13:27:13 UTC
svn commit: r1102244 [1/4] - in /aries/trunk/subsystem: subsystem-api/
subsystem-api/src/main/java/org/apache/aries/subsystem/
subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ subsystem-core/
subsystem-core/src/main/java/org/apache/aries/sub...
Author: gcc
Date: Thu May 12 11:27:11 2011
New Revision: 1102244
URL: http://svn.apache.org/viewvc?rev=1102244&view=rev
Log:
ARIES-644
Applied and merged in with updates form ARIES-645.
Added:
aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Capability.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Requirement.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceOperation.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/ResourceConverter.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemEvent.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemListener.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RootSubsystem.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemServiceFactory.java
aries/trunk/subsystem/subsystem-scope-impl/src/main/java/org/apache/aries/subsystem/scope/impl/IdGenerator.java
aries/trunk/subsystem/subsystem-scope-impl/src/main/java/org/apache/aries/subsystem/scope/impl/Scopes.java
aries/trunk/subsystem/subsystem-scope-impl/src/main/java/org/apache/aries/subsystem/scope/impl/SharePolicies.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/PersistenceTest.java
Modified:
aries/trunk/subsystem/subsystem-api/pom.xml
aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/Subsystem.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemConstants.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemException.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java
aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java
aries/trunk/subsystem/subsystem-core/pom.xml
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResourceProcessor.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/NoOpResolver.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceImpl.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceResolverImpl.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemEventDispatcher.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemImpl.java
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResourceProcessor.java
aries/trunk/subsystem/subsystem-install/src/main/java/org/apache/aries/subsystem/install/internal/SubsystemInstaller.java
aries/trunk/subsystem/subsystem-itests/pom.xml
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdmin2Test.java
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemAdminTest.java
aries/trunk/subsystem/subsystem-obr/pom.xml
aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/obr/internal/Activator.java
aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/obr/internal/ObrResourceImpl.java
aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/obr/internal/ObrResourceResolver.java
aries/trunk/subsystem/subsystem-obr/src/main/java/org/apache/aries/subsystem/obr/internal/ResourceImpl.java
aries/trunk/subsystem/subsystem-scope-impl/src/main/java/org/apache/aries/subsystem/scope/impl/ScopeImpl.java
aries/trunk/subsystem/subsystem-scope-impl/src/main/java/org/apache/aries/subsystem/scope/impl/ScopeManager.java
aries/trunk/subsystem/subsystem-scope-impl/src/main/java/org/apache/aries/subsystem/scope/impl/ScopeUpdateImpl.java
aries/trunk/subsystem/subsystem-scope-impl/src/main/java/org/apache/aries/subsystem/scope/internal/Activator.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/AbstractTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/BasicTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/BundleVisibilityTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/GetScopeServiceTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/MoveBundleTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/ScopeAdminTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/ServiceVisibilityTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/SharePolicyTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/UninstallBundleTest.java
aries/trunk/subsystem/subsystem-scope-itests/src/test/java/org/apache/aries/subsystem/scope/itests/Utils.java
Modified: aries/trunk/subsystem/subsystem-api/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/pom.xml?rev=1102244&r1=1102243&r2=1102244&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/pom.xml (original)
+++ aries/trunk/subsystem/subsystem-api/pom.xml Thu May 12 11:27:11 2011
@@ -52,6 +52,11 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>coordinator</artifactId>
+ <version>1.0.0.v20110314</version>
+ </dependency>
</dependencies>
</project>
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/Subsystem.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/Subsystem.java?rev=1102244&r1=1102243&r2=1102244&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/Subsystem.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/Subsystem.java Thu May 12 11:27:11 2011
@@ -13,196 +13,307 @@
*/
package org.apache.aries.subsystem;
+import java.io.InputStream;
import java.util.Collection;
import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
+/*
+ * TODO
+ * (1) How will the root subsystem handle install, start, stop, update, and
+ * uninstall?
+ * (2) ResourceProcesser will accept Coordination again. No chaining. Processor
+ * is responsible for failing the coordination or throwing exception from ended
+ * or failed.
+ * (3) Remove coordination from Resource.
+ * (4) Do we need to return Resources and Bundles? Just Resources? What?
+ * (5) Add description of root subsystem. List unsupported operations.
+ */
+
/**
- * A representation of a subsystem in the framework. A subsystem is a
- * collection of bundles and/or other resource. A subsystem has isolation
- * semantics. Subsystem types are defined that have different default isolation
- * semantics. For example, an Application subsystem does not export any of the
- * packages or services provided by its content bundles, and imports any
- * packages or services that are required to satisfy unresolved package or
- * service dependencies of the content bundles.
+ * A representation of a subsystem in the framework. A subsystem is a
+ * collection of bundles and/or other resource. A subsystem has isolation
+ * semantics. Subsystem types are defined that have different default isolation
+ * semantics. For example, an Application subsystem does not export any of the
+ * packages or services provided by its content bundles, and imports any
+ * packages or services that are required to satisfy unresolved package or
+ * service dependencies of the content bundles. A subsystem is defined using a
+ * manifest format.
*
- * A subsystem is defined using a manifest format.
+ * @ThreadSafe
+ * @noimplement
*/
public interface Subsystem {
-
- /**
- * The states of a subsystem in the framework. These states match those of a
- * Bundle and are derived using the same rules as CompositeBundles. As such,
- * they are more a reflection of what content bundles are permitted to do
- * rather than an aggregation of the content bundle states.
- */
- public enum State {
-
- /**
- * A subsystem is in the INSTALLED state when it is initially created.
- * It may or may not contain content bundles. No content bundles are
- * permitted to be resolved while the subsystem is in the INSTALLED
- * state.
- */
- INSTALLED,
-
- /**
- * A subsystem in the RESOLVED is allowed to have its content bundles
- * resolved. The content bundles are not allowed to activate while the
- * subsystem is in the RESOLVED state.
- */
- RESOLVED,
-
- /**
- * A subsystem is in the STARTING state when all its content bundles are
- * enabled for activation. The content bundles are started according to
- * the start-level specification.
- */
- STARTING,
-
- /**
- * A subsystem in the STOPPING state is in the process of taking its its active start level to
- * zero, stopping all the content bundles.
- */
- STOPPING,
-
- /**
- * A subsystem is in the ACTIVE state when it has reached the beginning
- * start-level (for starting it's contents), and all its persistently
- * started content bundles that are resolved and have had their
- * start-levels met have completed, or failed, their activator start
- * method.
- */
- ACTIVE,
-
- /**
- * A subsystem is in the UNINSTALLED state when all its content bundles
- * and uninstalled and its system bundle context is invalidated.
- */
- UNINSTALLED
-
- }
-
- /**
- * Gets the state of the subsystem.
- *
- * @return the state of the subsystem.
- */
- State getState();
-
- /**
- * Starts the subsystem. The subsystem is started according to the rules
- * defined for Bundles and the content bundles are enabled for activation.
- *
- * @throws SubsystemException
- * If this subsystem could not be started.
- * @throws IllegalStateException
- * If this subsystem has been uninstalled.
- * @throws SecurityException
- * If the caller does not have the appropriate
- * AdminPermission[this,EXECUTE] and the runtime supports
- * permissions.
- */
- void start() throws SubsystemException;
-
- /**
- * Stops the subsystem. The subsystem is stopped according to the rules
- * defined for Bundles and the content bundles are disabled for activation
- * and stopped.
- *
- * @throws SubsystemException
- * TODO: does not fit with BundleException from Bundle.stop.
- * What are the circumstances that cause this to be throw? When
- * an exception is thrown from a content bundle?
- * @throws IllegalStateException
- * If this subsystem has been uninstalled.
- * @throws SecurityException
- * If the caller does not have the appropriate
- * AdminPermission[this,EXECUTE] and the runtime supports
- * permissions.
- */
- void stop() throws SubsystemException;
-
- /**
- * Gets the identifier of the subsystem. Subsystem identifiers are assigned
- * when the subsystem is installed and are unique within the framework.
- *
- * @return the identifier for the subsystem.
- */
- long getSubsystemId();
-
- /**
- * The location identifier used to install this subsystem through
- * SubsystemAdmin.install. This identifier does not change while this
- * subsystem remains installed, even after SubsystemAdmin.update. This
- * location identifier is used in SubsystemAdmin.update if no other update
- * source is specified.
- *
- * @return The string representation of the subsystem's location identifier.
- */
- String getLocation();
-
- /**
- * Gets the symbolic name of this subsystem.
- *
- * @return the symbolic name of this subsystem.
- */
- String getSymbolicName();
-
- /**
- * Gets the version of this subsystem.
- *
- * @return the version of this subsystem.
- */
- Version getVersion();
-
- /**
- * Gets the headers used to define this subsystem. The headers will be
- * localized using the locale returned by java.util.Locale.getDefault. This
- * is equivalent to calling <code>getHeaders(null)</code>.
- *
- * @return the headers used to define this subsystem.
- * @throws SecurityException
- * If the caller does not have the appropriate
- * AdminPermission[this,METADATA] and the runtime supports
- * permissions.
- */
- Map<String, String> getHeaders();
-
- /**
- * Gets the headers used to define this subsystem.
- *
- * @param locale
- * The locale name to be used to localize the headers. If the
- * locale is <code>null</code> then the locale returned by
- * java.util.Locale.getDefault is used. If the value is the empty
- * string then the returned headers are returned unlocalized.
- * @return the headers used to define this subsystem, localized to the
- * specified locale.
- * @throws SecurityException
- * If the caller does not have the appropriate
- * AdminPermission[this,METADATA] and the runtime supports
- * permissions.
- */
- Map<String, String> getHeaders(String locale);
-
- /**
- * Gets the content bundles of this subsystem.
- *
- * @return the content of this subsystem.
- */
- Collection<Bundle> getBundles();
-
- //long getParentId();
-
- public void updateHeaders(Map<String, String> headers);
-
- /**
- * return the subsystem managed by the subsystem
- * @return
- */
- Collection<Subsystem> getChildrenSubsystems();
-
+ /**
+ * The states of a subsystem in the framework. These states match those of
+ * a Bundle and are derived using the same rules as CompositeBundles. As
+ * such, they are more a reflection of what content bundles are permitted
+ * to do rather than an aggregation of the content bundle states.
+ */
+ public static enum State {
+ /**
+ * A subsystem is in the ACTIVE state when it has reached the beginning
+ * start-level (for starting it's contents), and all its persistently
+ * started content bundles that are resolved and have had their
+ * start-levels met have completed, or failed, their activator start
+ * method.
+ */
+ ACTIVE,
+ /**
+ * A subsystem is in the INSTALLED state when it is initially created.
+ */
+ INSTALLED,
+ /**
+ * A subsystem in the RESOLVED is allowed to have its content bundles
+ * resolved.
+ */
+ RESOLVED,
+ /**
+ * A subsystem is in the STARTING state when all its content bundles
+ * are enabled for activation.
+ */
+ STARTING,
+ /**
+ * A subsystem in the STOPPING state is in the process of taking its
+ * its active start level to zero, stopping all the content bundles.
+ */
+ STOPPING,
+ /**
+ * A subsystem is in the UNINSTALLED state when all its content bundles
+ * and uninstalled and its system bundle context is invalidated.
+ */
+ UNINSTALLED
+ }
+ /**
+ * Gets the subsystems managed by this service. This only includes the
+ * top-level Subsystems installed in the Framework, CoompositeBundle or
+ * Subsystem from which this service has been retrieved.
+ * @return The Subsystems managed by this service.
+ */
+ public Collection<Subsystem> getChildren();
+ /**
+ * Gets the content bundles of this subsystem.
+ * @return The content of this subsystem.
+ */
+ // TODO Should constituents actually be resources instead of bundles?
+ public Collection<Bundle> getConstituents();
+ /**
+ * Gets the headers used to define this subsystem. The headers will be
+ * localized using the locale returned by java.util.Locale.getDefault. This
+ * is equivalent to calling getHeaders(null).
+ * @return The headers used to define this subsystem.
+ * @throws SecurityException If the caller does not have the appropriate
+ * AdminPermission[this,METADATA] and the runtime supports
+ * permissions.
+ */
+ public Map<String, String> getHeaders();
+ /**
+ * Gets the headers used to define this subsystem.
+ * @param locale The locale name to be used to localize the headers. If the
+ * locale is null then the locale returned by
+ * java.util.Locale.getDefault is used. If the value is the empty
+ * string then the returned headers are returned unlocalized.
+ * @return the headers used to define this subsystem, localized to the
+ * specified locale.
+ */
+ public Map<String, String> getHeaders(String locale);
+ /**
+ * The location identifier used to install this subsystem through
+ * SubsystemAdmin.install. This identifier does not change while this
+ * subsystem remains installed, even after SubsystemAdmin.update. This
+ * location identifier is used in SubsystemAdmin.update if no other update
+ * source is specified.
+ * @return The string representation of the subsystem's location identifier.
+ */
+ public String getLocation();
+ /**
+ * Gets the parent Subsystem that scopes this subsystem admin instance.
+ * @return The Subsystem that scopes this subsystem admin or null if there
+ * is no parent subsystem (e.g. if the outer scope is the framework).
+ */
+ public Subsystem getParent();
+ /**
+ * Gets the state of the subsystem.
+ * @return The state of the subsystem.
+ */
+ public State getState();
+ /**
+ * Gets the identifier of the subsystem. Subsystem identifiers are assigned
+ * when the subsystem is installed and are unique within the framework.
+ * @return The identifier of the subsystem.
+ */
+ public long getSubsystemId();
+ /**
+ * Gets the symbolic name of this subsystem.
+ * @return The symbolic name of this subsystem.
+ */
+ public String getSymbolicName();
+ /**
+ * Gets the version of this subsystem.
+ * @return The version of this subsystem.
+ */
+ public Version getVersion();
+ /**
+ * Install a new subsystem from the specified location identifier.
+ * <p>
+ * This method performs the same function as calling install(String,
+ * InputStream) with the specified location identifier and a null
+ * InputStream.
+ * @param location The location identifier of the subsystem to be installed.
+ * @return The installed subsystem.
+ * @throws SubsystemException If the subsystem could not be installed for
+ * any reason.
+ * @throws SecurityException If the caller does not have the appropriate
+ * AdminPermission[installed subsystem,LIFECYCLE], and the Java
+ * Runtime Environment supports permissions.
+ */
+ public Subsystem install(String location) throws SubsystemException;
+ /**
+ * Install a new subsystem from the specified InputStream object.
+ * <p/>
+ * If the specified InputStream is null, the InputStream must be created
+ * from the specified location.
+ * <p/>
+ * The specified location identifier will be used as the identity of the
+ * subsystem. Every installed subsystem is uniquely identified by its
+ * location identifier which is typically in the form of a URL.
+ * <p/>
+ * TODO: Understand whether this all change when we can install the same
+ * bundle multiple times.
+ * <p/>
+ * A subsystem and its contents must remain installed across Framework and
+ * VM restarts. The subsystem itself is installed atomically, however its
+ * contents are not.
+ * <p/>
+ * The following steps are required to install a subsystem:
+ * <ol>
+ * <li>If there is an existing subsystem containing the same location
+ * identifier as the Subsystem to be installed, then a Future is
+ * returned that has the existing subsystem immediately available
+ * as its result.</li>
+ * <li>If there is already an install in progress for a subsystem with
+ * the same location identifier, then the Future returned is the
+ * same as the Future returned for the first install and a new
+ * install is not started.</li>
+ * <li>If this is a new install, then a new Future is returned with
+ * the installation process following the remaining step.</li>
+ * <li>The subsystem content is read from the input stream.</li>
+ * <li>Isolation is set up while the install is in progress, such that
+ * none of the content can be resolved with bundles outside the
+ * subsystem.</li>
+ * <li>The resources are into the framework through the use of
+ * ResourceProcessors.</li>
+ * <li>Isolation is configured appropriate for the subsystem such that
+ * the content can be resolved with bundles outside the subsystem.</li>
+ * <li>The subsystem's state is set to INSTALLED.</li>
+ * <li>The subsystem event of type INSTALLED is fired.</li>
+ * <li>The subsystem content is started.</li>
+ * <li>The subsystem object for the newly installed subsystem is made
+ * available from the Future.</li>
+ * </ol>
+ * @param location The location identifier of the subsystem to be installed.
+ * @param content The InputStream from where the subsystem is to be
+ * installed or null if the location is to be used to create the
+ * InputStream.
+ * @return The installed subsystem.
+ * @throws SubsystemException If the subsystem could not be installed for
+ * any reason.
+ * @throws SecurityException If the caller does not have the appropriate
+ * AdminPermission[installed subsystem,LIFECYCLE], and the Java
+ * Runtime Environment supports permissions.
+ */
+ public Subsystem install(String location, InputStream content) throws SubsystemException;
+ /**
+ * Starts the subsystem. The subsystem is started according to the rules
+ * defined for Bundles and the content bundles are enabled for activation.
+ * @throws SubsystemException If this subsystem could not be started.
+ * @throws IllegalStateException If this subsystem has been uninstalled.
+ * @throws SecurityException If the caller does not have the appropriate
+ * AdminPermission[this,EXECUTE] and the runtime supports
+ * permissions.
+ */
+ public void start() throws SubsystemException;
+ /**
+ * Stops the subsystem. The subsystem is stopped according to the rules
+ * defined for Bundles and the content bundles are disabled for activation
+ * and stopped.
+ * @throws SubsystemException If an internal exception is thrown while
+ * stopping the subsystem (e.g. a BundleException from Bundle.stop).
+ * @throws IllegalStateException - If this subsystem has been uninstalled.
+ * @throws SecurityException - If the caller does not have the appropriate
+ * AdminPermission[this,EXECUTE] and the runtime supports
+ * permissions.
+ */
+ public void stop() throws SubsystemException;
+ /**
+ * Uninstall the given subsystem.
+ * <p/>
+ * This method causes the Framework to notify other bundles and subsystems
+ * that this subsystem is being uninstalled, and then puts this subsystem
+ * into the UNINSTALLED state. The Framework must remove any resources
+ * related to this subsystem that it is able to remove. It does so using the
+ * appropriate ResourceProcessor.uninstall(Subsystem, Resource,
+ * Coordination) for the resource namespace. If this subsystem has exported
+ * any packages, the Framework must continue to make these packages
+ * available to their importing bundles or subsystems until the
+ * org.osgi.service.packageadmin.PackageAdmin.refreshPackages(
+ * org.osgi.framework.Bundle[]) method has been called or the Framework is
+ * relaunched. The following steps are required to uninstall a subsystem:
+ * <ol>
+ * <li>If this subsystem's state is UNINSTALLED then an
+ * IllegalStateException is thrown.</li>
+ * <li>If this subsystem's state is ACTIVE, STARTING or STOPPING, this
+ * subsystem is stopped as described in the Subsystem.stop()
+ * method. If Subsystem.stop() throws an exception, a Framework
+ * event of type FrameworkEvent.ERROR is fired containing the
+ * exception.</li>
+ * <li>This subsystem's state is set to UNINSTALLED.</li>
+ * <li>A subsystem event of type SubsystemEvent.UNINSTALLED is fired.</li>
+ * <li>This subsystem and any persistent storage area provided for this
+ * subsystem by the Framework are removed.</li>
+ * </ol>
+ * @throws SubsystemException If the uninstall failed.
+ * @throws IllegalStateException If the subsystem is already in the
+ * UNISTALLED state.
+ * @throws SecurityException If the caller does not have the appropriate
+ * AdminPermission[this,LIFECYCLE] and the Java Runtime Environment
+ * supports permissions.
+ */
+ public void uninstall() throws SubsystemException;
+ /**
+ * Update the given subsystem.
+ * <p/>
+ * This method performs the same function as calling update(Subsystem,
+ * InputStream) with the specified subsystem and a null InputStream.
+ * @throws SubsystemException If the subsystem could not be updated for any
+ * reason.
+ */
+ public void update() throws SubsystemException;
+ /**
+ * Update the given subsystem from an InputStream.
+ * <p/>
+ * If the specified InputStream is null, the InputStream must be created
+ * from the subsystem's Subsystem-UpdateLocation Manifest header if present,
+ * or this subsystem's location provided when the subsystem was originally
+ * installed.
+ * <p/>
+ * TODO: expand on this description. For example, we need details on how
+ * update works for individual resources. We could follow the
+ * deploymentadmin approach and uninstall bundles that are removed and
+ * install new ones. This would happen if we had a different (updated)
+ * deployment calculated for the same version of the application.
+ * @param content The InputStream from which to update the subsystem or null
+ * if the Subsystem-UpdateLocation or original location are to be
+ * used.
+ * @throws SubsystemException
+ * @throws IllegalStateException If the subsystem is in the UNINSTALLED
+ * state.
+ * @throws SecurityException If the caller does not have the appropriate
+ * AdminPermission[this,LIFECYCLE] for both the current subsystem
+ * and the updated subsystem and the Java Runtime Environment
+ * supports permissions.
+ */
+ public void update(InputStream content) throws SubsystemException;
}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemConstants.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemConstants.java?rev=1102244&r1=1102243&r2=1102244&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemConstants.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemConstants.java Thu May 12 11:27:11 2011
@@ -13,255 +13,381 @@
*/
package org.apache.aries.subsystem;
-public class SubsystemConstants {
-
- /**
- * Private constructor to prevent objects of this type.
- */
- private SubsystemConstants() {
- // non-instantiable
- }
-
- //====================================================
- //
- // Subsystem manifest headers
- //
- //====================================================
-
- /**
- * The subsystem manifest version header must be present and equals to 1.0
- * for this version of subsystems.
- */
- public static final String SUBSYSTEM_MANIFESTVERSION = "Subsystem-ManifestVersion";
-
- /**
- * Symbolic name for the subsystem. Must be present.
- */
- public static final String SUBSYSTEM_SYMBOLICNAME = "Subsystem-SymbolicName";
-
- /**
- * Version of the subsystem. If not present, the default value is 0.0.0.
- */
- public static final String SUBSYSTEM_VERSION = "Subsystem-Version";
-
- /**
- * The human readable subsystem name.
- */
- public static final String SUBSYSTEM_NAME = "Subsystem-Name";
-
- /**
- * The human readable subsystem description.
- */
- public static final String SUBSYSTEM_DESCRIPTION = "Subsystem-Description";
-
- /**
- * Name of the resource to use for localized headers.
- */
- public static final String SUBSYSTEM_LOCALIZATION = "Subsystem-Localization";
+/*
+ * TODO
+ * There are disparities within the ODT between Field Summary and Field Detail.
+ * This interface is currently combines Field Summary and Field Detail.
+ */
- /**
+/**
+ * Defines the constants used by subsystems. These fall into four categories:
+ * <ol>
+ * <li>Headers for the applications subsystem type.</li>
+ * <li>Headers for the composite bundle subsystem type. Where appropriate,
+ * these header values are identical to those for a bundle.</li>
+ * <li>Headers for the library subsystem type.</li>
+ * <li>Attributes used in the above headers</li>
+ * </ol>
+ */
+public interface SubsystemConstants {
+ /**
+ * The subsystem lifecycle event types that can be produced by a subsystem.
+ * See ? and SubsystemAdmin for details on the circumstances under which
+ * these events are fired.
+ */
+ public static enum EventType {
+ /**
+ * Event type used to indicate that the operations was cancelled (e.g.
+ * an install was cancelled).
+ */
+ CANCELED,
+ /**
+ * Event type used to indicate that a subsystem operation is being
+ * cancelled.
+ */
+ CANCELING,
+ /**
+ * Event type used to indicate that the operation failed (e.g. an
+ * exception was thrown during installation).
+ */
+ FAILED,
+ /**
+ * Event type used to indicate a subsystem has been installed.
+ */
+ INSTALLED,
+ /**
+ * Event type used to indicate a subsystem is installing.
+ */
+ INSTALLING,
+ /**
+ * Event type used to indicate a subsystem has been resolved.
+ */
+ RESOLVED,
+ /**
+ * Event type used to indicate a subsystem is resolving.
+ */
+ RESOLVING,
+ /**
+ * Event type used to indicate a subsystem has been started.
+ */
+ STARTED,
+ /**
+ * Event type used to indicate a subsystem is starting.
+ */
+ STARTING,
+ /**
+ * Event type used to indicate a subsystem has been stopped.
+ */
+ STOPPED,
+ /**
+ * Event type used to indicate a subsystem is stopping.
+ */
+ STOPPING,
+ /**
+ * Event type used to indicate a subsystem has been uninstalled.
+ */
+ UNINSTALLED,
+ /**
+ * Event type used to indicate a subsystem has been updated.
+ */
+ UPDATED,
+ /**
+ * Event type used to indicate a subsystem is updating.
+ */
+ UPDATING
+ }
+ /**
+ * The list of application contents identified by a symbolic name and
+ * version.
+ */
+ public static final String APPLICATION_CONTENT = "";
+ /**
+ * Human readable description.
+ */
+ public static final String APPLICATION_DESCRIPTION = "";
+ /**
+ * Name of the resource to use for localized headers.
+ */
+ public static final String APPLICATION_LOCALIZATION = "";
+ /**
+ * The subsystem manifest version header must be present and equals to 1.0
+ * for this version of applications.
+ */
+ public static final String APPLICATION_MANIFESTVERSION = "";
+ /**
+ * Human readable application name.
+ */
+ public static final String APPLICATION_NAME = "";
+ /**
+ * Descriptions of resources contained within the application archive which
+ * cannot be determine reflectively.
+ */
+ public static final String APPLICATION_RESOURCES = "";
+ /**
+ * Symbolic name for the application. Must be present.
+ */
+ public static final String APPLICATION_SYMBOLICNAME = "";
+ /**
+ * Location to use when updating the application.
+ */
+ public static final String APPLICATION_UPDATELOCATION = "";
+ /**
+ * Version of the application. If not present, the default value is 0.0.0.
+ */
+ public static final String APPLICATION_VERSION = "";
+ /**
+ * The human readable composite bundle description (re-using the bundle
+ * header).
+ */
+ public static final String BUNDLE_DESCRIPTION = "";
+ /**
+ * The packages to be exported by the composite bundle for use outside the
+ * composite bundle (re-using the bundle header). The packages declarations
+ * must match a package provide by a bundle listed in the composite bundle
+ * content.
+ */
+ public static final String BUNDLE_EXPORTPACKAGE = "";
+ /**
+ * The packages to be imported into the composite bundle for use by the
+ * composite bundle contents (re-using the bundle header).
+ */
+ public static final String BUNDLE_IMPORTPACKAGE = "";
+ /**
+ * Name of the resource to use for localized headers (re-using the bundle
+ * header).
+ */
+ public static final String BUNDLE_LOCALIZATION = "";
+ /**
+ * The human readable composite bundle name (re-using the bundle header).
+ */
+ public static final String BUNDLE_NAME = "";
+ /**
+ * A list of Bundles the composite bundle requires (re-using the bundle
+ * header). These bundles are made available to satisfy Require-Bundle
+ * statements for the composite bundle content bundles.
+ */
+ public static final String BUNDLE_REQUIREBUNDLE = "";
+ /**
+ * Symbolic name for the composite bundle (re-using the bundle header).
+ * Must be present.
+ */
+ public static final String BUNDLE_SYMBOLICNAME = "";
+ /**
+ * Location to use when updating the composite bundle (re-using the bundle
+ * header).
+ */
+ public static final String BUNDLE_UPDATELOCATION = "";
+ /**
+ * Version of the composite bundle (re-using the bundle header). If not
+ * present, the default value is 0.0.0.
+ */
+ public static final String BUNDLE_VERSION = "";
+ /**
+ * The list of composite bundle contents identified by a symbolic name and
+ * version.
+ */
+ public static final String COMPOSITEBUNDLE_CONTENT = "";
+ /**
+ * A list of service filters used to identify the services provided by
+ * bundles inside the composite bundle that can be exported outside the
+ * composite bundle.
+ */
+ public static final String COMPOSITEBUNDLE_EXPORTSERVICE = "";
+ /**
+ * A list of service filters used to identify services that this composite
+ * bundle requires.
+ */
+ public static final String COMPOSITEBUNDLE_IMPORTSERVICE = "";
+ /**
+ * The composite bundle manifest version header must be present and equal
+ * to 1.0 for this version of composite bundles.
+ */
+ public static final String COMPOSITEBUNDLE_MANIFESTVERSION = "";
+ /**
+ * Descriptions of resources contained within the composite bundle archive
+ * which cannot be determine reflectively.
+ */
+ public static final String COMPOSITEBUNDLE_RESOURCES = "";
+ /**
+ *
+ */
+ public static final String FEATURE_CONTENT = "Feature-Content";
+ /**
+ *
+ */
+ public static final String FEATURE_DESCRIPTION = "Feature-Description";
+ /**
+ *
+ */
+ public static final String FEATURE_MANIFESTVERSION = "Feature-ManifestVersion";
+ /**
+ *
+ */
+ public static final String FEATURE_NAME = "Feature-Name";
+ /**
+ *
+ */
+ public static final String FEATURE_SYMBOLICNAME = "Feature-SymbolicName";
+ /**
+ *
+ */
+ public static final String FEATURE_VERSION = "Feature-Version";
+ /**
+ * The list of library contents identified by a symbolic name and version.
+ */
+ public static final String LIBRARY_CONTENT = "";
+ /**
+ * Human readable library description.
+ */
+ public static final String LIBRARY_DESCRIPTION = "";
+ /**
+ * Name of the resource to use for localized headers.
+ */
+ public static final String LIBRARY_LOCALIZATION = "";
+ /**
+ * The subsystem manifest version header must be present and equals to 1.0
+ * for this version of applications.
+ */
+ public static final String LIBRARY_MANIFESTVERSION = "";
+ /**
+ * Human readable library name.
+ */
+ public static final String LIBRARY_NAME = "";
+ /**
+ * Descriptions of resources contained within the library archive which
+ * cannot be determine reflectively.
+ */
+ public static final String LIBRARY_RESOURCES = "";
+ /**
+ * Symbolic name for the application. Must be present.
+ */
+ public static final String LIBRARY_SYMBOLICNAME = "";
+ /**
+ * Location to use when updating the library.
+ */
+ public static final String LIBRARY_UPDATELOCATION = "";
+ /**
+ * Version of the application. If not present, the default value is 0.0.0.
+ */
+ public static final String LIBRARY_VERSION = "";
+ /**
+ * Service property to be set on ResourceProcessor services to indicate
+ * which namespaces of resource it can process.
+ */
+ public static final String OSGI_RESOURCE_NAMESPACE = "";
+ /**
+ * Attribute to indicate the location of a resource.
+ */
+ public static final String RESOURCE_LOCATION_ATTRIBUTE = "";
+ /**
+ * Attribute to indicate the namespace of a resource.
+ */
+ public static final String RESOURCE_NAMESPACE_ATTRIBUTE = "osgi.resource.namespace";
+ /**
+ * Identify resources that are bundles (this is the default type).
+ */
+ public static final String RESOURCE_NAMESPACE_BUNDLE = "osgi.bundle";
+ /**
+ * Identify resources that are subsystems.
+ */
+ public static final String RESOURCE_NAMESPACE_SUBSYSTEM = "osgi.subsystem";
+ /**
+ * Attribute to indicate a bundle needs to be started, defaults to true.
+ */
+ public static final String RESOURCE_START_ATTRIBUTE = "";
+ /**
+ * Attribute to indicate the start level that must be associated to a
+ * constituent bundle or subsystem.
+ */
+ public static final String RESOURCE_START_LEVEL_ATTRIBUTE = "";
+ /**
+ * Attribute to indicate the type on a resource.
+ */
+ public static final String RESOURCE_TYPE_ATTRIBUTE = "";
+ /**
+ * Identify resources that are bundles (this is the default type).
+ */
+ public static final String RESOURCE_TYPE_BUNDLE = "";
+ /**
+ * Identify resources that are subsystems.
+ */
+ public static final String RESOURCE_TYPE_SUBSYSTEM = "";
+ /**
+ * Attribute to indicate a bundle needs to be forced updated, even if the
+ * version is the same, defaults to false
+ */
+ public static final String RESOURCE_UPDATE_ATTRIBUTE = "";
+ /**
+ * Service property to be set on ResourceProcessor services to indicate
+ * which types of resource it can process.
+ */
+ public static final String SERVICE_RESOURCE_TYPE = "";
+ /**
+ * Directive on the manifest header of a composite indicating the composite
+ * is managed as a subsystem.
+ */
+ public static final String SUBSYSTEM_DIRECTIVE = "";
+
+ // Event related constants.
+
+ /**
+ * Key for the event property that holds the subsystem id.
+ */
+ public static final String SUBSYSTEM_ID = "subsystem.id";
+ /**
+ * Key for the event property that holds the subsystem location.
+ */
+ public static final String SUBSYSTEM_LOCATION = "subsystem.location";
+ /**
+ * Key for the event property that holds the subsystem symbolic name.
+ */
+ public static final String SUBSYSTEM_SYMBOLICNAME = "Subsystem-SymbolicName";
+ /**
+ * Key for the event property that holds the subsystem version.
+ */
+ public static final String SUBSYSTEM_VERSION = "Subsystem-Version";
+ /**
+ * The topic for subsystem event admin events.
+ */
+ public static final String TOPIC = "org/osgi/service/Subsystem";
+ /**
+ * The topic for subsystem internal event admin events.
+ */
+ public static final String TOPIC_INTERNALS = "org/osgi/service/SubsystemInternals";
+ /**
* Location to use when updating the subsystem.
*/
- public static final String SUBSYSTEM_UPDATELOCATION = "Subsystem-UpdateLocation";
-
+ public static final String SUBSYSTEM_UPDATELOCATION = "Subsystem-UpdateLocation";
/**
* The list of subsystem contents identified by a symbolic name and version.
*/
public static final String SUBSYSTEM_CONTENT = "Subsystem-Content";
-
- /**
- * TODO: what is this for?
- */
- public static final String SUBSYSTEM_RESOURCES = "Subsystem-Resources";
-
/**
* The packages to be imported into the subsystem for use by the subsystem contents.
*/
public static final String SUBSYSTEM_IMPORTPACKAGE = "Subsystem-ImportPackage";
-
/**
* The packages to be exported by the subsystem for use outside the
* subsystem. The packages declarations must match a package provide by a
* bundle listed in the subsystem content.
*/
public static final String SUBSYSTEM_EXPORTPACKAGE = "Subsystem-ExportPackage";
-
- /**
- * A list of service filters used to identify services that this subsystem requires.
- */
- public static final String SUBSYSTEM_IMPORTSERVICE = "Subsystem-ImportService";
-
- /**
- * A list of service filters used to identify the services provided by
- * bundles inside the subsystem that can be exported outside the subsystem.
- */
- public static final String SUBSYSTEM_EXPORTSERVICE = "Subsystem-ExportService";
-
- /**
- * A list of Bundles the subsystem requires. These bundles are made
- * available to satisfy Require-Bundle statements for the subsystem content
- * bundles.
- */
- public static final String SUBSYSTEM_REQUIREBUNDLE = "Subsystem-RequireBundle";
-
- //====================================================
- //
- // Application manifest headers
- //
- //====================================================
-
- /**
- * The subsystem manifest version header must be present and equals to 1.0
- * for this version of applications.
- */
- public static final String APPLICATION_MANIFESTVERSION = "Application-ManifestVersion";
-
- /**
- * Symbolic name for the application. Must be present.
- */
- public static final String APPLICATION_SYMBOLICNAME = "Application-SymbolicName";
-
- /**
- * Version of the application. If not present, the default value is 0.0.0.
- */
- public static final String APPLICATION_VERSION = "Application-Version";
-
- /**
- * Human readable application name.
- */
- public static final String APPLICATION_NAME = "Application-Name";
-
- /**
- * Human readable description.
- */
- public static final String APPLICATION_DESCRIPTION = "Application-Description";
-
- /**
- * Name of the resource to use for localized headers.
- */
- public static final String APPLICATION_LOCALIZATION = "Application-Localization";
-
- /**
- * Location to use when updating the application.
- */
- public static final String APPLICATION_UPDATELOCATION = "Application-UpdateLocation";
-
- /**
- * The list of application contents identified by a symbolic name and version.
- */
- public static final String APPLICATION_CONTENT = "Application-Content";
-
/**
* TODO: what is this for?
*/
- public static final String APPLICATION_RESOURCES = "Application-Resources";
-
-
- //====================================================
- //
- // Library manifest headers
- //
- //====================================================
-
+ public static final String SUBSYSTEM_RESOURCES = "Subsystem-Resources";
/**
* The subsystem manifest version header must be present and equals to 1.0
- * for this version of applications.
- */
- public static final String LIBRARY_MANIFESTVERSION = "Library-ManifestVersion";
-
- /**
- * Symbolic name for the application. Must be present.
- */
- public static final String LIBRARY_SYMBOLICNAME = "Library-SymbolicName";
-
- /**
- * Version of the application. If not present, the default value is 0.0.0.
- */
- public static final String LIBRARY_VERSION = "Library-Version";
-
- /**
- * Human readable library name.
- */
- public static final String LIBRARY_NAME = "Library-Name";
-
- /**
- * Human readable library description.
- */
- public static final String LIBRARY_DESCRIPTION = "Library-Description";
-
- /**
- * Name of the resource to use for localized headers
- */
- public static final String LIBRARY_LOCALIZATION = "Library-Localization";
-
- /**
- * Location to use when updating the library
- */
- public static final String LIBRARY_UPDATELOCATION = "Library-UpdateLocation";
-
- /**
- * The list of library contents identified by a symbolic name and version.
- */
- public static final String LIBRARY_CONTENT = "Library-Content";
-
- /**
- * TODO: what is this for.
- */
- public static final String LIBRARY_RESOURCES = "Library-Resources";
-
-
- //====================================================
- //
- // Attributes used in headers
- //
- //====================================================
-
- /**
- * Directive on the manifest header of a composite indicating the
- * composite is managed as a subsystem.
- */
- public static final String SUBSYSTEM_DIRECTIVE = "subsystem";
-
- /**
- * Service property to be set on {@link org.apache.aries.subsystem.spi.ResourceProcessor}
- * services to indicate which types of resource it can process.
- */
- public static final String SERVICE_RESOURCE_TYPE = "resource-type";
-
- /**
- * Attribute to indicate the type on a resource
- */
- public static final String RESOURCE_TYPE_ATTRIBUTE = "type";
-
- /**
- * Identify resources that are bundles (this is the default type).
- */
- public static final String RESOURCE_TYPE_BUNDLE = "bundle";
-
- /**
- * Identify resources that are subsystems.
- */
- public static final String RESOURCE_TYPE_SUBSYSTEM = "subsystem";
-
- /**
- * Attribute to indicate the location of a resource
- */
- public static final String RESOURCE_LOCATION_ATTRIBUTE = "location";
-
- /**
- * Attribute to indicate a bundle needs to be started, defaults to <code>true</code>
+ * for this version of subsystems.
*/
- public static final String RESOURCE_START_ATTRIBUTE = "start";
-
+ public static final String SUBSYSTEM_MANIFESTVERSION = "Subsystem-ManifestVersion";
/**
- * Attribute to indicate a bundle needs to be forced updated, even if the version is the same, defaults to <code>false</code>
+ * A list of service filters used to identify services that this subsystem requires.
*/
- public static final String RESOURCE_UPDATE_ATTRIBUTE = "update";
-
+ public static final String SUBSYSTEM_IMPORTSERVICE = "Subsystem-ImportService";
/**
- * Attribute to indicate the start level that must be associated to a constituent bundle or subsystem
+ * A list of service filters used to identify the services provided by
+ * bundles inside the subsystem that can be exported outside the subsystem.
*/
- public static final String RESOURCE_START_LEVEL_ATTRIBUTE = "start-level";
-
-
+ public static final String SUBSYSTEM_EXPORTSERVICE = "Subsystem-ExportService";
}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemException.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemException.java?rev=1102244&r1=1102243&r2=1102244&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemException.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/SubsystemException.java Thu May 12 11:27:11 2011
@@ -14,43 +14,40 @@
package org.apache.aries.subsystem;
/**
- * Exception thrown by SubsystemAdmin or Subsystem when
- * a problem occurs.
+ * Exception thrown by SubsystemAdmin or Subsystem when a problem occurs.
*/
public class SubsystemException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
- /**
- * Construct a subsystem exception which no message.
- */
- public SubsystemException() {
- }
-
- /**
- * Construct a subsystem exception specifying a message.
- *
- * @param message The message to include in the exception.
- */
- public SubsystemException(String message) {
- super(message);
- }
-
- /**
- * Construct a subsystem exception, wrapping an existing exception.
- *
- * @param message The message to be included in the exception
- * @param cause The cause of the exception.
- */
- public SubsystemException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Construct a subsystem exception, wrapping an existing exception.
- *
- * @param cause The cause of the exception.
- */
- public SubsystemException(Throwable cause) {
- super(cause);
- }
-
+ /**
+ * Construct a subsystem exception with no message.
+ */
+ public SubsystemException() {
+ }
+
+ /**
+ * Construct a subsystem exception specifying a message.
+ * @param message The message to include in the exception.
+ */
+ public SubsystemException(String message) {
+ super(message);
+ }
+
+ /**
+ * Construct a subsystem exception wrapping an existing exception.
+ * @param cause The cause of the exception.
+ */
+ public SubsystemException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Construct a subsystem exception specifying a message and wrapping an
+ * existing exception.
+ * @param message The message to include in the exception.
+ * @param cause The cause of the exception.
+ */
+ public SubsystemException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Added: aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Capability.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Capability.java?rev=1102244&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Capability.java (added)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Capability.java Thu May 12 11:27:11 2011
@@ -0,0 +1,57 @@
+/*
+ * 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.apache.aries.subsystem.spi;
+
+import java.util.Map;
+
+/**
+ * A capability that has been declared from a {@link Resource}.
+ *
+ * @ThreadSafe
+ * @version $Id: bf96ffda6b06297b308c208afe3d2136b4dda2f1 $
+ */
+public interface Capability {
+
+ /**
+ * Returns the name space of this capability.
+ *
+ * @return The name space of this capability.
+ */
+ String getNamespace();
+
+ /**
+ * Returns the directives of this capability.
+ *
+ * @return An unmodifiable map of directive names to directive values for
+ * this capability, or an empty map if this capability has no
+ * directives.
+ */
+ Map<String, String> getDirectives();
+
+ /**
+ * Returns the attributes of this capability.
+ *
+ * @return An unmodifiable map of attribute names to attribute values for
+ * this capability, or an empty map if this capability has no
+ * attributes.
+ */
+ Map<String, Object> getAttributes();
+
+ /**
+ * The resource that declares this capability.
+ *
+ * @return the resource
+ */
+ Resource getResource();
+}
Added: aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Requirement.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Requirement.java?rev=1102244&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Requirement.java (added)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Requirement.java Thu May 12 11:27:11 2011
@@ -0,0 +1,54 @@
+/*
+ * 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.apache.aries.subsystem.spi;
+
+import java.util.Map;
+
+/**
+ * A requirement that has been declared from a {@link Resource}
+ * .
+ * @ThreadSafe
+ * @version $Id: 9b189b1ff33e9b96460e3abc97cce657965d20a7 $
+ */
+public interface Requirement {
+ /**
+ * Returns the name space of this requirement.
+ *
+ * @return The name space of this requirement.
+ */
+ String getNamespace();
+
+ /**
+ * Returns the directives of this requirement.
+ *
+ * @return An unmodifiable map of directive names to directive values for this
+ * requirement, or an empty map if this requirement has no directives.
+ */
+ Map<String, String> getDirectives();
+
+ /**
+ * Returns the attributes of this requirement.
+ *
+ * @return An unmodifiable map of attribute names to attribute values for this
+ * requirement, or an empty map if this requirement has no attributes.
+ */
+ Map<String, Object> getAttributes();
+
+ /**
+ * Returns the resource declaring this requirement.
+ *
+ * @return The resource declaring this requirement.
+ */
+ Resource getResource();
+}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java?rev=1102244&r1=1102243&r2=1102244&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/Resource.java Thu May 12 11:27:11 2011
@@ -13,62 +13,82 @@
*/
package org.apache.aries.subsystem.spi;
-import java.io.IOException;
-import java.io.InputStream;
+import java.util.List;
import java.util.Map;
+import org.osgi.framework.Constants;
import org.osgi.framework.Version;
+
/**
* A resource is the representation of a uniquely identified and typed data.
- * A bundle is represented as a resource with a type
- * {@link org.apache.aries.subsystem.SubsystemConstants#RESOURCE_TYPE_BUNDLE}.
+ *
+ * A resources can be wired together via capabilities and requirements.
+ *
+ * TODO decide on identity characteristics of a revision. Given in OSGi multiple
+ * bundles can be installed with same bsn/version this cannot be used as a key.
+ *
+ * What then is identity of a resource? Object identity? URI (needs getter
+ * method?)
+ *
+ * @ThreadSafe
+ * @version $Id: 8de47b041af414a2c6f2a21b5b34e89604c97806 $
*/
public interface Resource {
-
- /**
- * Symbolic name of the resource
- *
- * @return
- */
- String getSymbolicName();
-
- /**
- * Version of the resource
- *
- * @return
- */
- Version getVersion();
-
- /**
- * Type of the resource
- *
- * @return
- */
- String getType();
-
- /**
- * Location of the resource.
- * Can be the real url of the resource, but not necessarily.
- *
- * @return
- */
- String getLocation();
-
- /**
- * Attributes associated to this resource. Those may contain informations
- * for {@link ResourceConverter}s or {@link ResourceProcessor}s.
- *
- * @return
- */
- Map<String, String> getAttributes();
-
- /**
- * Open the resource for reading.
- *
- * @return
- * @throws IOException
- */
- InputStream open() throws IOException;
+ /**
+ * Name space for OSGi bundle resources
+ */
+ final String BUNDLE_NAMESPACE = "osgi.bundle";
+
+ /**
+ * Attribute of type {@link String} used to specify the resource location.
+ */
+ final String LOCATION_ATTRIBUTE = "location";
+
+ /**
+ * Attribute of type {@link String} used to specify the resource symbolic name.
+ */
+ final String SYMBOLIC_NAME_ATTRIBUTE = "symbolic-name";
+ /**
+ * Attribute of type {@link Version} used to specify the resource version.
+ */
+ final String VERSION_ATTRIBUTE = Constants.VERSION_ATTRIBUTE;
+ /**
+ * Attribute of type {@link String} used to specify the resource name space.
+ */
+ final String NAMESPACE_ATTRIBUTE = "namespace";
+
+ /**
+ * Returns the capabilities declared by this resource.
+ *
+ * @param namespace
+ * The name space of the declared capabilities to return or
+ * {@code null} to return the declared capabilities from all name
+ * spaces.
+ * @return A list containing a snapshot of the declared {@link Capability}s,
+ * or an empty list if this resource declares no capabilities in the
+ * specified name space.
+ */
+ List<Capability> getCapabilities(String namespace);
+
+ /**
+ * Returns the requirements declared by this bundle resource.
+ *
+ * @param namespace
+ * The name space of the declared requirements to return or
+ * {@code null} to return the declared requirements from all name
+ * spaces.
+ * @return A list containing a snapshot of the declared {@link Requirement}
+ * s, or an empty list if this resource declares no
+ * requirements in the specified name space.
+ */
+ List<Requirement> getRequirements(String namespace);
+
+ /**
+ * Gets the attributes associated to this resource.
+ *
+ * @return The attributes associated with the resource.
+ */
+ public Map<String, Object> getAttributes();
}
Added: aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceOperation.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceOperation.java?rev=1102244&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceOperation.java (added)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceOperation.java Thu May 12 11:27:11 2011
@@ -0,0 +1,89 @@
+/*
+ * 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.apache.aries.subsystem.spi;
+
+import java.util.Map;
+
+import org.osgi.service.coordinator.Coordination;
+
+/**
+ * A resource operation serves as a context for a resource processor while
+ * processing a resource.
+ *
+ *@ThreadSafe
+ *@noimplement
+ */
+public interface ResourceOperation {
+ /**
+ * The type of operation to perform on the resource.
+ */
+ public static enum Type {
+ /**
+ * Install the resource.
+ */
+ INSTALL,
+ /**
+ * Start the resource.
+ */
+ START,
+ /**
+ * Stop the resource.
+ */
+ STOP,
+ /**
+ * Uninstall the resource.
+ */
+ UNINSTALL,
+ /**
+ * Update the resource.
+ */
+ UPDATE
+ }
+ /**
+ * Called by the resource processor once the operation has successfully and
+ * fully completed. This would typically be called as the very last thing
+ * within the Participant.ended method. Calling this method will result in
+ * an appropriate event notification that the resource has been
+ * successfully processed.
+ */
+ public void completed();
+ /**
+ * This resource operation is taking place within a larger context that
+ * potentially involves many other operations on other resources as part of
+ * a subsystem operation. Resource processors are required to participate
+ * within the coordination controlling the overall process in which this
+ * resource operation plays a part.
+ * @return The coordination in which the resource processor must
+ * participate.
+ */
+ public Coordination getCoordination();
+
+ /**
+ * A resource operation is associated with a particular resource.
+ * @return The resource on which this operation must be performed.
+ */
+ public Resource getResource();
+
+ /**
+ *
+ * @return
+ */
+ public Map<String, Object> getContext();
+ /**
+ * A resource operation is associated with a type that defines the
+ * processing required on the resource.
+ * @return The type of resource operation.
+ */
+ public Type getType();
+}
Modified: aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java?rev=1102244&r1=1102243&r2=1102244&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java (original)
+++ aries/trunk/subsystem/subsystem-api/src/main/java/org/apache/aries/subsystem/spi/ResourceProcessor.java Thu May 12 11:27:11 2011
@@ -13,33 +13,47 @@
*/
package org.apache.aries.subsystem.spi;
-import org.apache.aries.subsystem.SubsystemAdmin;
import org.apache.aries.subsystem.SubsystemException;
+/*
+ * TODO
+ * (1) Perhaps pass a collection of resource contexts? There could be more than one
+ * resource of the same type. Coordinations span multiple resources anyway.
+ * (2) Can this be merged with ResourceProcessor in OBR?
+ */
+
/**
- * A ResourceProcessor is an object that can manage a given resource type.
- * Processors must be registered in the OSGi registry.
- *
- * The purpose is to actually install a resource. There would be a processor
- * for OSGi bundles (which may be internal), maybe we can also have a standard
- * one for configurations for the ConfigAdmin.
+ * A ResourceProcessor processes resources from a specific namespace or
+ * namespaces (e.g. bundle). Namespaces not defined by the OSGi Alliance should
+ * use a reverse domain name scheme to avoid collision (e.g. com.acme.config).
+ * <p>
+ * ResourceProcessors are registered in the OSGi Service Registry. They
+ * advertise the namespaces they support using the service property
+ * osgi.resource.namespace. The type of this property is a String+.
+ * <p>
+ * A resource processor performs the operation corresponding to those provided
+ * by SubsystemAdmin and Subsystem that affect a subsystem's lifecycle (e.g.
+ * install and start). For example, SubsystemAdmin.install() would delegate to
+ * on a resource processor if there were any resources to install for the
+ * namespace that the resource processor supported.
+ *
+ * @ThreadSafe
*/
public interface ResourceProcessor {
-
- Session createSession(SubsystemAdmin admin);
-
- public static interface Session {
-
- void process(Resource resource) throws SubsystemException;
-
- void dropped(Resource resource) throws SubsystemException;
-
- void prepare() throws SubsystemException;
-
- void commit();
-
- void rollback();
-
- }
-
+ /**
+ * Process a resource according to the provided operation. The type of
+ * processing to perform is defined by the type of ResourceOperation. The
+ * resource processor must register as a Participant with the provided
+ * Coordination and should process the resource according to the
+ * notifications given to the Participant. For example, if the resource
+ * processor participant is told the Coordination failed, then the resource
+ * processor should not perform the operation at all or should undo any
+ * processing that has already been performed. If the resource processor is
+ * unable to undo previous work, then it must throw an exception back to
+ * the Coordinator service from the Participant.failed method. Must call
+ * ResourceOperation.completed in Participant.ended.
+ * @param operation
+ * @throws SubsystemException
+ */
+ public void process(ResourceOperation operation) throws SubsystemException;
}
Modified: aries/trunk/subsystem/subsystem-core/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/pom.xml?rev=1102244&r1=1102243&r2=1102244&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/pom.xml (original)
+++ aries/trunk/subsystem/subsystem-core/pom.xml Thu May 12 11:27:11 2011
@@ -54,15 +54,57 @@
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>coordinator</artifactId>
+ <version>1.0.0.v20110314</version>
+ </dependency>
<dependency>
<groupId>org.apache.aries.subsystem</groupId>
<artifactId>org.apache.aries.subsystem.api</artifactId>
<version>0.1-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
- <groupId>org.apache.aries.subsystem</groupId>
- <artifactId>org.apache.aries.subsystem.scope.api</artifactId>
- <version>0.1-SNAPSHOT</version>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>region</artifactId>
+ <version>1.0.0.v20110506</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.api</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.utils</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.testsupport</groupId>
+ <artifactId>org.apache.aries.testsupport.unit</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
@@ -83,6 +125,12 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.utils</artifactId>
<version>1.1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.aries.application</groupId>
@@ -98,6 +146,12 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.bundlerepository</artifactId>
<version>1.6.4</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/ResourceConverter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/ResourceConverter.java?rev=1102244&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/ResourceConverter.java (added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/ResourceConverter.java Thu May 12 11:27:11 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.apache.aries.subsystem.core;
+
+import org.apache.aries.subsystem.SubsystemException;
+import org.apache.aries.subsystem.spi.Resource;
+
+/**
+ * ResourceConverters are used to transform resources into another kind of
+ * resources. For example, convert a blueprint xml configuration file
+ * into a deployable OSGi bundle
+ *
+ * Note that converters do not really *enable* anything. The ease the use
+ * of the subsystem archives, so we could remove those from the SPI.
+ */
+public interface ResourceConverter {
+
+ /**
+ * Check if the converter can convert a resource into the given type
+ * TODO: do we need that or should it be inferred from service properties?
+ *
+ * @param resource
+ * @param targetType
+ * @return
+ */
+ boolean canConvert(Resource resource, String targetType);
+
+ /**
+ * Convert a resource into the given type.
+ *
+ * @param resource
+ * @return <code>null</code> if the conversion is not supported
+ */
+ Resource convert(Resource resource, String targetType) throws SubsystemException;
+
+}
Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemEvent.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemEvent.java?rev=1102244&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemEvent.java (added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemEvent.java Thu May 12 11:27:11 2011
@@ -0,0 +1,115 @@
+/*
+ * 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.apache.aries.subsystem.core;
+
+import org.apache.aries.subsystem.Subsystem;
+
+/**
+ * Event sent to listeners when an operation has been performed on a subsystem.
+ */
+public class SubsystemEvent {
+
+ /**
+ * The subsystem lifecycle event types that can be produced by a subsystem.
+ * See {@link Subsystem} and {@link SubsystemAdmin} for details on the
+ * circumstances under which these events are fired.
+ */
+ public enum Type {
+
+ /**
+ * Event type used to indicate a subsystem has been installed.
+ */
+ INSTALLED,
+
+ /**
+ * Event type used to indicate a subsystem has been started.
+ */
+ STARTED,
+
+ /**
+ * Event type used to indicate a subsystem has been stopped.
+ */
+ STOPPED,
+
+ /**
+ * Event type used to indicate a subsystem has been updated.
+ */
+ UPDATED,
+
+ /**
+ * Event type used to indicate a subsystem has been uninstalled.
+ */
+ UNINSTALLED,
+
+ /**
+ * Event type used to indicate a subsystem has been resolved.
+ */
+ RESOLVED,
+
+ /**
+ * Event type used to indicate a subsystem is starting.
+ */
+ STARTING,
+
+ /**
+ * Event type used to indicate a subsystem is stopping.
+ */
+ STOPPING
+ }
+ private final Type type;
+
+ private final long timestamp;
+
+ private final Subsystem subsystem;
+
+ /**
+ * Constructs a new subsystem event.
+ *
+ * @param type The type of the event. For example, INSTALLED. See {@link SubsystemEvent.Type} for the list of event types.
+ * @param timestamp The timestamp for the event.
+ * @param subsystem The subsystem for which the event is being created.
+ */
+ public SubsystemEvent(Type type, long timestamp, Subsystem subsystem) {
+ this.type = type;
+ this.timestamp = timestamp;
+ this.subsystem = subsystem;
+ }
+
+ /**
+ * Gets the type of the subsystem event. See {@link SubsystemEvent.Type} for the list of event types.
+ * @return the type of the subsystem event.
+ */
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * Gets the timestamp for the subsystem event.
+ *
+ * @return the timestamp for the subsystem event.
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Gets the subsystem for which the event was created.
+ *
+ * @return the subsystem for which the event was created.
+ */
+ public Subsystem getSubsystem() {
+ return subsystem;
+ }
+
+}
Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemListener.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemListener.java?rev=1102244&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemListener.java (added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/SubsystemListener.java Thu May 12 11:27:11 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.apache.aries.subsystem.core;
+
+/**
+ * A listener for subsystem events (see {@link SubsystemEvent}).
+ *
+ * Registered OSGi services implementing this interface will be notified of
+ * subsystem events when they occur. Notifications will only be delivered for
+ * subsystems that are at the same level. For example, events are not seen for
+ * parent or child subsystems.
+ */
+public interface SubsystemListener {
+
+ /**
+ * Called to deliver a subsystem event to this subsystem listener.
+ *
+ * @param event The subsystem event being delivered.
+ */
+ void subsystemEvent(SubsystemEvent event);
+
+}