Use offical R6 compendium jar
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1694395 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/pom.xml b/scr/pom.xml
index fb60390..9aa7d11 100644
--- a/scr/pom.xml
+++ b/scr/pom.xml
@@ -77,20 +77,20 @@
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
+ <artifactId>osgi.core</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.annotation</artifactId>
- <version>6.0.0</version>
+ <artifactId>osgi.annotation</artifactId>
+ <version>6.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.enterprise</artifactId>
- <version>5.0.0</version>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git a/scr/src/main/java/org/osgi/service/component/ComponentConstants.java b/scr/src/main/java/org/osgi/service/component/ComponentConstants.java
deleted file mode 100644
index de3a41a..0000000
--- a/scr/src/main/java/org/osgi/service/component/ComponentConstants.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2015). 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.component;
-
-import org.osgi.annotation.versioning.ProviderType;
-
-/**
- * Defines standard names for Service Component constants.
- *
- * @author $Id: 624eb5610c2127d24ce76f16b3cc146cbcf6db57 $
- */
-@ProviderType
-public interface ComponentConstants {
- /**
- * Manifest header specifying the XML documents within a bundle that contain
- * the bundle's Service Component descriptions.
- * <p>
- * The attribute value may be retrieved from the {@code Dictionary} object
- * returned by the {@code Bundle.getHeaders} method.
- */
- public static final String SERVICE_COMPONENT = "Service-Component";
-
- /**
- * A component property for a component configuration that contains the name
- * of the component as specified in the {@code name} attribute of the
- * {@code component} element. The value of this property must be of type
- * {@code String}.
- */
- public final static String COMPONENT_NAME = "component.name";
-
- /**
- * A component property that contains the generated id for a component
- * configuration. The value of this property must be of type {@code Long}.
- *
- * <p>
- * The value of this property is assigned by Service Component Runtime when
- * a component configuration is created. Service Component Runtime assigns a
- * unique value that is larger than all previously assigned values since
- * Service Component Runtime was started. These values are NOT persistent
- * across restarts of Service Component Runtime.
- */
- public final static String COMPONENT_ID = "component.id";
-
- /**
- * A service registration property for a Component Factory that contains the
- * value of the {@code factory} attribute. The value of this property must
- * be of type {@code String}.
- */
- public final static String COMPONENT_FACTORY = "component.factory";
-
- /**
- * The suffix for reference target properties. These properties contain the
- * filter to select the target services for a reference. The value of this
- * property must be of type {@code String}.
- */
- public final static String REFERENCE_TARGET_SUFFIX = ".target";
-
- /**
- * The reason the component configuration was deactivated is unspecified.
- *
- * @since 1.1
- */
- public static final int DEACTIVATION_REASON_UNSPECIFIED = 0;
-
- /**
- * The component configuration was deactivated because the component was
- * disabled.
- *
- * @since 1.1
- */
- public static final int DEACTIVATION_REASON_DISABLED = 1;
-
- /**
- * The component configuration was deactivated because a reference became
- * unsatisfied.
- *
- * @since 1.1
- */
- public static final int DEACTIVATION_REASON_REFERENCE = 2;
-
- /**
- * The component configuration was deactivated because its configuration was
- * changed.
- *
- * @since 1.1
- */
- public static final int DEACTIVATION_REASON_CONFIGURATION_MODIFIED = 3;
-
- /**
- * The component configuration was deactivated because its configuration was
- * deleted.
- *
- * @since 1.1
- */
- public static final int DEACTIVATION_REASON_CONFIGURATION_DELETED = 4;
-
- /**
- * The component configuration was deactivated because the component was
- * disposed.
- *
- * @since 1.1
- */
- public static final int DEACTIVATION_REASON_DISPOSED = 5;
-
- /**
- * The component configuration was deactivated because the bundle was
- * stopped.
- *
- * @since 1.1
- */
- public static final int DEACTIVATION_REASON_BUNDLE_STOPPED = 6;
-
- /**
- * Capability name for Service Component Runtime.
- *
- * <p>
- * Used in {@code Provide-Capability} and {@code Require-Capability}
- * manifest headers with the {@code osgi.extender} namespace. For example:
- *
- * <pre>
- * Require-Capability: osgi.extender;
- * filter:="(&(osgi.extender=osgi.component)(version>=1.3)(!(version>=2.0)))"
- * </pre>
- *
- * @since 1.3
- */
- public static final String COMPONENT_CAPABILITY_NAME = "osgi.component";
-}
diff --git a/scr/src/main/java/org/osgi/service/component/ComponentContext.java b/scr/src/main/java/org/osgi/service/component/ComponentContext.java
deleted file mode 100644
index 4e0c4a1..0000000
--- a/scr/src/main/java/org/osgi/service/component/ComponentContext.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2014). 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.component;
-
-import java.util.Dictionary;
-import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-/**
- * A Component Context object is used by a component instance to interact with
- * its execution context including locating services by reference name. Each
- * component instance has a unique Component Context.
- *
- * <p>
- * A component instance may obtain its Component Context object through its
- * activate, modified, and deactivate methods.
- *
- * @ThreadSafe
- * @author $Id: 5499691841bcfbb0d35222564785af1a5a530c7f $
- */
-@ProviderType
-public interface ComponentContext {
- /**
- * Returns the component properties for this Component Context.
- *
- * @return The properties for this Component Context. The Dictionary is read
- * only and cannot be modified.
- */
- public Dictionary<String, Object> getProperties();
-
- /**
- * Returns the service object for the specified reference name.
- *
- * <p>
- * If the cardinality of the reference is {@code 0..n} or {@code 1..n} and
- * multiple services are bound to the reference, the service with the
- * highest ranking (as specified in its {@code Constants.SERVICE_RANKING}
- * property) is returned. If there is a tie in ranking, the service with the
- * lowest service id (as specified in its {@code Constants.SERVICE_ID}
- * property); that is, the service that was registered first is returned.
- *
- * @param name The name of a reference as specified in a {@code reference}
- * element in this component's description.
- * @return A service object for the referenced service or {@code null} if
- * the reference cardinality is {@code 0..1} or {@code 0..n} and no
- * bound service is available.
- * @throws ComponentException If Service Component Runtime catches an
- * exception while activating the bound service.
- */
- public Object locateService(String name);
-
- /**
- * Returns the service object for the specified reference name and
- * {@code ServiceReference}.
- *
- * @param <S> Type of Service.
- * @param name The name of a reference as specified in a {@code reference}
- * element in this component's description.
- * @param reference The {@code ServiceReference} to a bound service. This
- * must be a {@code ServiceReference} provided to the component via
- * the bind or unbind method for the specified reference name.
- * @return A service object for the referenced service or {@code null} if
- * the specified {@code ServiceReference} is not a bound service for
- * the specified reference name.
- * @throws ComponentException If Service Component Runtime catches an
- * exception while activating the bound service.
- */
- public <S> S locateService(String name, ServiceReference<S> reference);
-
- /**
- * Returns the service objects for the specified reference name.
- *
- * @param name The name of a reference as specified in a {@code reference}
- * element in this component's description.
- * @return An array of service objects for the referenced service or
- * {@code null} if the reference cardinality is {@code 0..1} or
- * {@code 0..n} and no bound service is available. If the reference
- * cardinality is {@code 0..1} or {@code 1..1} and a bound service
- * is available, the array will have exactly one element.
- * @throws ComponentException If Service Component Runtime catches an
- * exception while activating a bound service.
- */
- public Object[] locateServices(String name);
-
- /**
- * Returns the {@code BundleContext} of the bundle which contains this
- * component.
- *
- * @return The {@code BundleContext} of the bundle containing this
- * component.
- */
- public BundleContext getBundleContext();
-
- /**
- * If the component instance is registered as a service using the
- * {@code servicescope="bundle"} or {@code servicescope="prototype"}
- * attribute, then this method returns the bundle using the service provided
- * by the component instance.
- * <p>
- * This method will return {@code null} if:
- * <ul>
- * <li>The component instance is not a service, then no bundle can be using
- * it as a service.</li>
- * <li>The component instance is a service but did not specify the
- * {@code servicescope="bundle"} or {@code servicescope="prototype"}
- * attribute, then all bundles using the service provided by the component
- * instance will share the same component instance.</li>
- * <li>The service provided by the component instance is not currently being
- * used by any bundle.</li>
- * </ul>
- *
- * @return The bundle using the component instance as a service or
- * {@code null}.
- */
- public Bundle getUsingBundle();
-
- /**
- * Returns the Component Instance object for the component instance
- * associated with this Component Context.
- *
- * @return The Component Instance object for the component instance.
- */
- public ComponentInstance getComponentInstance();
-
- /**
- * Enables the specified component name. The specified component name must
- * be in the same bundle as this component.
- *
- * <p>
- * This method must return after changing the enabled state of the specified
- * component name. Any actions that result from this, such as activating or
- * deactivating a component configuration, must occur asynchronously to this
- * method call.
- *
- * @param name The name of a component or {@code null} to indicate all
- * components in the bundle.
- */
- public void enableComponent(String name);
-
- /**
- * Disables the specified component name. The specified component name must
- * be in the same bundle as this component.
- *
- * <p>
- * This method must return after changing the enabled state of the specified
- * component name. Any actions that result from this, such as activating or
- * deactivating a component configuration, must occur asynchronously to this
- * method call.
- *
- * @param name The name of a component.
- */
- public void disableComponent(String name);
-
- /**
- * If the component instance is registered as a service using the
- * {@code service} element, then this method returns the service reference
- * of the service provided by this component instance.
- * <p>
- * This method will return {@code null} if the component instance is not
- * registered as a service.
- *
- * @return The {@code ServiceReference} object for the component instance or
- * {@code null} if the component instance is not registered as a
- * service.
- */
- public ServiceReference<?> getServiceReference();
-}
diff --git a/scr/src/main/java/org/osgi/service/component/ComponentException.java b/scr/src/main/java/org/osgi/service/component/ComponentException.java
deleted file mode 100644
index 8b2aaab..0000000
--- a/scr/src/main/java/org/osgi/service/component/ComponentException.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2014). 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.component;
-
-/**
- * Unchecked exception which may be thrown by Service Component Runtime.
- *
- * @author $Id: 6b47774608ff37a2076b9f58090509093314a67a $
- */
-public class ComponentException extends RuntimeException {
- static final long serialVersionUID = -7438212656298726924L;
-
- /**
- * Construct a new ComponentException with the specified message and cause.
- *
- * @param message The message for the exception.
- * @param cause The cause of the exception. May be {@code null}.
- */
- public ComponentException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Construct a new ComponentException with the specified message.
- *
- * @param message The message for the exception.
- */
- public ComponentException(String message) {
- super(message);
- }
-
- /**
- * Construct a new ComponentException with the specified cause.
- *
- * @param cause The cause of the exception. May be {@code null}.
- */
- public ComponentException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Returns the cause of this exception or {@code null} if no cause was set.
- *
- * @return The cause of this exception or {@code null} if no cause was set.
- */
- @Override
- public Throwable getCause() {
- return super.getCause();
- }
-
- /**
- * Initializes the cause of this exception to the specified value.
- *
- * @param cause The cause of this exception.
- * @return This exception.
- * @throws IllegalArgumentException If the specified cause is this
- * exception.
- * @throws IllegalStateException If the cause of this exception has already
- * been set.
- */
- @Override
- public Throwable initCause(Throwable cause) {
- return super.initCause(cause);
- }
-}
diff --git a/scr/src/main/java/org/osgi/service/component/ComponentFactory.java b/scr/src/main/java/org/osgi/service/component/ComponentFactory.java
deleted file mode 100644
index ca74a7a..0000000
--- a/scr/src/main/java/org/osgi/service/component/ComponentFactory.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2014). 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.component;
-
-import java.util.Dictionary;
-import org.osgi.annotation.versioning.ProviderType;
-
-/**
- * When a component is declared with the {@code factory} attribute on its
- * {@code component} element, Service Component Runtime will register a
- * Component Factory service to allow new component configurations to be created
- * and activated rather than automatically creating and activating component
- * configuration as necessary.
- *
- * @ThreadSafe
- * @author $Id: a6422fc517a31533b1188d5ab9d9ee95a7a52c8a $
- */
-@ProviderType
-public interface ComponentFactory {
- /**
- * Create and activate a new component configuration. Additional properties
- * may be provided for the component configuration.
- *
- * @param properties Additional properties for the component configuration
- * or {@code null} if there are no additional properties.
- * @return A {@code ComponentInstance} object encapsulating the component
- * instance of the component configuration. The component
- * configuration has been activated and, if the component specifies
- * a {@code service} element, the component instance has been
- * registered as a service.
- * @throws ComponentException If Service Component Runtime is unable to
- * activate the component configuration.
- */
- public ComponentInstance newInstance(Dictionary<String, ?> properties);
-}
diff --git a/scr/src/main/java/org/osgi/service/component/ComponentInstance.java b/scr/src/main/java/org/osgi/service/component/ComponentInstance.java
deleted file mode 100644
index c45e075..0000000
--- a/scr/src/main/java/org/osgi/service/component/ComponentInstance.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2004, 2013). 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.component;
-
-import org.osgi.annotation.versioning.ProviderType;
-
-/**
- * A ComponentInstance encapsulates a component instance of an activated
- * component configuration. ComponentInstances are created whenever a component
- * configuration is activated.
- *
- * <p>
- * ComponentInstances are never reused. A new ComponentInstance object will be
- * created when the component configuration is activated again.
- *
- * @ThreadSafe
- * @author $Id: 8078babdd771f18831a54bfaa407e4edd2781552 $
- */
-@ProviderType
-public interface ComponentInstance {
- /**
- * Dispose of the component configuration for this component instance. The
- * component configuration will be deactivated. If the component
- * configuration has already been deactivated, this method does nothing.
- */
- public void dispose();
-
- /**
- * Returns the component instance of the activated component configuration.
- *
- * @return The component instance or {@code null} if the component
- * configuration has been deactivated.
- */
- public Object getInstance();
-}
diff --git a/scr/src/main/java/org/osgi/service/component/ComponentServiceObjects.java b/scr/src/main/java/org/osgi/service/component/ComponentServiceObjects.java
deleted file mode 100644
index 62cabcb..0000000
--- a/scr/src/main/java/org/osgi/service/component/ComponentServiceObjects.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2012, 2014). 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.component;
-
-import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceObjects;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Allows multiple service objects for a service to be obtained.
- *
- * <p>
- * A component instance can receive a {@code ComponentServiceObjects} object via
- * a reference that is typed {@code ComponentServiceObjects}.
- *
- * <p>
- * For services with {@link Constants#SCOPE_PROTOTYPE prototype} scope, multiple
- * service objects for the service can be obtained. For services with
- * {@link Constants#SCOPE_SINGLETON singleton} or {@link Constants#SCOPE_BUNDLE
- * bundle} scope, only one, use-counted service object is available.
- *
- * <p>
- * Any unreleased service objects obtained from this
- * {@code ComponentServiceObjects} object are automatically released by Service
- * Component Runtime when the service becomes unbound.
- *
- * @param <S> Type of Service
- * @ThreadSafe
- * @since 1.3
- * @see ServiceObjects
- * @author $Id: 49fc5e86384324c73b412d8b733f715f8b55d4d6 $
- */
-@ProviderType
-public interface ComponentServiceObjects<S> {
- /**
- * Returns a service object for the {@link #getServiceReference()
- * associated} service.
- *
- * <p>
- * This method will always return {@code null} when the associated service
- * has been become unbound.
- *
- * @return A service object for the associated service or {@code null} if
- * the service is unbound, the customized service object returned by
- * a {@code ServiceFactory} does not implement the classes under
- * which it was registered or the {@code ServiceFactory} threw an
- * exception.
- * @throws IllegalStateException If the associated service has been become
- * unbound.
- * @see #ungetService(Object)
- */
- public S getService();
-
- /**
- * Releases a service object for the {@link #getServiceReference()
- * associated} service.
- *
- * <p>
- * The specified service object must no longer be used and all references to
- * it should be destroyed after calling this method.
- *
- * @param service A service object previously provided by this
- * {@code ComponentServiceObjects} object.
- * @throws IllegalStateException If the associated service has been become
- * unbound.
- * @throws IllegalArgumentException If the specified service object was not
- * provided by this {@code ComponentServiceObjects} object.
- * @see #getService()
- */
- public void ungetService(S service);
-
- /**
- * Returns the {@link ServiceReference} for the service associated with this
- * {@code ComponentServiceObjects} object.
- *
- * @return The {@link ServiceReference} for the service associated with this
- * {@code ComponentServiceObjects} object.
- */
- public ServiceReference<S> getServiceReference();
-}
diff --git a/scr/src/main/java/org/osgi/service/component/package-info.java b/scr/src/main/java/org/osgi/service/component/package-info.java
deleted file mode 100644
index 010a246..0000000
--- a/scr/src/main/java/org/osgi/service/component/package-info.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2010, 2013). 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.
- */
-
-/**
- * Service Component Package Version 1.3.
- *
- * <p>
- * Bundles wishing to use this package must list the package in the
- * Import-Package header of the bundle's manifest. This package has two types of
- * users: the consumers that use the API in this package and the providers that
- * implement the API in this package.
- *
- * <p>
- * Example import for consumers using the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.service.component; version="[1.3,2.0)"}
- * <p>
- * Example import for providers implementing the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.service.component; version="[1.3,1.4)"}
- *
- * @author $Id: 9c158e8fb0f0512b3fbfb759fc06ed54afc0d8b0 $
- */
-
-@Version("1.3")
-package org.osgi.service.component;
-
-import org.osgi.annotation.versioning.Version;
-
diff --git a/scr/src/main/java/org/osgi/service/component/runtime/ServiceComponentRuntime.java b/scr/src/main/java/org/osgi/service/component/runtime/ServiceComponentRuntime.java
deleted file mode 100755
index d71024c..0000000
--- a/scr/src/main/java/org/osgi/service/component/runtime/ServiceComponentRuntime.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2013, 2014). 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.component.runtime;
-
-import java.util.Collection;
-import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.framework.Bundle;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
-import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
-import org.osgi.util.promise.Promise;
-
-/**
- * The {@code ServiceComponentRuntime} service represents the Declarative
- * Services actor, known as Service Component Runtime (SCR), that manages the
- * service components and their life cycle. The {@code ServiceComponentRuntime}
- * service allows introspection of the components managed by Service Component
- * Runtime.
- *
- * <p>
- * This service differentiates between a {@link ComponentDescriptionDTO} and a
- * {@link ComponentConfigurationDTO}. A {@link ComponentDescriptionDTO} is a
- * representation of a declared component description. A
- * {@link ComponentConfigurationDTO} is a representation of an actual instance
- * of a declared component description parameterized by component properties.
- * <p>
- *
- * Access to this service requires the
- * {@code ServicePermission[ServiceComponentRuntime, GET]} permission. It is
- * intended that only administrative bundles should be granted this permission
- * to limit access to the potentially intrusive methods provided by this
- * service.
- *
- * @ThreadSafe
- * @since 1.3
- * @author $Id: 59760dcd57f2162574cfd0c7f3a393825566e78f $
- */
-@ProviderType
-public interface ServiceComponentRuntime {
-
- /**
- * Returns the component descriptions declared by the specified active
- * bundles.
- *
- * <p>
- * Only component descriptions from active bundles are returned. If the
- * specified bundles have no declared components or are not active, an empty
- * collection is returned.
- *
- * @param bundles The bundles whose declared component descriptions are to
- * be returned. Specifying no bundles, or the equivalent of an empty
- * {@code Bundle} array, will return the declared component
- * descriptions from all active bundles.
- * @return The declared component descriptions of the specified active
- * {@code bundles}. An empty collection is returned if there are no
- * component descriptions for the specified active bundles.
- */
- Collection<ComponentDescriptionDTO> getComponentDescriptionDTOs(Bundle... bundles);
-
- /**
- * Returns the {@link ComponentDescriptionDTO} declared with the specified name
- * by the specified bundle.
- *
- * <p>
- * Only component descriptions from active bundles are returned.
- * {@code null} if no such component is declared by the given {@code bundle}
- * or the bundle is not active.
- *
- * @param bundle The bundle declaring the component description. Must not be
- * {@code null}.
- * @param name The name of the component description. Must not be
- * {@code null}.
- * @return The declared component description or {@code null} if the
- * specified bundle is not active or does not declare a component
- * description with the specified name.
- */
- ComponentDescriptionDTO getComponentDescriptionDTO(Bundle bundle, String name);
-
- /**
- * Returns the component configurations for the specified component
- * description.
- *
- * @param description The component description. Must not be {@code null}.
- * @return A collection containing a snapshot of the current component
- * configurations for the specified component description. An empty
- * collection is returned if there are none.
- */
- Collection<ComponentConfigurationDTO> getComponentConfigurationDTOs(ComponentDescriptionDTO description);
-
- /**
- * Returns whether the specified component description is currently enabled.
- *
- * <p>
- * The enabled state of a component description is initially set by the
- * {@link ComponentDescriptionDTO#defaultEnabled enabled} attribute of the
- * component description.
- *
- * @param description The component description. Must not be {@code null}.
- * @return {@code true} if the specified component description is currently
- * enabled. Otherwise, {@code false}.
- * @see #enableComponent(ComponentDescriptionDTO)
- * @see #disableComponent(ComponentDescriptionDTO)
- * @see ComponentContext#disableComponent(String)
- * @see ComponentContext#enableComponent(String)
- */
- boolean isComponentEnabled(ComponentDescriptionDTO description);
-
- /**
- * Enables the specified component description.
- *
- * <p>
- * If the specified component description is currently enabled, this method
- * has no effect.
- *
- * <p>
- * This method must return after changing the enabled state of the specified
- * component description. Any actions that result from this, such as
- * activating or deactivating a component configuration, must occur
- * asynchronously to this method call.
- *
- * @param description The component description to enable. Must not be
- * {@code null}.
- * @return A promise that will be resolved when the actions that result from
- * changing the enabled state of the specified component have
- * completed.
- * @see #isComponentEnabled(ComponentDescriptionDTO)
- */
- Promise<Void> enableComponent(ComponentDescriptionDTO description);
-
- /**
- * Disables the specified component description.
- *
- * <p>
- * If the specified component description is currently disabled, this method
- * has no effect.
- *
- * <p>
- * This method must return after changing the enabled state of the specified
- * component description. Any actions that result from this, such as
- * activating or deactivating a component configuration, must occur
- * asynchronously to this method call.
- *
- * @param description The component description to disable. Must not be
- * {@code null}.
- * @return A promise that will be resolved when the actions that result from
- * changing the enabled state of the specified component have
- * completed.
- * @see #isComponentEnabled(ComponentDescriptionDTO)
- */
- Promise<Void> disableComponent(ComponentDescriptionDTO description);
-}
diff --git a/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentConfigurationDTO.java b/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentConfigurationDTO.java
deleted file mode 100755
index dc3227d..0000000
--- a/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentConfigurationDTO.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2013, 2014). 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.component.runtime.dto;
-
-import java.util.Map;
-import org.osgi.dto.DTO;
-import org.osgi.service.component.ComponentContext;
-
-/**
- * A representation of an actual instance of a declared component description
- * parameterized by component properties.
- *
- * @since 1.3
- * @NotThreadSafe
- * @author $Id: a3e98bbac97a1d79805f9be0ed7f2ae811f112d0 $
- */
-public class ComponentConfigurationDTO extends DTO {
- /**
- * The component configuration is unsatisfied due to a missing required
- * configuration.
- */
- public static final int UNSATISFIED_CONFIGURATION = 1;
-
- /**
- * The component configuration is unsatisfied due to an unsatisfied
- * reference.
- */
- public static final int UNSATISFIED_REFERENCE = 2;
-
- /**
- * The component configuration is satisfied.
- *
- * <p>
- * Any {@link ComponentDescriptionDTO#serviceInterfaces services} declared
- * by the component description are registered.
- */
- public static final int SATISFIED = 4;
-
- /**
- * The component configuration is active.
- *
- * <p>
- * This is the normal operational state of a component configuration.
- */
- public static final int ACTIVE = 8;
-
- /**
- * The representation of the component configuration's component
- * description.
- */
- public ComponentDescriptionDTO description;
-
- /**
- * The current state of the component configuration.
- *
- * <p>
- * This is one of {@link #UNSATISFIED_CONFIGURATION},
- * {@link #UNSATISFIED_REFERENCE}, {@link #SATISFIED} or {@link #ACTIVE}.
- */
- public int state;
-
- /**
- * The id of the component configuration.
- *
- * <p>
- * The id is a non-persistent, unique value assigned at runtime. The id is
- * also available as the {@code component.id} component property. The value
- * of this field is unspecified if the state of this component configuration
- * is unsatisfied.
- */
- public long id;
-
- /**
- * The component properties for the component configuration.
- *
- * @see ComponentContext#getProperties()
- */
- public Map<String, Object> properties;
-
- /**
- * The satisfied references.
- *
- * <p>
- * Each {@link SatisfiedReferenceDTO} in the array represents a satisfied
- * reference of the component configuration. The array must be empty if the
- * component configuration has no satisfied references.
- */
- public SatisfiedReferenceDTO[] satisfiedReferences;
-
- /**
- * The unsatisfied references.
- *
- * <p>
- * Each {@link UnsatisfiedReferenceDTO} in the array represents an
- * unsatisfied reference of the component configuration. The array must be
- * empty if the component configuration has no unsatisfied references.
- */
- public UnsatisfiedReferenceDTO[] unsatisfiedReferences;
-}
diff --git a/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java b/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java
deleted file mode 100755
index 8e50ca3..0000000
--- a/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2013, 2014). 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.component.runtime.dto;
-
-import java.util.Map;
-import org.osgi.dto.DTO;
-import org.osgi.framework.dto.BundleDTO;
-
-/**
- * A representation of a declared component description.
- *
- * @since 1.3
- * @NotThreadSafe
- * @author $Id: 9f098a6edef3359b4dbd21e1e58bbad01b89b995 $
- */
-public class ComponentDescriptionDTO extends DTO {
- /**
- * The name of the component.
- *
- * <p>
- * This is declared in the {@code name} attribute of the {@code component}
- * element. This must be the default name if the component description does
- * not declare a name.
- */
- public String name;
-
- /**
- * The bundle declaring the component description.
- */
- public BundleDTO bundle;
-
- /**
- * The component factory name.
- *
- * <p>
- * This is declared in the {@code factory} attribute of the
- * {@code component} element. This must be {@code null} if the component
- * description is not declared as a component factory.
- */
- public String factory;
-
- /**
- * The service scope.
- *
- * <p>
- * This is declared in the {@code scope} attribute of the {@code service}
- * element. This must be {@code null} if the component description does not
- * declare any service interfaces.
- */
- public String scope;
-
- /**
- * The fully qualified name of the implementation class.
- *
- * <p>
- * This is declared in the {@code class} attribute of the
- * {@code implementation} element.
- */
- public String implementationClass;
-
- /**
- * The initial enabled state.
- *
- * <p>
- * This is declared in the {@code enabled} attribute of the
- * {@code component} element.
- */
- public boolean defaultEnabled;
-
- /**
- * The immediate state.
- *
- * <p>
- * This is declared in the {@code immediate} attribute of the
- * {@code component} element.
- */
- public boolean immediate;
-
- /**
- * The fully qualified names of the service interfaces.
- *
- * <p>
- * These are declared in the {@code interface} attribute of the
- * {@code provide} elements. The array must be empty if the component
- * description does not declare any service interfaces.
- */
- public String[] serviceInterfaces;
-
- /**
- * The declared component properties.
- *
- * <p>
- * These are declared in the {@code property} and {@code properties}
- * elements.
- */
- public Map<String, Object> properties;
-
- /**
- * The referenced services.
- *
- * <p>
- * These are declared in the {@code reference} elements. The array must be
- * empty if the component description does not declare references to any
- * services.
- */
- public ReferenceDTO[] references;
-
- /**
- * The name of the activate method.
- *
- * <p>
- * This is declared in the {@code activate} attribute of the
- * {@code component} element. This must be {@code null} if the component
- * description does not declare an activate method name.
- */
- public String activate;
-
- /**
- * The name of the deactivate method.
- *
- * <p>
- * This is declared in the {@code deactivate} attribute of the
- * {@code component} element. This must be {@code null} if the component
- * description does not declare a deactivate method name.
- */
- public String deactivate;
-
- /**
- * The name of the modified method.
- *
- * <p>
- * This is declared in the {@code modified} attribute of the
- * {@code component} element. This must be {@code null} if the component
- * description does not declare a modified method name.
- */
- public String modified;
-
- /**
- * The configuration policy.
- *
- * <p>
- * This is declared in the {@code configuration-policy} attribute of the
- * {@code component} element. This must be the default configuration policy
- * if the component description does not declare a configuration policy.
- */
- public String configurationPolicy;
-
- /**
- * The configuration pids.
- *
- * <p>
- * These are declared in the {@code configuration-pid} attribute of the
- * {@code component} element. This must contain the default configuration
- * pid if the component description does not declare a configuration pid.
- */
- public String[] configurationPid;
-}
diff --git a/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java b/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java
deleted file mode 100755
index 8f7c5b1..0000000
--- a/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2013, 2015). 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.component.runtime.dto;
-
-import org.osgi.dto.DTO;
-
-/**
- * A representation of a declared reference to a service.
- *
- * @since 1.3
- * @NotThreadSafe
- * @author $Id: fca2413271fcded16b4ebe3c6628fe8660e2575e $
- */
-public class ReferenceDTO extends DTO {
-
- /**
- * The name of the reference.
- *
- * <p>
- * This is declared in the {@code name} attribute of the {@code reference}
- * element. This must be the default name if the component description does
- * not declare a name for the reference.
- */
- public String name;
-
- /**
- * The service interface of the reference.
- *
- * <p>
- * This is declared in the {@code interface} attribute of the
- * {@code reference} element.
- */
- public String interfaceName;
-
- /**
- * The cardinality of the reference.
- *
- * <p>
- * This is declared in the {@code cardinality} attribute of the
- * {@code reference} element. This must be the default cardinality if the
- * component description does not declare a cardinality for the reference.
- */
- public String cardinality;
-
- /**
- * The policy of the reference.
- *
- * <p>
- * This is declared in the {@code policy} attribute of the {@code reference}
- * element. This must be the default policy if the component description
- * does not declare a policy for the reference.
- */
- public String policy;
-
- /**
- * The policy option of the reference.
- *
- * <p>
- * This is declared in the {@code policy-option} attribute of the
- * {@code reference} element. This must be the default policy option if the
- * component description does not declare a policy option for the reference.
- */
- public String policyOption;
-
- /**
- * The target of the reference.
- *
- * <p>
- * This is declared in the {@code target} attribute of the {@code reference}
- * element. This must be {@code null} if the component description does not
- * declare a target for the reference.
- */
- public String target;
-
- /**
- * The name of the bind method of the reference.
- *
- * <p>
- * This is declared in the {@code bind} attribute of the {@code reference}
- * element. This must be {@code null} if the component description does not
- * declare a bind method for the reference.
- */
- public String bind;
-
- /**
- * The name of the unbind method of the reference.
- *
- * <p>
- * This is declared in the {@code unbind} attribute of the {@code reference}
- * element. This must be {@code null} if the component description does not
- * declare an unbind method for the reference.
- */
- public String unbind;
-
- /**
- * The name of the updated method of the reference.
- *
- * <p>
- * This is declared in the {@code updated} attribute of the
- * {@code reference} element. This must be {@code null} if the component
- * description does not declare an updated method for the reference.
- */
- public String updated;
-
- /**
- * The name of the field of the reference.
- *
- * <p>
- * This is declared in the {@code field} attribute of the {@code reference}
- * element. This must be {@code null} if the component description does not
- * declare a field for the reference.
- */
- public String field;
-
- /**
- * The field option of the reference.
- *
- * <p>
- * This is declared in the {@code field-option} attribute of the
- * {@code reference} element. This must be {@code null} if the component
- * description does not declare a field for the reference.
- */
- public String fieldOption;
-
- /**
- * The scope of the reference.
- *
- * <p>
- * This is declared in the {@code scope} attribute of the {@code reference}
- * element. This must be the default scope if the component description does
- * not declare a scope for the reference.
- */
- public String scope;
-}
diff --git a/scr/src/main/java/org/osgi/service/component/runtime/dto/SatisfiedReferenceDTO.java b/scr/src/main/java/org/osgi/service/component/runtime/dto/SatisfiedReferenceDTO.java
deleted file mode 100755
index 3bfc082..0000000
--- a/scr/src/main/java/org/osgi/service/component/runtime/dto/SatisfiedReferenceDTO.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2013, 2014). 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.component.runtime.dto;
-
-import org.osgi.dto.DTO;
-import org.osgi.framework.dto.ServiceReferenceDTO;
-
-/**
- * A representation of a satisfied reference.
- *
- * @since 1.3
- * @NotThreadSafe
- * @author $Id: 20de229ef78ffbfd603b62d4534721e2f2b17922 $
- */
-public class SatisfiedReferenceDTO extends DTO {
- /**
- * The name of the declared reference.
- *
- * <p>
- * This is declared in the {@code name} attribute of the {@code reference}
- * element of the component description.
- *
- * @see ReferenceDTO#name
- */
- public String name;
-
- /**
- * The target property of the satisfied reference.
- *
- * <p>
- * This is the value of the {@link ComponentConfigurationDTO#properties
- * component property} whose name is the concatenation of the
- * {@link ReferenceDTO#name declared reference name} and
- * ".target". This must be {@code null} if no target property is
- * set for the reference.
- */
- public String target;
-
- /**
- * The bound services.
- *
- * <p>
- * Each {@link ServiceReferenceDTO} in the array represents a service bound
- * to the satisfied reference. The array must be empty if there are no bound
- * services.
- */
- public ServiceReferenceDTO[] boundServices;
-}
diff --git a/scr/src/main/java/org/osgi/service/component/runtime/dto/UnsatisfiedReferenceDTO.java b/scr/src/main/java/org/osgi/service/component/runtime/dto/UnsatisfiedReferenceDTO.java
deleted file mode 100644
index 870c5c3..0000000
--- a/scr/src/main/java/org/osgi/service/component/runtime/dto/UnsatisfiedReferenceDTO.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2013, 2014). 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.component.runtime.dto;
-
-import org.osgi.dto.DTO;
-import org.osgi.framework.dto.ServiceReferenceDTO;
-
-/**
- * A representation of an unsatisfied reference.
- *
- * @since 1.3
- * @NotThreadSafe
- * @author $Id: 20ce77a3dbc307be592c86bf7b5eddacfe77e21b $
- */
-public class UnsatisfiedReferenceDTO extends DTO {
- /**
- * The name of the declared reference.
- *
- * <p>
- * This is declared in the {@code name} attribute of the {@code reference}
- * element of the component description.
- *
- * @see ReferenceDTO#name
- */
- public String name;
-
- /**
- * The target property of the unsatisfied reference.
- *
- * <p>
- * This is the value of the {@link ComponentConfigurationDTO#properties
- * component property} whose name is the concatenation of the
- * {@link ReferenceDTO#name declared reference name} and
- * ".target". This must be {@code null} if no target property is
- * set for the reference.
- */
- public String target;
-
- /**
- * The target services.
- *
- * <p>
- * Each {@link ServiceReferenceDTO} in the array represents a target service
- * for the reference. The array must be empty if there are no target
- * services. The upper bound on the number of target services in the array
- * is the upper bound on the {@link ReferenceDTO#cardinality cardinality} of
- * the reference.
- */
- public ServiceReferenceDTO[] targetServices;
-}
diff --git a/scr/src/main/java/org/osgi/service/component/runtime/dto/package-info.java b/scr/src/main/java/org/osgi/service/component/runtime/dto/package-info.java
deleted file mode 100644
index 75c3b78..0000000
--- a/scr/src/main/java/org/osgi/service/component/runtime/dto/package-info.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.
- */
-
-/**
- * Service Component Runtime Data Transfer Objects Package Version 1.3.
- *
- * <p>
- * Bundles wishing to use this package must list the package in the
- * Import-Package header of the bundle's manifest. This package has two types of
- * users: the consumers that use the API in this package and the providers that
- * implement the API in this package.
- *
- * <p>
- * Example import for consumers using the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.service.component.runtime.dto; version="[1.3,2.0)"}
- * <p>
- * Example import for providers implementing the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.service.component.runtime.dto; version="[1.3,1.4)"}
- *
- * @author $Id: d7d82da09d67a3ce4274ad8554966c1952a2b4de $
- */
-
-@Version("1.3")
-package org.osgi.service.component.runtime.dto;
-
-import org.osgi.annotation.versioning.Version;
-
diff --git a/scr/src/main/java/org/osgi/service/component/runtime/package-info.java b/scr/src/main/java/org/osgi/service/component/runtime/package-info.java
deleted file mode 100644
index 1dd3488..0000000
--- a/scr/src/main/java/org/osgi/service/component/runtime/package-info.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2013). 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.
- */
-
-/**
- * Service Component Runtime Package Version 1.3.
- *
- * <p>
- * Bundles wishing to use this package must list the package in the
- * Import-Package header of the bundle's manifest. This package has two types of
- * users: the consumers that use the API in this package and the providers that
- * implement the API in this package.
- *
- * <p>
- * Example import for consumers using the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.service.component.runtime; version="[1.3,2.0)"}
- * <p>
- * Example import for providers implementing the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.service.component.runtime; version="[1.3,1.4)"}
- *
- * @author $Id: 3d4fa42ce33a4682cbaeee3f094b558e6ea6080f $
- */
-
-@Version("1.3")
-package org.osgi.service.component.runtime;
-
-import org.osgi.annotation.versioning.Version;
-
diff --git a/scr/src/main/java/org/osgi/util/function/Function.java b/scr/src/main/java/org/osgi/util/function/Function.java
deleted file mode 100644
index 313d772..0000000
--- a/scr/src/main/java/org/osgi/util/function/Function.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.function;
-
-import org.osgi.annotation.versioning.ConsumerType;
-
-/**
- * A function that accepts a single argument and produces a result.
- *
- * <p>
- * This is a functional interface and can be used as the assignment target for a
- * lambda expression or method reference.
- *
- * @param <T> The type of the function input.
- * @param <R> The type of the function output.
- *
- * @ThreadSafe
- * @author $Id: 5d812f75c0b4f88f01083189babb3ef7476b5ced $
- */
-@ConsumerType
-public interface Function<T, R> {
- /**
- * Applies this function to the specified argument.
- *
- * @param t The input to this function.
- * @return The output of this function.
- */
- R apply(T t);
-}
diff --git a/scr/src/main/java/org/osgi/util/function/Predicate.java b/scr/src/main/java/org/osgi/util/function/Predicate.java
deleted file mode 100644
index 8b4c695..0000000
--- a/scr/src/main/java/org/osgi/util/function/Predicate.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.function;
-
-import org.osgi.annotation.versioning.ConsumerType;
-
-/**
- * A predicate that accepts a single argument and produces a boolean result.
- *
- * <p>
- * This is a functional interface and can be used as the assignment target for a
- * lambda expression or method reference.
- *
- * @param <T> The type of the predicate input.
- *
- * @ThreadSafe
- * @author $Id: 0c2c61f78bede4e2afc4278af4f5e4b873769347 $
- */
-@ConsumerType
-public interface Predicate<T> {
- /**
- * Evaluates this predicate on the specified argument.
- *
- * @param t The input to this predicate.
- * @return {@code true} if the specified argument is accepted by this
- * predicate; {@code false} otherwise.
- */
- boolean test(T t);
-}
diff --git a/scr/src/main/java/org/osgi/util/function/package-info.java b/scr/src/main/java/org/osgi/util/function/package-info.java
deleted file mode 100644
index 6dcf3b8..0000000
--- a/scr/src/main/java/org/osgi/util/function/package-info.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.
- */
-
-/**
- * Function Package Version 1.0.
- *
- * <p>
- * Bundles wishing to use this package must list the package in the
- * Import-Package header of the bundle's manifest.
- *
- * <p>
- * Example import for consumers using the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.util.function; version="[1.0,2.0)"}
- * <p>
- * Example import for providers implementing the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.util.function; version="[1.0,1.1)"}
- *
- * @author $Id: 899d786b27012f55ed87b4c872a6ab2087a20a39 $
- */
-
-@Version("1.0")
-package org.osgi.util.function;
-
-import org.osgi.annotation.versioning.Version;
-
diff --git a/scr/src/main/java/org/osgi/util/promise/Deferred.java b/scr/src/main/java/org/osgi/util/promise/Deferred.java
deleted file mode 100644
index 29efdeb..0000000
--- a/scr/src/main/java/org/osgi/util/promise/Deferred.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.promise;
-
-import static org.osgi.util.promise.PromiseImpl.requireNonNull;
-
-/**
- * A Deferred Promise resolution.
- *
- * <p>
- * Instances of this class can be used to create a {@link Promise} that can be
- * resolved in the future. The {@link #getPromise() associated} Promise can be
- * successfully resolved with {@link #resolve(Object)} or resolved with a
- * failure with {@link #fail(Throwable)}. It can also be resolved with the
- * resolution of another promise using {@link #resolveWith(Promise)}.
- *
- * <p>
- * The associated Promise can be provided to any one, but the Deferred object
- * should be made available only to the party that will responsible for
- * resolving the Promise.
- *
- * @param <T> The value type associated with the created Promise.
- *
- * @Immutable
- * @author $Id: b12288b7edc994f615dc1305d6aeaeeb56208df7 $
- */
-public class Deferred<T> {
- private final PromiseImpl<T> promise;
-
- /**
- * Create a new Deferred with an associated Promise.
- */
- public Deferred() {
- promise = new PromiseImpl<T>();
- }
-
- /**
- * Returns the Promise associated with this Deferred.
- *
- * @return The Promise associated with this Deferred.
- */
- public Promise<T> getPromise() {
- return promise;
- }
-
- /**
- * Successfully resolve the Promise associated with this Deferred.
- *
- * <p>
- * After the associated Promise is resolved with the specified value, all
- * registered {@link Promise#onResolve(Runnable) callbacks} are called and
- * any {@link Promise#then(Success, Failure) chained} Promises are resolved.
- *
- * <p>
- * Resolving the associated Promise <i>happens-before</i> any registered
- * callback is called. That is, in a registered callback,
- * {@link Promise#isDone()} must return {@code true} and
- * {@link Promise#getValue()} and {@link Promise#getFailure()} must not
- * block.
- *
- * @param value The value of the resolved Promise.
- * @throws IllegalStateException If the associated Promise was already
- * resolved.
- */
- public void resolve(T value) {
- promise.resolve(value, null);
- }
-
- /**
- * Fail the Promise associated with this Deferred.
- *
- * <p>
- * After the associated Promise is resolved with the specified failure, all
- * registered {@link Promise#onResolve(Runnable) callbacks} are called and
- * any {@link Promise#then(Success, Failure) chained} Promises are resolved.
- *
- * <p>
- * Resolving the associated Promise <i>happens-before</i> any registered
- * callback is called. That is, in a registered callback,
- * {@link Promise#isDone()} must return {@code true} and
- * {@link Promise#getValue()} and {@link Promise#getFailure()} must not
- * block.
- *
- * @param failure The failure of the resolved Promise. Must not be
- * {@code null}.
- * @throws IllegalStateException If the associated Promise was already
- * resolved.
- */
- public void fail(Throwable failure) {
- promise.resolve(null, requireNonNull(failure));
- }
-
- /**
- * Resolve the Promise associated with this Deferred with the specified
- * Promise.
- *
- * <p>
- * If the specified Promise is successfully resolved, the associated Promise
- * is resolved with the value of the specified Promise. If the specified
- * Promise is resolved with a failure, the associated Promise is resolved
- * with the failure of the specified Promise.
- *
- * <p>
- * After the associated Promise is resolved with the specified Promise, all
- * registered {@link Promise#onResolve(Runnable) callbacks} are called and
- * any {@link Promise#then(Success, Failure) chained} Promises are resolved.
- *
- * <p>
- * Resolving the associated Promise <i>happens-before</i> any registered
- * callback is called. That is, in a registered callback,
- * {@link Promise#isDone()} must return {@code true} and
- * {@link Promise#getValue()} and {@link Promise#getFailure()} must not
- * block.
- *
- * @param with A Promise whose value or failure will be used to resolve the
- * associated Promise. Must not be {@code null}.
- * @return A Promise that is resolved only when the associated Promise is
- * resolved by the specified Promise. The returned Promise will be
- * successfully resolved, with the value {@code null}, if the
- * associated Promise was resolved by the specified Promise. The
- * returned Promise will be resolved with a failure of
- * {@link IllegalStateException} if the associated Promise was
- * already resolved when the specified Promise was resolved.
- */
- public Promise<Void> resolveWith(Promise<? extends T> with) {
- return promise.resolveWith(with);
- }
-}
diff --git a/scr/src/main/java/org/osgi/util/promise/FailedPromisesException.java b/scr/src/main/java/org/osgi/util/promise/FailedPromisesException.java
deleted file mode 100644
index 6d9c472..0000000
--- a/scr/src/main/java/org/osgi/util/promise/FailedPromisesException.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.promise;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * Promise failure exception for a collection of failed Promises.
- *
- * @author $Id: 95546abe53fcca0c3daa3d2847a915fe94b9cef8 $
- */
-public class FailedPromisesException extends RuntimeException {
- private static final long serialVersionUID = 1L;
- private final Collection<Promise<?>> failed;
-
- /**
- * Create a new FailedPromisesException with the specified Promises.
- *
- * @param failed A collection of Promises that have been resolved with a
- * failure. Must not be {@code null}, must not be empty and all of
- * the elements in the collection must not be {@code null}.
- * @param cause The cause of this exception. This is typically the failure
- * of the first Promise in the specified collection.
- */
- public FailedPromisesException(Collection<Promise<?>> failed, Throwable cause) {
- super(cause);
- this.failed = Collections.unmodifiableCollection(failed);
- }
-
- /**
- * Returns the collection of Promises that have been resolved with a
- * failure.
- *
- * @return The collection of Promises that have been resolved with a
- * failure. The returned collection is unmodifiable.
- */
- public Collection<Promise<?>> getFailedPromises() {
- return failed;
- }
-}
diff --git a/scr/src/main/java/org/osgi/util/promise/Failure.java b/scr/src/main/java/org/osgi/util/promise/Failure.java
deleted file mode 100644
index ab93794..0000000
--- a/scr/src/main/java/org/osgi/util/promise/Failure.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.promise;
-
-import org.osgi.annotation.versioning.ConsumerType;
-
-/**
- * Failure callback for a Promise.
- *
- * <p>
- * A Failure callback is registered with a {@link Promise} using the
- * {@link Promise#then(Success, Failure)} method and is called if the Promise is
- * resolved with a failure.
- *
- * <p>
- * This is a functional interface and can be used as the assignment target for a
- * lambda expression or method reference.
- *
- * @ThreadSafe
- * @author $Id: a4bd1ef9948a4abb9fc01a140bd9562be0beb9aa $
- */
-@ConsumerType
-public interface Failure {
- /**
- * Failure callback for a Promise.
- *
- * <p>
- * This method is called if the Promise with which it is registered resolves
- * with a failure.
- *
- * <p>
- * In the remainder of this description we will refer to the Promise
- * returned by {@link Promise#then(Success, Failure)} when this Failure
- * callback was registered as the chained Promise.
- *
- * <p>
- * If this methods completes normally, the chained Promise will be failed
- * with the same exception which failed the resolved Promise. If this method
- * throws an exception, the chained Promise will be failed with the thrown
- * exception.
- *
- * @param resolved The failed resolved {@link Promise}.
- * @throws Exception The chained Promise will be failed with the thrown
- * exception.
- */
- void fail(Promise<?> resolved) throws Exception;
-}
diff --git a/scr/src/main/java/org/osgi/util/promise/Promise.java b/scr/src/main/java/org/osgi/util/promise/Promise.java
deleted file mode 100644
index 74e4b59..0000000
--- a/scr/src/main/java/org/osgi/util/promise/Promise.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.promise;
-
-import java.lang.reflect.InvocationTargetException;
-import org.osgi.annotation.versioning.ProviderType;
-import org.osgi.util.function.Function;
-import org.osgi.util.function.Predicate;
-
-/**
- * A Promise of a value.
- *
- * <p>
- * A Promise represents a future value. It handles the interactions for
- * asynchronous processing. A {@link Deferred} object can be used to create a
- * Promise and later resolve the Promise. A Promise is used by the caller of an
- * asynchronous function to get the result or handle the error. The caller can
- * either get a callback when the Promise is resolved with a value or an error,
- * or the Promise can be used in chaining. In chaining, callbacks are provided
- * that receive the resolved Promise, and a new Promise is generated that
- * resolves based upon the result of a callback.
- *
- * <p>
- * Both {@link #onResolve(Runnable) callbacks} and
- * {@link #then(Success, Failure) chaining} can be repeated any number of times,
- * even after the Promise has been resolved.
- * <p>
- * Example callback usage:
- *
- * <pre>
- * final Promise<String> foo = foo();
- * foo.onResolve(new Runnable() {
- * public void run() {
- * System.out.println(foo.getValue());
- * }
- * });
- * </pre>
- *
- * Example chaining usage;
- *
- * <pre>
- * Success<String,String> doubler = new Success<String,String>() {
- * public Promise<String> call(Promise<String> p) throws Exception {
- * return Promises.resolved(p.getValue()+p.getValue());
- * }
- * };
- * final Promise<String> foo = foo().then(doubler).then(doubler);
- * foo.onResolve(new Runnable() {
- * public void run() {
- * System.out.println(foo.getValue());
- * }
- * });
- * </pre>
- *
- * @param <T> The value type associated with this Promise.
- *
- * @ThreadSafe
- * @author $Id: 8a24f66339967ecdd03def57f31ac8c371a7f4cd $
- */
-@ProviderType
-public interface Promise<T> {
-
- /**
- * Returns whether this Promise has been resolved.
- *
- * <p>
- * This Promise may be successfully resolved or resolved with a failure.
- *
- * @return {@code true} if this Promise was resolved either successfully or
- * with a failure; {@code false} if this Promise is unresolved.
- */
- boolean isDone();
-
- /**
- * Returns the value of this Promise.
- *
- * <p>
- * If this Promise is not {@link #isDone() resolved}, this method must block
- * and wait for this Promise to be resolved before completing.
- *
- * <p>
- * If this Promise was successfully resolved, this method returns with the
- * value of this Promise. If this Promise was resolved with a failure, this
- * method must throw an {@code InvocationTargetException} with the
- * {@link #getFailure() failure exception} as the cause.
- *
- * @return The value of this resolved Promise.
- * @throws InvocationTargetException If this Promise was resolved with a
- * failure. The cause of the {@code InvocationTargetException} is
- * the failure exception.
- * @throws InterruptedException If the current thread was interrupted while
- * waiting.
- */
- T getValue() throws InvocationTargetException, InterruptedException;
-
- /**
- * Returns the failure of this Promise.
- *
- * <p>
- * If this Promise is not {@link #isDone() resolved}, this method must block
- * and wait for this Promise to be resolved before completing.
- *
- * <p>
- * If this Promise was resolved with a failure, this method returns with the
- * failure of this Promise. If this Promise was successfully resolved, this
- * method must return {@code null}.
- *
- * @return The failure of this resolved Promise or {@code null} if this
- * Promise was successfully resolved.
- * @throws InterruptedException If the current thread was interrupted while
- * waiting.
- */
- Throwable getFailure() throws InterruptedException;
-
- /**
- * Register a callback to be called when this Promise is resolved.
- *
- * <p>
- * The specified callback is called when this Promise is resolved either
- * successfully or with a failure.
- *
- * <p>
- * This method may be called at any time including before and after this
- * Promise has been resolved.
- *
- * <p>
- * Resolving this Promise <i>happens-before</i> any registered callback is
- * called. That is, in a registered callback, {@link #isDone()} must return
- * {@code true} and {@link #getValue()} and {@link #getFailure()} must not
- * block.
- *
- * <p>
- * A callback may be called on a different thread than the thread which
- * registered the callback. So the callback must be thread safe but can rely
- * upon that the registration of the callback <i>happens-before</i> the
- * registered callback is called.
- *
- * @param callback A callback to be called when this Promise is resolved.
- * Must not be {@code null}.
- * @return This Promise.
- */
- Promise<T> onResolve(Runnable callback);
-
- /**
- * Chain a new Promise to this Promise with Success and Failure callbacks.
- *
- * <p>
- * The specified {@link Success} callback is called when this Promise is
- * successfully resolved and the specified {@link Failure} callback is
- * called when this Promise is resolved with a failure.
- *
- * <p>
- * This method returns a new Promise which is chained to this Promise. The
- * returned Promise must be resolved when this Promise is resolved after the
- * specified Success or Failure callback is executed. The result of the
- * executed callback must be used to resolve the returned Promise. Multiple
- * calls to this method can be used to create a chain of promises which are
- * resolved in sequence.
- *
- * <p>
- * If this Promise is successfully resolved, the Success callback is
- * executed and the result Promise, if any, or thrown exception is used to
- * resolve the returned Promise from this method. If this Promise is
- * resolved with a failure, the Failure callback is executed and the
- * returned Promise from this method is failed.
- *
- * <p>
- * This method may be called at any time including before and after this
- * Promise has been resolved.
- *
- * <p>
- * Resolving this Promise <i>happens-before</i> any registered callback is
- * called. That is, in a registered callback, {@link #isDone()} must return
- * {@code true} and {@link #getValue()} and {@link #getFailure()} must not
- * block.
- *
- * <p>
- * A callback may be called on a different thread than the thread which
- * registered the callback. So the callback must be thread safe but can rely
- * upon that the registration of the callback <i>happens-before</i> the
- * registered callback is called.
- *
- * @param <R> The value type associated with the returned Promise.
- * @param success A Success callback to be called when this Promise is
- * successfully resolved. May be {@code null} if no Success callback
- * is required. In this case, the returned Promise must be resolved
- * with the value {@code null} when this Promise is successfully
- * resolved.
- * @param failure A Failure callback to be called when this Promise is
- * resolved with a failure. May be {@code null} if no Failure
- * callback is required.
- * @return A new Promise which is chained to this Promise. The returned
- * Promise must be resolved when this Promise is resolved after the
- * specified Success or Failure callback, if any, is executed.
- */
- <R> Promise<R> then(Success<? super T, ? extends R> success, Failure failure);
-
- /**
- * Chain a new Promise to this Promise with a Success callback.
- *
- * <p>
- * This method performs the same function as calling
- * {@link #then(Success, Failure)} with the specified Success callback and
- * {@code null} for the Failure callback.
- *
- * @param <R> The value type associated with the returned Promise.
- * @param success A Success callback to be called when this Promise is
- * successfully resolved. May be {@code null} if no Success callback
- * is required. In this case, the returned Promise must be resolved
- * with the value {@code null} when this Promise is successfully
- * resolved.
- * @return A new Promise which is chained to this Promise. The returned
- * Promise must be resolved when this Promise is resolved after the
- * specified Success, if any, is executed.
- * @see #then(Success, Failure)
- */
- <R> Promise<R> then(Success<? super T, ? extends R> success);
-
- /**
- * Filter the value of this Promise.
- *
- * <p>
- * If this Promise is successfully resolved, the returned Promise will
- * either be resolved with the value of this Promise if the specified
- * Predicate accepts that value or failed with a
- * {@code NoSuchElementException} if the specified Predicate does not accept
- * that value. If the specified Predicate throws an exception, the returned
- * Promise will be failed with the exception.
- *
- * <p>
- * If this Promise is resolved with a failure, the returned Promise will be
- * failed with that failure.
- *
- * <p>
- * This method may be called at any time including before and after this
- * Promise has been resolved.
- *
- * @param predicate The Predicate to evaluate the value of this Promise.
- * Must not be {@code null}.
- * @return A Promise that filters the value of this Promise.
- */
- Promise<T> filter(Predicate<? super T> predicate);
-
- /**
- * Map the value of this Promise.
- *
- * <p>
- * If this Promise is successfully resolved, the returned Promise will be
- * resolved with the value of specified Function as applied to the value of
- * this Promise. If the specified Function throws an exception, the returned
- * Promise will be failed with the exception.
- *
- * <p>
- * If this Promise is resolved with a failure, the returned Promise will be
- * failed with that failure.
- *
- * <p>
- * This method may be called at any time including before and after this
- * Promise has been resolved.
- *
- * @param <R> The value type associated with the returned Promise.
- * @param mapper The Function that will map the value of this Promise to the
- * value that will be used to resolve the returned Promise. Must not
- * be {@code null}.
- * @return A Promise that returns the value of this Promise as mapped by the
- * specified Function.
- */
- <R> Promise<R> map(Function<? super T, ? extends R> mapper);
-
- /**
- * FlatMap the value of this Promise.
- *
- * <p>
- * If this Promise is successfully resolved, the returned Promise will be
- * resolved with the Promise from the specified Function as applied to the
- * value of this Promise. If the specified Function throws an exception, the
- * returned Promise will be failed with the exception.
- *
- * <p>
- * If this Promise is resolved with a failure, the returned Promise will be
- * failed with that failure.
- *
- * <p>
- * This method may be called at any time including before and after this
- * Promise has been resolved.
- *
- * @param <R> The value type associated with the returned Promise.
- * @param mapper The Function that will flatMap the value of this Promise to
- * a Promise that will be used to resolve the returned Promise. Must
- * not be {@code null}.
- * @return A Promise that returns the value of this Promise as mapped by the
- * specified Function.
- */
- <R> Promise<R> flatMap(Function<? super T, Promise<? extends R>> mapper);
-
- /**
- * Recover from a failure of this Promise with a recovery value.
- *
- * <p>
- * If this Promise is successfully resolved, the returned Promise will be
- * resolved with the value of this Promise.
- *
- * <p>
- * If this Promise is resolved with a failure, the specified Function is
- * applied to this Promise to produce a recovery value.
- * <ul>
- * <li>If the recovery value is not {@code null}, the returned Promise will
- * be resolved with the recovery value.</li>
- * <li>If the recovery value is {@code null}, the returned Promise will be
- * failed with the failure of this Promise.</li>
- * <li>If the specified Function throws an exception, the returned Promise
- * will be failed with that exception.</li>
- * </ul>
- *
- * <p>
- * To recover from a failure of this Promise with a recovery value of
- * {@code null}, the {@link #recoverWith(Function)} method must be used. The
- * specified Function for {@link #recoverWith(Function)} can return
- * {@code Promises.resolved(null)} to supply the desired {@code null} value.
- *
- * <p>
- * This method may be called at any time including before and after this
- * Promise has been resolved.
- *
- * @param recovery If this Promise resolves with a failure, the specified
- * Function is called to produce a recovery value to be used to
- * resolve the returned Promise. Must not be {@code null}.
- * @return A Promise that resolves with the value of this Promise or
- * recovers from the failure of this Promise.
- */
- Promise<T> recover(Function<Promise<?>, ? extends T> recovery);
-
- /**
- * Recover from a failure of this Promise with a recovery Promise.
- *
- * <p>
- * If this Promise is successfully resolved, the returned Promise will be
- * resolved with the value of this Promise.
- *
- * <p>
- * If this Promise is resolved with a failure, the specified Function is
- * applied to this Promise to produce a recovery Promise.
- * <ul>
- * <li>If the recovery Promise is not {@code null}, the returned Promise
- * will be resolved with the recovery Promise.</li>
- * <li>If the recovery Promise is {@code null}, the returned Promise will be
- * failed with the failure of this Promise.</li>
- * <li>If the specified Function throws an exception, the returned Promise
- * will be failed with that exception.</li>
- * </ul>
- *
- * <p>
- * This method may be called at any time including before and after this
- * Promise has been resolved.
- *
- * @param recovery If this Promise resolves with a failure, the specified
- * Function is called to produce a recovery Promise to be used to
- * resolve the returned Promise. Must not be {@code null}.
- * @return A Promise that resolves with the value of this Promise or
- * recovers from the failure of this Promise.
- */
- Promise<T> recoverWith(Function<Promise<?>, Promise<? extends T>> recovery);
-
- /**
- * Fall back to the value of the specified Promise if this Promise fails.
- *
- * <p>
- * If this Promise is successfully resolved, the returned Promise will be
- * resolved with the value of this Promise.
- *
- * <p>
- * If this Promise is resolved with a failure, the successful result of the
- * specified Promise is used to resolve the returned Promise. If the
- * specified Promise is resolved with a failure, the returned Promise will
- * be failed with the failure of this Promise rather than the failure of the
- * specified Promise.
- *
- * <p>
- * This method may be called at any time including before and after this
- * Promise has been resolved.
- *
- * @param fallback The Promise whose value will be used to resolve the
- * returned Promise if this Promise resolves with a failure. Must not
- * be {@code null}.
- * @return A Promise that returns the value of this Promise or falls back to
- * the value of the specified Promise.
- */
- Promise<T> fallbackTo(Promise<? extends T> fallback);
-}
diff --git a/scr/src/main/java/org/osgi/util/promise/PromiseImpl.java b/scr/src/main/java/org/osgi/util/promise/PromiseImpl.java
deleted file mode 100644
index 1b01472..0000000
--- a/scr/src/main/java/org/osgi/util/promise/PromiseImpl.java
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.promise;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.NoSuchElementException;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CountDownLatch;
-import org.osgi.util.function.Function;
-import org.osgi.util.function.Predicate;
-
-/**
- * Promise implementation.
- *
- * <p>
- * This class is not used directly by clients. Clients should use
- * {@link Deferred} to create a resolvable {@link Promise}.
- *
- * @param <T> The result type associated with the Promise.
- *
- * @ThreadSafe
- * @author $Id: d8b44a36f3eb797316b213118192fac213fa0c59 $
- */
-final class PromiseImpl<T> implements Promise<T> {
- /**
- * A ConcurrentLinkedQueue to hold the callbacks for this Promise, so no
- * additional synchronization is required to write to or read from the
- * queue.
- */
- private final ConcurrentLinkedQueue<Runnable> callbacks;
- /**
- * A CountDownLatch to manage the resolved state of this Promise.
- *
- * <p>
- * This object is used as the synchronizing object to provide a critical
- * section in {@link #resolve(Object, Throwable)} so that only a single
- * thread can write the resolved state variables and open the latch.
- *
- * <p>
- * The resolved state variables, {@link #value} and {@link #fail}, must only
- * be written when the latch is closed (getCount() != 0) and must only be
- * read when the latch is open (getCount() == 0). The latch state must
- * always be checked before writing or reading since the resolved state
- * variables' memory consistency is guarded by the latch.
- */
- private final CountDownLatch resolved;
- /**
- * The value of this Promise if successfully resolved.
- *
- * @GuardedBy("resolved")
- * @see #resolved
- */
- private T value;
- /**
- * The failure of this Promise if resolved with a failure or {@code null} if
- * successfully resolved.
- *
- * @GuardedBy("resolved")
- * @see #resolved
- */
- private Throwable fail;
-
- /**
- * Initialize this Promise.
- */
- PromiseImpl() {
- callbacks = new ConcurrentLinkedQueue<Runnable>();
- resolved = new CountDownLatch(1);
- }
-
- /**
- * Initialize and resolve this Promise.
- *
- * @param v The value of this resolved Promise.
- * @param f The failure of this resolved Promise.
- */
- PromiseImpl(T v, Throwable f) {
- value = v;
- fail = f;
- callbacks = new ConcurrentLinkedQueue<Runnable>();
- resolved = new CountDownLatch(0);
- }
-
- /**
- * Resolve this Promise.
- *
- * @param v The value of this Promise.
- * @param f The failure of this Promise.
- */
- void resolve(T v, Throwable f) {
- // critical section: only one resolver at a time
- synchronized (resolved) {
- if (resolved.getCount() == 0) {
- throw new IllegalStateException("Already resolved");
- }
- /*
- * The resolved state variables must be set before opening the
- * latch. This safely publishes them to be read by other threads
- * that must verify the latch is open before reading.
- */
- value = v;
- fail = f;
- resolved.countDown();
- }
- notifyCallbacks(); // call any registered callbacks
- }
-
- /**
- * Call any registered callbacks if this Promise is resolved.
- */
- private void notifyCallbacks() {
- if (resolved.getCount() != 0) {
- return; // return if not resolved
- }
-
- /*
- * Note: multiple threads can be in this method removing callbacks from
- * the queue and calling them, so the order in which callbacks are
- * called cannot be specified.
- */
- for (Runnable callback = callbacks.poll(); callback != null; callback = callbacks.poll()) {
- try {
- callback.run();
- } catch (Throwable t) {
- Logger.logCallbackException(t);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDone() {
- return resolved.getCount() == 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public T getValue() throws InvocationTargetException, InterruptedException {
- resolved.await();
- if (fail == null) {
- return value;
- }
- throw new InvocationTargetException(fail);
- }
-
- /**
- * {@inheritDoc}
- */
- public Throwable getFailure() throws InterruptedException {
- resolved.await();
- return fail;
- }
-
- /**
- * {@inheritDoc}
- */
- public Promise<T> onResolve(Runnable callback) {
- callbacks.offer(callback);
- notifyCallbacks(); // call any registered callbacks
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- public <R> Promise<R> then(Success<? super T, ? extends R> success, Failure failure) {
- PromiseImpl<R> chained = new PromiseImpl<R>();
- onResolve(new Then<R>(chained, success, failure));
- return chained;
- }
-
- /**
- * {@inheritDoc}
- */
- public <R> Promise<R> then(Success<? super T, ? extends R> success) {
- return then(success, null);
- }
-
- /**
- * A callback used to chain promises for the {@link #then(Success, Failure)}
- * method.
- *
- * @Immutable
- */
- private final class Then<R> implements Runnable {
- private final PromiseImpl<R> chained;
- private final Success<T, ? extends R> success;
- private final Failure failure;
-
- @SuppressWarnings("unchecked")
- Then(PromiseImpl<R> chained, Success<? super T, ? extends R> success, Failure failure) {
- this.chained = chained;
- this.success = (Success<T, ? extends R>) success;
- this.failure = failure;
- }
-
- public void run() {
- Throwable f;
- final boolean interrupted = Thread.interrupted();
- try {
- f = getFailure();
- } catch (Throwable e) {
- f = e; // propagate new exception
- } finally {
- if (interrupted) { // restore interrupt status
- Thread.currentThread().interrupt();
- }
- }
- if (f != null) {
- if (failure != null) {
- try {
- failure.fail(PromiseImpl.this);
- } catch (Throwable e) {
- f = e; // propagate new exception
- }
- }
- // fail chained
- chained.resolve(null, f);
- return;
- }
- Promise<? extends R> returned = null;
- if (success != null) {
- try {
- returned = success.call(PromiseImpl.this);
- } catch (Throwable e) {
- chained.resolve(null, e);
- return;
- }
- }
- if (returned == null) {
- // resolve chained with null value
- chained.resolve(null, null);
- } else {
- // resolve chained when returned promise is resolved
- returned.onResolve(new Chain<R>(chained, returned));
- }
- }
- }
-
- /**
- * A callback used to resolve the chained Promise when the Promise promise
- * is resolved.
- *
- * @Immutable
- */
- private final static class Chain<R> implements Runnable {
- private final PromiseImpl<R> chained;
- private final Promise<? extends R> promise;
- private final Throwable failure;
-
- Chain(PromiseImpl<R> chained, Promise<? extends R> promise) {
- this.chained = chained;
- this.promise = promise;
- this.failure = null;
- }
-
- Chain(PromiseImpl<R> chained, Promise<? extends R> promise, Throwable failure) {
- this.chained = chained;
- this.promise = promise;
- this.failure = failure;
- }
-
- public void run() {
- R value = null;
- Throwable f;
- final boolean interrupted = Thread.interrupted();
- try {
- f = promise.getFailure();
- if (f == null) {
- value = promise.getValue();
- } else if (failure != null) {
- f = failure;
- }
- } catch (Throwable e) {
- f = e; // propagate new exception
- } finally {
- if (interrupted) { // restore interrupt status
- Thread.currentThread().interrupt();
- }
- }
- chained.resolve(value, f);
- }
- }
-
- /**
- * Resolve this Promise with the specified Promise.
- *
- * <p>
- * If the specified Promise is successfully resolved, this Promise is
- * resolved with the value of the specified Promise. If the specified
- * Promise is resolved with a failure, this Promise is resolved with the
- * failure of the specified Promise.
- *
- * @param with A Promise whose value or failure will be used to resolve this
- * Promise. Must not be {@code null}.
- * @return A Promise that is resolved only when this Promise is resolved by
- * the specified Promise. The returned Promise will be successfully
- * resolved, with the value {@code null}, if this Promise was
- * resolved by the specified Promise. The returned Promise will be
- * resolved with a failure of {@link IllegalStateException} if this
- * Promise was already resolved when the specified Promise was
- * resolved.
- */
- Promise<Void> resolveWith(Promise<? extends T> with) {
- PromiseImpl<Void> chained = new PromiseImpl<Void>();
- ResolveWith resolveWith = new ResolveWith(chained);
- with.then(resolveWith, resolveWith);
- return chained;
- }
-
- /**
- * A callback used to resolve this Promise with another Promise for the
- * {@link PromiseImpl#resolveWith(Promise)} method.
- *
- * @Immutable
- */
- private final class ResolveWith implements Success<T, Void>, Failure {
- private final PromiseImpl<Void> chained;
-
- ResolveWith(PromiseImpl<Void> chained) {
- this.chained = chained;
- }
-
- public Promise<Void> call(Promise<T> with) throws Exception {
- try {
- resolve(with.getValue(), null);
- } catch (Throwable e) {
- chained.resolve(null, e);
- return null;
- }
- chained.resolve(null, null);
- return null;
- }
-
- public void fail(Promise<?> with) throws Exception {
- try {
- resolve(null, with.getFailure());
- } catch (Throwable e) {
- chained.resolve(null, e);
- return;
- }
- chained.resolve(null, null);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Promise<T> filter(Predicate<? super T> predicate) {
- return then(new Filter<T>(predicate));
- }
-
- /**
- * A callback used by the {@link PromiseImpl#filter(Predicate)} method.
- *
- * @Immutable
- */
- private static final class Filter<T> implements Success<T, T> {
- private final Predicate<? super T> predicate;
-
- Filter(Predicate<? super T> predicate) {
- this.predicate = requireNonNull(predicate);
- }
-
- public Promise<T> call(Promise<T> resolved) throws Exception {
- if (predicate.test(resolved.getValue())) {
- return resolved;
- }
- throw new NoSuchElementException();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public <R> Promise<R> map(Function<? super T, ? extends R> mapper) {
- return then(new Map<T, R>(mapper));
- }
-
- /**
- * A callback used by the {@link PromiseImpl#map(Function)} method.
- *
- * @Immutable
- */
- private static final class Map<T, R> implements Success<T, R> {
- private final Function<? super T, ? extends R> mapper;
-
- Map(Function<? super T, ? extends R> mapper) {
- this.mapper = requireNonNull(mapper);
- }
-
- public Promise<R> call(Promise<T> resolved) throws Exception {
- return new PromiseImpl<R>(mapper.apply(resolved.getValue()), null);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public <R> Promise<R> flatMap(Function<? super T, Promise<? extends R>> mapper) {
- return then(new FlatMap<T, R>(mapper));
- }
-
- /**
- * A callback used by the {@link PromiseImpl#flatMap(Function)} method.
- *
- * @Immutable
- */
- private static final class FlatMap<T, R> implements Success<T, R> {
- private final Function<? super T, Promise<? extends R>> mapper;
-
- FlatMap(Function<? super T, Promise<? extends R>> mapper) {
- this.mapper = requireNonNull(mapper);
- }
-
- @SuppressWarnings("unchecked")
- public Promise<R> call(Promise<T> resolved) throws Exception {
- return (Promise<R>) mapper.apply(resolved.getValue());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Promise<T> recover(Function<Promise<?>, ? extends T> recovery) {
- PromiseImpl<T> chained = new PromiseImpl<T>();
- Recover<T> recover = new Recover<T>(chained, recovery);
- then(recover, recover);
- return chained;
- }
-
- /**
- * A callback used by the {@link PromiseImpl#recover(Function)} method.
- *
- * @Immutable
- */
- private static final class Recover<T> implements Success<T, Void>, Failure {
- private final PromiseImpl<T> chained;
- private final Function<Promise<?>, ? extends T> recovery;
-
- Recover(PromiseImpl<T> chained, Function<Promise<?>, ? extends T> recovery) {
- this.chained = chained;
- this.recovery = requireNonNull(recovery);
- }
-
- public Promise<Void> call(Promise<T> resolved) throws Exception {
- T value;
- try {
- value = resolved.getValue();
- } catch (Throwable e) {
- chained.resolve(null, e);
- return null;
- }
- chained.resolve(value, null);
- return null;
- }
-
- public void fail(Promise<?> resolved) throws Exception {
- T recovered;
- Throwable failure;
- try {
- recovered = recovery.apply(resolved);
- failure = resolved.getFailure();
- } catch (Throwable e) {
- chained.resolve(null, e);
- return;
- }
- if (recovered == null) {
- chained.resolve(null, failure);
- } else {
- chained.resolve(recovered, null);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Promise<T> recoverWith(Function<Promise<?>, Promise<? extends T>> recovery) {
- PromiseImpl<T> chained = new PromiseImpl<T>();
- RecoverWith<T> recoverWith = new RecoverWith<T>(chained, recovery);
- then(recoverWith, recoverWith);
- return chained;
- }
-
- /**
- * A callback used by the {@link PromiseImpl#recoverWith(Function)} method.
- *
- * @Immutable
- */
- private static final class RecoverWith<T> implements Success<T, Void>, Failure {
- private final PromiseImpl<T> chained;
- private final Function<Promise<?>, Promise<? extends T>> recovery;
-
- RecoverWith(PromiseImpl<T> chained, Function<Promise<?>, Promise<? extends T>> recovery) {
- this.chained = chained;
- this.recovery = requireNonNull(recovery);
- }
-
- public Promise<Void> call(Promise<T> resolved) throws Exception {
- T value;
- try {
- value = resolved.getValue();
- } catch (Throwable e) {
- chained.resolve(null, e);
- return null;
- }
- chained.resolve(value, null);
- return null;
- }
-
- public void fail(Promise<?> resolved) throws Exception {
- Promise<? extends T> recovered;
- Throwable failure;
- try {
- recovered = recovery.apply(resolved);
- failure = resolved.getFailure();
- } catch (Throwable e) {
- chained.resolve(null, e);
- return;
- }
- if (recovered == null) {
- chained.resolve(null, failure);
- } else {
- recovered.onResolve(new Chain<T>(chained, recovered));
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Promise<T> fallbackTo(Promise<? extends T> fallback) {
- PromiseImpl<T> chained = new PromiseImpl<T>();
- FallbackTo<T> fallbackTo = new FallbackTo<T>(chained, fallback);
- then(fallbackTo, fallbackTo);
- return chained;
- }
-
- /**
- * A callback used by the {@link PromiseImpl#fallbackTo(Promise)} method.
- *
- * @Immutable
- */
- private static final class FallbackTo<T> implements Success<T, Void>, Failure {
- private final PromiseImpl<T> chained;
- private final Promise<? extends T> fallback;
-
- FallbackTo(PromiseImpl<T> chained, Promise<? extends T> fallback) {
- this.chained = chained;
- this.fallback = requireNonNull(fallback);
- }
-
- public Promise<Void> call(Promise<T> resolved) throws Exception {
- T value;
- try {
- value = resolved.getValue();
- } catch (Throwable e) {
- chained.resolve(null, e);
- return null;
- }
- chained.resolve(value, null);
- return null;
- }
-
- public void fail(Promise<?> resolved) throws Exception {
- Throwable failure;
- try {
- failure = resolved.getFailure();
- } catch (Throwable e) {
- chained.resolve(null, e);
- return;
- }
- fallback.onResolve(new Chain<T>(chained, fallback, failure));
- }
- }
-
- static <V> V requireNonNull(V value) {
- if (value != null) {
- return value;
- }
- throw new NullPointerException();
- }
-
- /**
- * Use the lazy initialization holder class idiom to delay creating a Logger
- * until we actually need it.
- */
- private static final class Logger {
- private final static java.util.logging.Logger LOGGER;
- static {
- LOGGER = java.util.logging.Logger.getLogger(PromiseImpl.class.getName());
- }
-
- static void logCallbackException(Throwable t) {
- LOGGER.log(java.util.logging.Level.WARNING, "Exception from Promise callback", t);
- }
- }
-}
diff --git a/scr/src/main/java/org/osgi/util/promise/Promises.java b/scr/src/main/java/org/osgi/util/promise/Promises.java
deleted file mode 100644
index 4be25c0..0000000
--- a/scr/src/main/java/org/osgi/util/promise/Promises.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.promise;
-
-import static org.osgi.util.promise.PromiseImpl.requireNonNull;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Static helper methods for {@link Promise}s.
- *
- * @ThreadSafe
- * @author $Id: 6ad9c7cca5a98dbddd87db8417df51bf6e008922 $
- */
-public class Promises {
- private Promises() {
- // disallow object creation
- }
-
- /**
- * Create a new Promise that has been resolved with the specified value.
- *
- * @param <T> The value type associated with the returned Promise.
- * @param value The value of the resolved Promise.
- * @return A new Promise that has been resolved with the specified value.
- */
- public static <T> Promise<T> resolved(T value) {
- return new PromiseImpl<T>(value, null);
- }
-
- /**
- * Create a new Promise that has been resolved with the specified failure.
- *
- * @param <T> The value type associated with the returned Promise.
- * @param failure The failure of the resolved Promise. Must not be
- * {@code null}.
- * @return A new Promise that has been resolved with the specified failure.
- */
- public static <T> Promise<T> failed(Throwable failure) {
- return new PromiseImpl<T>(null, requireNonNull(failure));
- }
-
- /**
- * Create a new Promise that is a latch on the resolution of the specified
- * Promises.
- *
- * <p>
- * The new Promise acts as a gate and must be resolved after all of the
- * specified Promises are resolved.
- *
- * @param <T> The value type of the List value associated with the returned
- * Promise.
- * @param <S> A subtype of the value type of the List value associated with
- * the returned Promise.
- * @param promises The Promises which must be resolved before the returned
- * Promise must be resolved. Must not be {@code null} and all of the
- * elements in the collection must not be {@code null}.
- * @return A Promise that is resolved only when all the specified Promises
- * are resolved. The returned Promise will be successfully resolved,
- * with a List of the values in the order of the specified Promises,
- * if all the specified Promises are successfully resolved. The List
- * in the returned Promise is the property of the caller and is
- * modifiable. The returned Promise will be resolved with a failure
- * of {@link FailedPromisesException} if any of the specified
- * Promises are resolved with a failure. The failure
- * {@link FailedPromisesException} must contain all of the specified
- * Promises which resolved with a failure.
- */
- public static <T, S extends T> Promise<List<T>> all(Collection<Promise<S>> promises) {
- if (promises.isEmpty()) {
- List<T> result = new ArrayList<T>();
- return resolved(result);
- }
- /* make a copy and capture the ordering */
- List<Promise<? extends T>> list = new ArrayList<Promise<? extends T>>(promises);
- PromiseImpl<List<T>> chained = new PromiseImpl<List<T>>();
- All<T> all = new All<T>(chained, list);
- for (Promise<? extends T> promise : list) {
- promise.onResolve(all);
- }
- return chained;
- }
-
- /**
- * Create a new Promise that is a latch on the resolution of the specified
- * Promises.
- *
- * <p>
- * The new Promise acts as a gate and must be resolved after all of the
- * specified Promises are resolved.
- *
- * @param <T> The value type associated with the specified Promises.
- * @param promises The Promises which must be resolved before the returned
- * Promise must be resolved. Must not be {@code null} and all of the
- * arguments must not be {@code null}.
- * @return A Promise that is resolved only when all the specified Promises
- * are resolved. The returned Promise will be successfully resolved,
- * with a List of the values in the order of the specified Promises,
- * if all the specified Promises are successfully resolved. The List
- * in the returned Promise is the property of the caller and is
- * modifiable. The returned Promise will be resolved with a failure
- * of {@link FailedPromisesException} if any of the specified
- * Promises are resolved with a failure. The failure
- * {@link FailedPromisesException} must contain all of the specified
- * Promises which resolved with a failure.
- */
- public static <T> Promise<List<T>> all(Promise<? extends T>... promises) {
- @SuppressWarnings("unchecked")
- List<Promise<T>> list = Arrays.asList((Promise<T>[]) promises);
- return all(list);
- }
-
- /**
- * A callback used to resolve a Promise when the specified list of Promises
- * are resolved for the {@link Promises#all(Collection)} method.
- *
- * @ThreadSafe
- */
- private static final class All<T> implements Runnable {
- private final PromiseImpl<List<T>> chained;
- private final List<Promise<? extends T>> promises;
- private final AtomicInteger promiseCount;
-
- All(PromiseImpl<List<T>> chained, List<Promise<? extends T>> promises) {
- this.chained = chained;
- this.promises = promises;
- this.promiseCount = new AtomicInteger(promises.size());
- }
-
- public void run() {
- if (promiseCount.decrementAndGet() != 0) {
- return;
- }
- List<T> result = new ArrayList<T>(promises.size());
- List<Promise<?>> failed = new ArrayList<Promise<?>>(promises.size());
- Throwable cause = null;
- for (Promise<? extends T> promise : promises) {
- Throwable failure;
- T value;
- try {
- failure = promise.getFailure();
- value = (failure != null) ? null : promise.getValue();
- } catch (Throwable e) {
- chained.resolve(null, e);
- return;
- }
- if (failure != null) {
- failed.add(promise);
- if (cause == null) {
- cause = failure;
- }
- } else {
- result.add(value);
- }
- }
- if (failed.isEmpty()) {
- chained.resolve(result, null);
- } else {
- chained.resolve(null, new FailedPromisesException(failed, cause));
- }
- }
- }
-}
diff --git a/scr/src/main/java/org/osgi/util/promise/Success.java b/scr/src/main/java/org/osgi/util/promise/Success.java
deleted file mode 100644
index 7f47c4e..0000000
--- a/scr/src/main/java/org/osgi/util/promise/Success.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.util.promise;
-
-import org.osgi.annotation.versioning.ConsumerType;
-
-/**
- * Success callback for a Promise.
- *
- * <p>
- * A Success callback is registered with a {@link Promise} using the
- * {@link Promise#then(Success)} method and is called if the Promise is resolved
- * successfully.
- *
- * <p>
- * This is a functional interface and can be used as the assignment target for a
- * lambda expression or method reference.
- *
- * @param <T> The value type of the resolved Promise passed as input to this
- * callback.
- * @param <R> The value type of the returned Promise from this callback.
- *
- * @ThreadSafe
- * @author $Id: 58eef5ba732ef999d57a1feaaf1e5229356647e3 $
- */
-@ConsumerType
-public interface Success<T, R> {
- /**
- * Success callback for a Promise.
- *
- * <p>
- * This method is called if the Promise with which it is registered resolves
- * successfully.
- *
- * <p>
- * In the remainder of this description we will refer to the Promise
- * returned by this method as the returned Promise and the Promise returned
- * by {@link Promise#then(Success)} when this Success callback was
- * registered as the chained Promise.
- *
- * <p>
- * If the returned Promise is {@code null} then the chained Promise will
- * resolve immediately with a successful value of {@code null}. If the
- * returned Promise is not {@code null} then the chained Promise will be
- * resolved when the returned Promise is resolved.
- *
- * @param resolved The successfully resolved {@link Promise}.
- * @return The Promise to use to resolve the chained Promise, or
- * {@code null} if the chained Promise is to be resolved immediately
- * with the value {@code null}.
- * @throws Exception The chained Promise will be failed with the thrown
- * exception.
- */
- Promise<R> call(Promise<T> resolved) throws Exception;
-}
diff --git a/scr/src/main/java/org/osgi/util/promise/package-info.java b/scr/src/main/java/org/osgi/util/promise/package-info.java
deleted file mode 100644
index 054282c..0000000
--- a/scr/src/main/java/org/osgi/util/promise/package-info.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2014). 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.
- */
-
-/**
- * Promise Package Version 1.0.
- *
- * <p>
- * Bundles wishing to use this package must list the package in the
- * Import-Package header of the bundle's manifest.
- *
- * <p>
- * Example import for consumers using the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.util.promise; version="[1.0,2.0)"}
- * <p>
- * Example import for providers implementing the API in this package:
- * <p>
- * {@code Import-Package: org.osgi.util.promise; version="[1.0,1.1)"}
- *
- * @author $Id: 5a3ec65d3b7e7ebdd2278d75675b8a808e6cb2bf $
- */
-
-@Version("1.0")
-package org.osgi.util.promise;
-
-import org.osgi.annotation.versioning.Version;
-