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 09:55:50 UTC

[sling-org-apache-sling-models-api] 04/07: SLING-5739 - pluggable @Via providers / SLING-6778 - supporting delegate models

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.api-1.3.4
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-api.git

commit c0f5197ae9457fbcb5df3630e001b4b2515f9ed2
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Thu Apr 20 15:06:03 2017 +0000

    SLING-5739 - pluggable @Via providers / SLING-6778 - supporting delegate models
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1792071 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/models/annotations/Via.java   | 16 ++++++++--
 .../{package-info.java => ViaProviderType.java}    |  7 +++--
 .../sling/models/annotations/package-info.java     |  2 +-
 .../{package-info.java => via/BeanProperty.java}   | 11 +++++--
 .../{package-info.java => via/ChildResource.java}  | 11 +++++--
 .../ForcedResourceType.java}                       | 11 +++++--
 .../ResourceSuperType.java}                        | 11 +++++--
 .../models/annotations/{ => via}/package-info.java |  4 +--
 .../{annotations/Via.java => spi/ViaProvider.java} | 36 ++++++++++++++--------
 9 files changed, 77 insertions(+), 32 deletions(-)

diff --git a/src/main/java/org/apache/sling/models/annotations/Via.java b/src/main/java/org/apache/sling/models/annotations/Via.java
index e8b5b07..91661aa 100644
--- a/src/main/java/org/apache/sling/models/annotations/Via.java
+++ b/src/main/java/org/apache/sling/models/annotations/Via.java
@@ -16,19 +16,29 @@
  */
 package org.apache.sling.models.annotations;
 
