This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.testing.osgi-mock-1.7.2 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git
commit 505f211ee01848e336e8ac49499cf2f1e6ab25e9 Author: Stefan Seifert <[email protected]> AuthorDate: Thu Nov 19 09:13:38 2015 +0000 SLING-5312 osgi-mock: Eliminate runtime-depenency to Felix SCR annotations git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/osgi-mock@1715131 13f79535-47bb-0310-9956-ffa450edef68 --- .../sling/testing/mock/osgi/OsgiMetadataUtil.java | 68 +++++++++++++++++++++- .../sling/testing/mock/osgi/OsgiServiceUtil.java | 4 +- .../testing/mock/osgi/OsgiMetadataUtilTest.java | 2 +- 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java b/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java index f520617..7c3db48 100644 --- a/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java +++ b/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java @@ -41,8 +41,6 @@ import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.apache.commons.lang3.StringUtils; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.ReferencePolicy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -449,4 +447,70 @@ final class OsgiMetadataUtil { } + + /** + * Options for {@link Reference#cardinality()} property. + */ + enum ReferenceCardinality { + + /** + * Optional, unary reference: No service required to be available for the + * reference to be satisfied. Only a single service is available through this + * reference. + */ + OPTIONAL_UNARY("0..1"), + + /** + * Mandatory, unary reference: At least one service must be available for + * the reference to be satisfied. Only a single service is available through + * this reference. + */ + MANDATORY_UNARY("1..1"), + + /** + * Optional, multiple reference: No service required to be available for the + * reference to be satisfied. All matching services are available through + * this reference. + */ + OPTIONAL_MULTIPLE("0..n"), + + /** + * Mandatory, multiple reference: At least one service must be available for + * the reference to be satisfied. All matching services are available + * through this reference. + */ + MANDATORY_MULTIPLE("1..n"); + + private final String cardinalityString; + + private ReferenceCardinality(final String cardinalityString) { + this.cardinalityString = cardinalityString; + } + + /** + * @return String representation of cardinality + */ + public String getCardinalityString() { + return this.cardinalityString; + } + + } + + /** + * Options for {@link Reference#policy()} property. + */ + enum ReferencePolicy { + + /** + * The component will be deactivated and re-activated if the service comes + * and/or goes away. + */ + STATIC, + + /** + * The service will be made available to the component as it comes and goes. + */ + DYNAMIC; + } + } diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java b/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java index 2c427e5..05a26bc 100644 --- a/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java +++ b/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java @@ -29,10 +29,10 @@ import java.util.SortedSet; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.ReferencePolicy; import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.OsgiMetadata; import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.Reference; +import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.ReferenceCardinality; +import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.ReferencePolicy; import org.osgi.framework.BundleContext; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; diff --git a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java index 050d951..eaf31fd 100644 --- a/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java +++ b/src/test/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtilTest.java @@ -27,9 +27,9 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.OsgiMetadata; import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.Reference; +import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.ReferenceCardinality; import org.junit.Test; import org.osgi.framework.Constants; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
