You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:22:19 UTC
[sling-org-apache-sling-testing-sling-mock] 09/28: SLING-4433
remove dependency to org.apache.sling.adapter and inline helper classes
instead
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.testing.sling-mock-1.3.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git
commit a4d3ac95dbd87ff88f60e8adecb7ccd42391db77
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Sat Feb 21 09:40:05 2015 +0000
SLING-4433 remove dependency to org.apache.sling.adapter and inline helper classes instead
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/testing/mocks/sling-mock@1661311 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 6 ---
.../testing/mock/sling/MockAdapterManagerImpl.java | 63 +++++++++++++++++++++-
2 files changed, 61 insertions(+), 8 deletions(-)
diff --git a/pom.xml b/pom.xml
index 27f586f..84d3d7b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,12 +86,6 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.adapter</artifactId>
- <version>2.1.0</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.resourceresolver</artifactId>
<version>1.1.0</version>
<scope>compile</scope>
diff --git a/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java b/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
index d6f890d..271bb14 100644
--- a/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
+++ b/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
@@ -28,6 +28,7 @@ import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -38,8 +39,6 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.adapter.internal.AdapterFactoryDescriptor;
-import org.apache.sling.adapter.internal.AdapterFactoryDescriptorMap;
import org.apache.sling.api.SlingConstants;
import org.apache.sling.api.adapter.AdapterFactory;
import org.apache.sling.api.adapter.AdapterManager;
@@ -434,4 +433,64 @@ public class MockAdapterManagerImpl implements AdapterManager {
}
}
}
+
+
+ /**
+ * The <code>AdapterFactoryDescriptor</code> is an entry in the
+ * {@link AdapterFactoryDescriptorMap} conveying the list of adapter (target)
+ * types and the respective {@link AdapterFactory}.
+ */
+ private static class AdapterFactoryDescriptor {
+
+ private volatile AdapterFactory factory;
+
+ private final String[] adapters;
+
+ private final ServiceReference reference;
+
+ private final ComponentContext context;
+
+ public AdapterFactoryDescriptor(
+ final ComponentContext context,
+ final ServiceReference reference,
+ final String[] adapters) {
+ this.reference = reference;
+ this.context = context;
+ this.adapters = adapters;
+ }
+
+ public AdapterFactory getFactory() {
+ if ( factory == null ) {
+ factory = (AdapterFactory) context.locateService(
+ "AdapterFactory", reference);
+ }
+ return factory;
+ }
+
+ public String[] getAdapters() {
+ return adapters;
+ }
+ }
+
+ /**
+ * The <code>AdapterFactoryDescriptorMap</code> is a sorted map of
+ * {@link AdapterFactoryDescriptor} instances indexed (and ordered) by their
+ * {@link ServiceReference}. This map is used to organize the
+ * registered {@link org.apache.sling.api.adapter.AdapterFactory} services for
+ * a given adaptable type.
+ * <p>
+ * Each entry in the map is a {@link AdapterFactoryDescriptor} thus enabling the
+ * registration of multiple factories for the same (adaptable, adapter) type
+ * tuple. Of course only the first entry (this is the reason for having a sorted
+ * map) for such a given tuple is actually being used. If that first instance is
+ * removed the eventual second instance may actually be used instead.
+ */
+ private static class AdapterFactoryDescriptorMap extends
+ TreeMap<ServiceReference, AdapterFactoryDescriptor> {
+
+ private static final long serialVersionUID = 2L;
+
+ }
+
+
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.