+import org.apache.sling.models.annotations.via.BeanProperty;
+
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * Indicate that this injection point should be handled using a projected
- * property of the adaptable.
+ * Indicate that this injection point should be handled using some value
+ * derived from the adaptable.
  */
 @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Via {
 
-    public String value();
+    /**
+     * A string value which the via provider uses to determine the correct adaptable.
+     */
+    public String value() default "";
+
+    /**
+     * The specific ViaProvider which will handle retrieval of the adaptable.
+     */
+    public Class<? extends ViaProviderType> type() default BeanProperty.class;
 
 }
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/models/annotations/package-info.java b/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java
similarity index 88%
copy from src/main/java/org/apache/sling/models/annotations/package-info.java
copy to src/main/java/org/apache/sling/models/annotations/ViaProviderType.java
index 57d589b..0abc629 100644
--- a/src/main/java/org/apache/sling/models/annotations/package-info.java
+++ b/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java
@@ -14,7 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.4.1")
 package org.apache.sling.models.annotations;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+/**
+ * Marker interface for eligible @Via provider identifiers.
+ */
+public interface ViaProviderType {
+}
diff --git a/src/main/java/org/apache/sling/models/annotations/package-info.java b/src/main/java/org/apache/sling/models/annotations/package-info.java
index 57d589b..fdb8ffe 100644
--- a/src/main/java/org/apache/sling/models/annotations/package-info.java
+++ b/src/main/java/org/apache/sling/models/annotations/package-info.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.4.1")
+@Version("1.5.0")
 package org.apache.sling.models.annotations;
 
 import aQute.bnd.annotation.Version;
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/models/annotations/package-info.java b/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java
similarity index 77%
copy from src/main/java/org/apache/sling/models/annotations/package-info.java
copy to src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java
index 57d589b..11b3d02 100644
--- a/src/main/java/org/apache/sling/models/annotations/package-info.java
+++ b/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java
@@ -14,7 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.4.1")
-package org.apache.sling.models.annotations;
+package org.apache.sling.models.annotations.via;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+import org.apache.sling.models.annotations.ViaProviderType;
+
+/**
+ * Marker class for using the JavaBean @Via provider.
+ */
+public class BeanProperty implements ViaProviderType {
+}
diff --git a/src/main/java/org/apache/sling/models/annotations/package-info.java b/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java
similarity index 77%
copy from src/main/java/org/apache/sling/models/annotations/package-info.java
copy to src/main/java/org/apache/sling/models/annotations/via/ChildResource.java
index 57d589b..adeef76 100644
--- a/src/main/java/org/apache/sling/models/annotations/package-info.java
+++ b/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java
@@ -14,7 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.4.1")
-package org.apache.sling.models.annotations;
+package org.apache.sling.models.annotations.via;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+import org.apache.sling.models.annotations.ViaProviderType;
+
+/**
+ * Marker class for using the ChildResource @Via provider.
+ */
+public class ChildResource implements ViaProviderType {
+}
diff --git a/src/main/java/org/apache/sling/models/annotations/package-info.java b/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java
similarity index 76%
copy from src/main/java/org/apache/sling/models/annotations/package-info.java
copy to src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java
index 57d589b..5bf7847 100644
--- a/src/main/java/org/apache/sling/models/annotations/package-info.java
+++ b/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java
@@ -14,7 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.4.1")
-package org.apache.sling.models.annotations;
+package org.apache.sling.models.annotations.via;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+import org.apache.sling.models.annotations.ViaProviderType;
+
+/**
+ * Marker class for using the ForcedResourceType @Via provider.
+ */
+public class ForcedResourceType implements ViaProviderType {
+}
diff --git a/src/main/java/org/apache/sling/models/annotations/package-info.java b/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java
similarity index 76%
copy from src/main/java/org/apache/sling/models/annotations/package-info.java
copy to src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java
index 57d589b..ab13228 100644
--- a/src/main/java/org/apache/sling/models/annotations/package-info.java
+++ b/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java
@@ -14,7 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.4.1")
-package org.apache.sling.models.annotations;
+package org.apache.sling.models.annotations.via;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+import org.apache.sling.models.annotations.ViaProviderType;
+
+/**
+ * Marker class for using the ResourceSuperType @Via provider.
+ */
+public class ResourceSuperType implements ViaProviderType {
+}
diff --git a/src/main/java/org/apache/sling/models/annotations/package-info.java b/src/main/java/org/apache/sling/models/annotations/via/package-info.java
similarity index 88%
copy from src/main/java/org/apache/sling/models/annotations/package-info.java
copy to src/main/java/org/apache/sling/models/annotations/via/package-info.java
index 57d589b..8453287 100644
--- a/src/main/java/org/apache/sling/models/annotations/package-info.java
+++ b/src/main/java/org/apache/sling/models/annotations/via/package-info.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.4.1")
-package org.apache.sling.models.annotations;
+@Version("1.0.0")
+package org.apache.sling.models.annotations.via;
 
 import aQute.bnd.annotation.Version;
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/models/annotations/Via.java b/src/main/java/org/apache/sling/models/spi/ViaProvider.java
similarity index 51%
copy from src/main/java/org/apache/sling/models/annotations/Via.java
copy to src/main/java/org/apache/sling/models/spi/ViaProvider.java
index e8b5b07..daaf75e 100644
--- a/src/main/java/org/apache/sling/models/annotations/Via.java
+++ b/src/main/java/org/apache/sling/models/spi/ViaProvider.java
@@ -14,21 +14,33 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.annotations;
+package org.apache.sling.models.spi;
 
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import org.apache.sling.models.annotations.ViaProviderType;
 
 /**
- * Indicate that this injection point should be handled using a projected
- * property of the adaptable.
+ * SPI interface for providers of the @Via annotation.
  */
-@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Via {
+public interface ViaProvider {
 
-    public String value();
+    /**
+     * Return the marker class for use in the @Via annotation
+     *
+     * @return the marker class
+     */
+    Class<? extends ViaProviderType> getType();
 
-}
\ No newline at end of file
+    /**
+     * Get an adaptable using the value of the @Via annotation.
+     *
+     * @param original the original adaptable
+     * @param value the value of the @Via annotation
+     * @return the projected adaptable
+     */
+    Object getAdaptable(Object original, String value);
+
+    /**
+     * Marker object indicating that the original object should be used.
+     */
+    Object ORIGINAL = new Object();
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.