Author: justin
Date: Thu Apr 20 15:06:03 2017
New Revision: 1792071

URL: http://svn.apache.org/viewvc?rev=1792071&view=rev
Log:
Merge branch 'via-resource-type-force'

# Conflicts:
#       
bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java

Added:
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/package-info.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/spi/ViaProvider.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java
    
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateRequestTest.java
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateResourceTest.java
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java
      - copied, changed from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
Modified:
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
    
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java
    
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java
    
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java
    
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/ViaTest.java
    sling/trunk/bundles/extensions/models/integration-tests/pom.xml
    
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/rtbound/FakeRequest.java

Modified: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
 Thu Apr 20 15:06:03 2017
@@ -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

Copied: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java?p2=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java
 Thu Apr 20 15:06:03 2017
@@ -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 {
+}

Modified: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 Thu Apr 20 15:06:03 2017
@@ -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

Copied: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java?p2=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java
 Thu Apr 20 15:06:03 2017
@@ -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 {
+}

Copied: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java?p2=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java
 Thu Apr 20 15:06:03 2017
@@ -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 {
+}

Copied: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java?p2=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java
 Thu Apr 20 15:06:03 2017
@@ -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 {
+}

Copied: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java?p2=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java
 Thu Apr 20 15:06:03 2017
@@ -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 {
+}

Copied: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/package-info.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/package-info.java?p2=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/package-info.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/via/package-info.java
 Thu Apr 20 15:06:03 2017
@@ -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

Copied: 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/spi/ViaProvider.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/spi/ViaProvider.java?p2=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/spi/ViaProvider.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/spi/ViaProvider.java
 Thu Apr 20 15:06:03 2017
@@ -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();
+}

Modified: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
 Thu Apr 20 15:06:03 2017
@@ -62,6 +62,8 @@ import org.apache.sling.commons.osgi.Pro
 import org.apache.sling.commons.osgi.RankedServices;
 import org.apache.sling.models.annotations.Model;
 import org.apache.sling.models.annotations.ValidationStrategy;
+import org.apache.sling.models.annotations.ViaProviderType;
+import org.apache.sling.models.annotations.via.BeanProperty;
 import org.apache.sling.models.export.spi.ModelExporter;
 import org.apache.sling.models.factory.ExportException;
 import org.apache.sling.models.factory.InvalidAdaptableException;
@@ -86,6 +88,7 @@ import org.apache.sling.models.spi.Imple
 import org.apache.sling.models.spi.Injector;
 import org.apache.sling.models.spi.ModelValidation;
 import org.apache.sling.models.spi.ValuePreparer;
+import org.apache.sling.models.spi.ViaProvider;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessor;
 import 
org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessorFactory;
 import 
org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessorFactory2;
@@ -106,7 +109,12 @@ import org.slf4j.LoggerFactory;
         name = "injector",
         referenceInterface = Injector.class,
         cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
-        policy = ReferencePolicy.DYNAMIC)
+        policy = ReferencePolicy.DYNAMIC),
+    @Reference(
+            name = "viaProvider",
+            referenceInterface = ViaProvider.class,
+            cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
+            policy = ReferencePolicy.DYNAMIC)
 })
 @SuppressWarnings("deprecation")
 public class ModelAdapterFactory implements AdapterFactory, Runnable, 
ModelFactory {
@@ -168,6 +176,7 @@ public class ModelAdapterFactory impleme
 
     private final @Nonnull ConcurrentMap<String, RankedServices<Injector>> 
injectors = new ConcurrentHashMap<String, RankedServices<Injector>>();
     private final @Nonnull RankedServices<Injector> sortedInjectors = new 
RankedServices<Injector>();
+    private final @Nonnull ConcurrentMap<Class<? extends ViaProviderType>, 
ViaProvider> viaProviders = new ConcurrentHashMap<Class<? extends 
ViaProviderType>, ViaProvider>();
 
     @Reference(name = "injectAnnotationProcessorFactory", referenceInterface = 
InjectAnnotationProcessorFactory.class,
             cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = 
ReferencePolicy.DYNAMIC)
@@ -728,22 +737,30 @@ public class ModelAdapterFactory impleme
     }
     
     private Object getAdaptable(Object adaptable, InjectableElement point, 
InjectAnnotationProcessor processor) {
-        String viaPropertyName = null;
+        String viaValue = null;
+        Class<? extends ViaProviderType> viaProviderType = null;
         if (processor != null) {
-            viaPropertyName = processor.getVia();
+            viaValue = processor.getVia();
+            viaProviderType = BeanProperty.class; // processors don't support 
via provider type
         }
-        if (viaPropertyName == null) {
-            viaPropertyName = point.getVia();
+        if (StringUtils.isBlank(viaValue)) {
+            viaValue = point.getVia();
+            viaProviderType = point.getViaProviderType();
         }
-        if (viaPropertyName == null) {
+        if (viaProviderType == null || viaValue == null) {
             return adaptable;
         }
-        try {
-            return PropertyUtils.getProperty(adaptable, viaPropertyName);
-        } catch (Exception e) {
-            log.error("Unable to execution projection " + viaPropertyName, e);
+        ViaProvider viaProvider = viaProviders.get(viaProviderType);
+        if (viaProvider == null) {
+            log.error("Unable to find Via provider type {}.", viaProviderType);
             return null;
         }
+        final Object viaResult = viaProvider.getAdaptable(adaptable, viaValue);
+        if (viaResult == ViaProvider.ORIGINAL) {
+            return adaptable;
+        } else {
+            return viaResult;
+        }
     }
 
     private String getName(InjectableElement element, 
InjectAnnotationProcessor processor) {
@@ -1069,6 +1086,16 @@ public class ModelAdapterFactory impleme
         }
     }
 
+    protected void bindViaProvider(final ViaProvider viaProvider, final 
Map<String, Object> props) {
+        Class<? extends ViaProviderType> type = viaProvider.getType();
+        viaProviders.put(type, viaProvider);
+    }
+
+    protected void unbindViaProvider(final ViaProvider viaProvider, final 
Map<String, Object> props) {
+        Class<? extends ViaProviderType> type = viaProvider.getType();
+        viaProviders.remove(type, viaProvider);
+    }
+
     @Nonnull Collection<Injector> getInjectors() {
         return sortedInjectors.get();
     }
@@ -1089,6 +1116,10 @@ public class ModelAdapterFactory impleme
         return adapterImplementations.getImplementationPickers();
     }
 
+    @Nonnull Map<Class<? extends ViaProviderType>, ViaProvider> 
getViaProviders() {
+        return viaProviders;
+    }
+
     @Override
     public boolean isModelAvailableForRequest(@Nonnull SlingHttpServletRequest 
request) {
         return adapterImplementations.getModelClassForRequest(request) != null;

Modified: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
 Thu Apr 20 15:06:03 2017
@@ -20,8 +20,10 @@ import java.io.PrintWriter;
 import java.util.Collection;
 import java.util.Map;
 
+import org.apache.sling.models.annotations.ViaProviderType;
 import org.apache.sling.models.spi.ImplementationPicker;
 import org.apache.sling.models.spi.Injector;
+import org.apache.sling.models.spi.ViaProvider;
 import 
org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessorFactory;
 import 
org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessorFactory2;
 import 
org.apache.sling.models.spi.injectorspecific.StaticInjectAnnotationProcessorFactory;
@@ -100,6 +102,21 @@ public class ModelConfigurationPrinter {
 
         printWriter.println();
 
+        // implementation pickers
+        printWriter.println("Sling Models Via Providers:");
+        Map<Class<? extends ViaProviderType>, ViaProvider> viaProviders = 
modelAdapterFactory.getViaProviders();
+        if (viaProviders == null || viaProviders.size() == 0) {
+            printWriter.println("none");
+        } else {
+            for (Map.Entry<Class<? extends ViaProviderType>, ViaProvider> 
entry : viaProviders.entrySet()) {
+                printWriter.printf("%s (Type: %s)", 
entry.getValue().getClass().getName(), entry.getKey().getName());
+                printWriter.println();
+            }
+        }
+
+
+        printWriter.println();
+
         // models bound to resource types
         printWriter.println("Sling Models Bound to Resource Types *For 
Resources*:");
         for (Map.Entry<String, Class<?>> entry : 
adapterImplementations.getResourceTypeMappingsForResources().entrySet()) {

Modified: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/AbstractInjectableElement.java
 Thu Apr 20 15:06:03 2017
@@ -24,12 +24,8 @@ import java.lang.reflect.Type;
 import javax.inject.Named;
 
 import org.apache.commons.lang.ArrayUtils;
-import org.apache.sling.models.annotations.Default;
-import org.apache.sling.models.annotations.DefaultInjectionStrategy;
-import org.apache.sling.models.annotations.Optional;
-import org.apache.sling.models.annotations.Required;
-import org.apache.sling.models.annotations.Source;
-import org.apache.sling.models.annotations.Via;
+import org.apache.sling.models.annotations.*;
+import org.apache.sling.models.annotations.via.BeanProperty;
 import org.apache.sling.models.impl.ModelAdapterFactory;
 import org.apache.sling.models.impl.ReflectionUtil;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessor;
@@ -40,21 +36,21 @@ import org.slf4j.LoggerFactory;
 
 @SuppressWarnings("deprecation")
 abstract class AbstractInjectableElement implements InjectableElement {
-    
+
     private final AnnotatedElement element;
     private final Type type;
     private final String name;
     private final String source;
-    private final String via;
+    private final ViaSpec via;
     private final boolean hasDefaultValue;
     private final Object defaultValue;
     private final boolean isOptional;
     private final boolean isRequired;
     private final DefaultInjectionStrategy injectionStrategy;
     private final DefaultInjectionStrategy defaultInjectionStrategy;
-    
+
     private static final Logger log = 
LoggerFactory.getLogger(ModelAdapterFactory.class);
-    
+
     public AbstractInjectableElement(AnnotatedElement element, Type type, 
String defaultName,
             StaticInjectAnnotationProcessorFactory[] processorFactories, 
DefaultInjectionStrategy defaultInjectionStrategy) {
         this.element = element;
@@ -70,7 +66,7 @@ abstract class AbstractInjectableElement
         this.injectionStrategy = getInjectionStrategy(element, 
annotationProcessor, defaultInjectionStrategy);
         this.defaultInjectionStrategy = defaultInjectionStrategy;
     }
-    
+
     private static InjectAnnotationProcessor2 
getAnnotationProcessor(AnnotatedElement element, 
StaticInjectAnnotationProcessorFactory[] processorFactories) {
         for (StaticInjectAnnotationProcessorFactory processorFactory : 
processorFactories) {
             InjectAnnotationProcessor2 annotationProcessor = 
processorFactory.createAnnotationProcessor(element);
@@ -80,7 +76,7 @@ abstract class AbstractInjectableElement
         }
         return null;
     }
-    
+
     private static String getName(AnnotatedElement element, String 
defaultName, InjectAnnotationProcessor2 annotationProcessor) {
         String name = null;
         if (annotationProcessor != null) {
@@ -105,19 +101,23 @@ abstract class AbstractInjectableElement
         }
         return null;
     }
-    
-    private static String getVia(AnnotatedElement element, 
InjectAnnotationProcessor2 annotationProcessor) {
-        String via = null;
+
+    private static ViaSpec getVia(AnnotatedElement element, 
InjectAnnotationProcessor2 annotationProcessor) {
+        ViaSpec spec = new ViaSpec();
         if (annotationProcessor != null) {
-            via = annotationProcessor.getVia();
+            spec.via = annotationProcessor.getVia();
         }
-        if (via == null) {
+        if (spec.via == null) {
             Via viaAnnotation = element.getAnnotation(Via.class);
             if (viaAnnotation != null) {
-                via = viaAnnotation.value();
+                spec.via = viaAnnotation.value();
+                spec.type = viaAnnotation.type();
             }
+        } else {
+            // use default type
+            spec.type = BeanProperty.class;
         }
-        return via;
+        return spec;
     }
 
     private static boolean getHasDefaultValue(AnnotatedElement element, 
InjectAnnotationProcessor2 annotationProcessor) {
@@ -131,7 +131,7 @@ abstract class AbstractInjectableElement
         if (annotationProcessor != null && annotationProcessor.hasDefault()) {
             return annotationProcessor.getDefault();
         }
-        
+
         Default defaultAnnotation = element.getAnnotation(Default.class);
         if (defaultAnnotation == null) {
             return null;
@@ -206,13 +206,13 @@ abstract class AbstractInjectableElement
         }
         return element.isAnnotationPresent(Optional.class);
     }
-    
+
     private static boolean getRequired(AnnotatedElement element, 
InjectAnnotationProcessor annotationProcessor) {
         // do not evaluate the injector-specific annotation (those are only 
considered for optional)
         // even setting optional=false will not make an attribute mandatory
         return element.isAnnotationPresent(Required.class);
     }
-    
+
     private static DefaultInjectionStrategy 
getInjectionStrategy(AnnotatedElement element, InjectAnnotationProcessor 
annotationProcessor, DefaultInjectionStrategy defaultInjectionStrategy) {
         if (annotationProcessor != null) {
             if (annotationProcessor instanceof InjectAnnotationProcessor2) {
@@ -228,12 +228,12 @@ abstract class AbstractInjectableElement
         }
         return defaultInjectionStrategy;
     }
-    
+
     @Override
     public final AnnotatedElement getAnnotatedElement() {
         return this.element;
     }
-    
+
     @Override
     public final Type getType() {
         return type;
@@ -243,7 +243,7 @@ abstract class AbstractInjectableElement
     public final String getName() {
         return this.name;
     }
-    
+
     @Override
     public String getSource() {
         return this.source;
@@ -251,9 +251,12 @@ abstract class AbstractInjectableElement
 
     @Override
     public String getVia() {
-        return this.via;
+        return this.via.via;
     }
-    
+
+    @Override
+    public Class<? extends ViaProviderType> getViaProviderType() { return 
this.via.type; }
+
     @Override
     public boolean hasDefaultValue() {
         return this.hasDefaultValue;
@@ -269,8 +272,8 @@ abstract class AbstractInjectableElement
         DefaultInjectionStrategy injectionStrategy = this.injectionStrategy;
         boolean isOptional = this.isOptional;
         boolean isRequired = this.isRequired;
-        
-        // evaluate annotationProcessor (which depends on the adapter) 
+
+        // evaluate annotationProcessor (which depends on the adapter)
         if (annotationProcessor != null) {
             isOptional = getOptional(getAnnotatedElement(), 
annotationProcessor);
             isRequired = getRequired(getAnnotatedElement(), 
annotationProcessor);
@@ -283,4 +286,9 @@ abstract class AbstractInjectableElement
         }
     }
 
+    private static class ViaSpec {
+        String via;
+        Class<? extends ViaProviderType> type;
+    }
+
 }

Modified: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/model/InjectableElement.java
 Thu Apr 20 15:06:03 2017
@@ -21,11 +21,12 @@ package org.apache.sling.models.impl.mod
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Type;
 
+import org.apache.sling.models.annotations.ViaProviderType;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotationProcessor;
 
 @SuppressWarnings("deprecation")
 public interface InjectableElement {
-    
+
     /**
      * @return Underlying annotated element
      */
@@ -35,17 +36,17 @@ public interface InjectableElement {
      * @return Type of injectable mapped to wrapper class
      */
     Type getType();
-    
+
     /**
      * @return true if original type of injectable is a primitive type
      */
     boolean isPrimitive();
-    
+
     /**
      * @return Name for injection
      */
     String getName();
-    
+
     /**
      * @return Via annotation or null
      */
@@ -55,7 +56,9 @@ public interface InjectableElement {
      * @return Via annotation or null
      */
     String getVia();
-    
+
+    Class<? extends ViaProviderType> getViaProviderType();
+
     /**
      * @return true, if a default value is set
      */
@@ -65,7 +68,7 @@ public interface InjectableElement {
      * @return Default value or null
      */
     Object getDefaultValue();
-    
+
     /**
      * @return {@code true} if the element is optional otherwise {@code false}
      */

Added: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java?rev=1792071&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/AbstractResourceTypeViaProvider.java
 Thu Apr 20 15:06:03 2017
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.impl.via;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceWrapper;
+import org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper;
+import org.apache.sling.models.spi.ViaProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+public abstract class AbstractResourceTypeViaProvider implements ViaProvider {
+
+    protected final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Override
+    public Object getAdaptable(Object original, String value) {
+        if (!handle(value)) {
+            return ORIGINAL;
+        }
+         if (original instanceof Resource) {
+            final Resource resource = (Resource) original;
+            if (resource == null) {
+                return null;
+            }
+            final String resourceType = getResourceType(resource, value);
+            if (resourceType == null) {
+                log.warn("Could not determine forced resource type for {} 
using via value {}.", resource, value);
+                return null;
+            }
+            return new ResourceTypeForcingResourceWrapper(resource, 
resourceType);
+         } else if (original instanceof SlingHttpServletRequest) {
+            final SlingHttpServletRequest request = (SlingHttpServletRequest) 
original;
+            final Resource resource = request.getResource();
+            if (resource == null) {
+                return null;
+            }
+            final String resourceType = getResourceType(resource, value);
+            if (resourceType == null) {
+                log.warn("Could not determine forced resource type for {} 
using via value {}.", resource, value);
+                return null;
+            }
+            return new ResourceTypeForcingRequestWrapper(request, resource, 
resourceType);
+         } else {
+            log.warn("Received unexpected adaptable of type {}.", 
original.getClass().getName());
+            return null;
+         }
+    }
+
+    protected abstract boolean handle(@Nonnull String value);
+
+    protected abstract @CheckForNull String getResourceType(@Nonnull Resource 
resource, @Nonnull String value);
+
+    private class ResourceTypeForcingResourceWrapper extends ResourceWrapper {
+
+        private final String resourceType;
+
+        private ResourceTypeForcingResourceWrapper(Resource resource, String 
resourceType) {
+            super(resource);
+            this.resourceType = resourceType;
+        }
+
+        @Override
+        public String getResourceType() {
+            return resourceType;
+        }
+    }
+
+    private class ResourceTypeForcingRequestWrapper extends 
SlingHttpServletRequestWrapper {
+
+        private final Resource resource;
+
+        private ResourceTypeForcingRequestWrapper(SlingHttpServletRequest 
request, Resource resource, String resourceType) {
+            super(request);
+            this.resource = new ResourceTypeForcingResourceWrapper(resource, 
resourceType);
+        }
+
+        @Override
+        public Resource getResource() {
+            return resource;
+        }
+    }
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java?rev=1792071&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
 Thu Apr 20 15:06:03 2017
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.impl.via;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.models.annotations.ViaProviderType;
+import org.apache.sling.models.annotations.via.BeanProperty;
+import org.apache.sling.models.spi.ViaProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component
+@Service
+public class BeanPropertyViaProvider implements ViaProvider {
+
+    private static final Logger log = 
LoggerFactory.getLogger(BeanPropertyViaProvider.class);
+
+    @Override
+    public Class<? extends ViaProviderType> getType() {
+        return BeanProperty.class;
+    }
+
+    @Override
+    public Object getAdaptable(Object original, String value) {
+        if (StringUtils.isBlank(value)) {
+            return ORIGINAL;
+        }
+        try {
+            return PropertyUtils.getProperty(original, value);
+        } catch (Exception e) {
+            log.error("Unable to execution projection " + value, e);
+            return null;
+        }
+    }
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java?rev=1792071&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ChildResourceViaProvider.java
 Thu Apr 20 15:06:03 2017
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.impl.via;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.ViaProviderType;
+import org.apache.sling.models.annotations.via.ChildResource;
+import org.apache.sling.models.spi.ViaProvider;
+
+@Component
+@Service
+public class ChildResourceViaProvider implements ViaProvider {
+
+    @Override
+    public Class<? extends ViaProviderType> getType() {
+        return ChildResource.class;
+    }
+
+    @Override
+    public Object getAdaptable(Object original, String value) {
+        if (StringUtils.isBlank(value)) {
+            return ORIGINAL;
+        }
+        if (original instanceof Resource) {
+            return ((Resource) original).getChild(value);
+        } else {
+            return null;
+        }
+    }
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java?rev=1792071&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ForcedResourceTypeViaProvider.java
 Thu Apr 20 15:06:03 2017
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.impl.via;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.ViaProviderType;
+import org.apache.sling.models.annotations.via.ForcedResourceType;
+
+import javax.annotation.Nonnull;
+
+@Component
+@Service
+public class ForcedResourceTypeViaProvider extends 
AbstractResourceTypeViaProvider {
+    @Override
+    public Class<? extends ViaProviderType> getType() {
+        return ForcedResourceType.class;
+    }
+
+    @Override
+    protected String getResourceType(@Nonnull Resource resource, @Nonnull 
String value) {
+        return value;
+    }
+
+    @Override
+    protected boolean handle(@Nonnull String value) {
+        return StringUtils.isNotBlank(value);
+    }
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java?rev=1792071&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/via/ResourceSuperTypeViaProvider.java
 Thu Apr 20 15:06:03 2017
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.impl.via;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.ViaProviderType;
+import org.apache.sling.models.annotations.via.ResourceSuperType;
+
+import javax.annotation.Nonnull;
+
+@Component
+@Service
+public class ResourceSuperTypeViaProvider extends 
AbstractResourceTypeViaProvider {
+
+    @Override
+    public Class<? extends ViaProviderType> getType() {
+        return ResourceSuperType.class;
+    }
+
+    @Override
+    protected String getResourceType(@Nonnull Resource resource, @Nonnull 
String value) {
+        return resource.getResourceResolver().getParentResourceType(resource);
+    }
+
+    @Override
+    protected boolean handle(@Nonnull String value) {
+        return true;
+    }
+}

Modified: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/InjectorSpecificAnnotationTest.java
 Thu Apr 20 15:06:03 2017
@@ -35,6 +35,7 @@ import org.apache.sling.models.impl.inje
 import org.apache.sling.models.impl.injectors.OSGiServiceInjector;
 import org.apache.sling.models.impl.injectors.RequestAttributeInjector;
 import org.apache.sling.models.impl.injectors.ValueMapInjector;
+import org.apache.sling.models.impl.via.BeanPropertyViaProvider;
 import 
org.apache.sling.models.testmodels.classes.InjectorSpecificAnnotationModel;
 import org.junit.Before;
 import org.junit.Test;
@@ -105,6 +106,7 @@ public class InjectorSpecificAnnotationT
                 Collections.<String, Object> 
singletonMap(Constants.SERVICE_ID, 4L));
         factory.bindStaticInjectAnnotationProcessorFactory(osgiInjector,
                 Collections.<String, Object> 
singletonMap(Constants.SERVICE_ID, 5L));
+        factory.bindViaProvider(new BeanPropertyViaProvider(), null);
 
         SlingBindings bindings = new SlingBindings();
         bindings.setLog(log);

Modified: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/ViaTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/ViaTest.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/ViaTest.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/ViaTest.java
 Thu Apr 20 15:06:03 2017
@@ -28,6 +28,9 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.api.wrappers.ValueMapDecorator;
 import org.apache.sling.models.impl.injectors.ValueMapInjector;
+import org.apache.sling.models.impl.via.BeanPropertyViaProvider;
+import org.apache.sling.models.impl.via.ChildResourceViaProvider;
+import org.apache.sling.models.testmodels.classes.ChildResourceViaModel;
 import org.apache.sling.models.testmodels.classes.ViaModel;
 import org.junit.Before;
 import org.junit.Test;
@@ -44,6 +47,9 @@ public class ViaTest {
     private Resource resource;
 
     @Mock
+    private Resource childResource;
+
+    @Mock
     private SlingHttpServletRequest request;
 
     @Mock
@@ -51,7 +57,7 @@ public class ViaTest {
 
     @Mock
     private BundleContext bundleContext;
-    
+
     private ModelAdapterFactory factory;
 
     @Before
@@ -60,10 +66,14 @@ public class ViaTest {
         when(componentCtx.getProperties()).thenReturn(new Hashtable<String, 
Object>());
 
         when(request.getResource()).thenReturn(resource);
+        when(resource.getChild("jcr:content")).thenReturn(childResource);
         factory = new ModelAdapterFactory();
         factory.activate(componentCtx);
         factory.bindInjector(new ValueMapInjector(), new 
ServicePropertiesMap(1, 1));
+        factory.bindViaProvider(new BeanPropertyViaProvider(), null);
+        factory.bindViaProvider(new ChildResourceViaProvider(), null);
         
factory.adapterImplementations.addClassesAsAdapterAndImplementation(ViaModel.class);
+        
factory.adapterImplementations.addClassesAsAdapterAndImplementation(ChildResourceViaModel.class);
     }
 
     @Test
@@ -71,10 +81,20 @@ public class ViaTest {
         String value = RandomStringUtils.randomAlphanumeric(10);
         ValueMap map = new ValueMapDecorator(Collections.<String, Object> 
singletonMap("firstProperty", value));
         when(resource.adaptTo(ValueMap.class)).thenReturn(map);
-        
+
         ViaModel model = factory.getAdapter(request, ViaModel.class);
         assertNotNull(model);
         assertEquals(value, model.getFirstProperty());
     }
+
+    @Test
+    public void testProjectionToChildResource() {
+        String value = RandomStringUtils.randomAlphanumeric(10);
+        ValueMap map = new ValueMapDecorator(Collections.<String, Object> 
singletonMap("firstProperty", value));
+        when(childResource.adaptTo(ValueMap.class)).thenReturn(map);
+        ChildResourceViaModel model = factory.getAdapter(resource, 
ChildResourceViaModel.class);
+        assertNotNull(model);
+        assertEquals(value, model.getFirstProperty());
+    }
 
 }

Copied: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java?p2=sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceViaModel.java
 Thu Apr 20 15:06:03 2017
@@ -14,21 +14,24 @@
  * 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.testmodels.classes;
 
-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.
- */
-@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Via {
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Via;
+import org.apache.sling.models.annotations.via.ChildResource;
+
+import javax.inject.Inject;
+
+@Model(adaptables = Resource.class)
+public class ChildResourceViaModel {
+
+    @Inject
+    @Via(value = "jcr:content", type = ChildResource.class)
+    private String firstProperty;
 
-    public String value();
+    public String getFirstProperty() {
+        return firstProperty;
+    }
 
-}
\ No newline at end of file
+}

Modified: sling/trunk/bundles/extensions/models/integration-tests/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/pom.xml?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/models/integration-tests/pom.xml (original)
+++ sling/trunk/bundles/extensions/models/integration-tests/pom.xml Thu Apr 20 
15:06:03 2017
@@ -116,7 +116,9 @@
                             org.apache.sling.models.it.noclasses,
                             org.apache.sling.models.it.models,
                             org.apache.sling.models.it.rtbound,
-                            org.apache.sling.models.it.rtboundpicker
+                            org.apache.sling.models.it.rtboundpicker,
+                            org.apache.sling.models.it.delegate.request,
+                            org.apache.sling.models.it.delegate.resource
                         </Sling-Model-Packages>
                         <Sling-Model-Classes>
                             org.apache.sling.models.it.exporter.BaseComponent,
@@ -416,4 +418,18 @@
             <scope>compile</scope>
         </dependency>
     </dependencies>
+    <profiles>
+        <profile>
+            <id>debug-remote-process</id>
+            <properties>
+                <jar.executor.vm.options>-Xmx512m -Xdebug 
-Xrunjdwp:server=y,transport=dt_socket,address=38080,suspend=n</jar.executor.vm.options>
+            </properties>
+        </profile>
+        <profile>
+            <id>debug-remote-process-suspend</id>
+            <properties>
+                <jar.executor.vm.options>-Xmx512m -Xdebug 
-Xrunjdwp:server=y,transport=dt_socket,address=38080,suspend=n</jar.executor.vm.options>
+            </properties>
+        </profile>
+    </profiles>
 </project>

Added: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateRequestTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateRequestTest.java?rev=1792071&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateRequestTest.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateRequestTest.java
 Thu Apr 20 15:06:03 2017
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.it.delegate;
+
+import org.apache.sling.api.SlingConstants;
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
+import org.apache.sling.junit.annotations.TestReference;
+import org.apache.sling.models.factory.ModelFactory;
+import org.apache.sling.models.it.delegate.request.DelegateBaseModel;
+import org.apache.sling.models.it.delegate.request.DelegateExtendedModel;
+import org.apache.sling.models.it.delegate.request.DelegateInterface;
+import org.apache.sling.models.it.rtbound.FakeRequest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+@RunWith(SlingAnnotationsTestRunner.class)
+public class DelegateRequestTest {
+
+    @TestReference
+    private ResourceResolverFactory rrFactory;
+
+    @TestReference
+    private ModelFactory modelFactory;
+
+    private final String baseComponentPath = "/content/delegate/baseComponent";
+    private final String extendedComponentPath = 
"/content/delegate/extendedComponent";
+
+    @Before
+    public void setup() throws LoginException, PersistenceException {
+        ResourceResolver adminResolver = null;
+        try {
+            adminResolver = rrFactory.getAdministrativeResourceResolver(null);
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put("text", "baseTESTValue");
+            properties.put("other", "baseOther");
+            properties.put(SlingConstants.NAMESPACE_PREFIX + ":" + 
SlingConstants.PROPERTY_RESOURCE_TYPE,
+                    "sling/delegate/base");
+            ResourceUtil.getOrCreateResource(adminResolver, baseComponentPath, 
properties, null, false);
+            properties.clear();
+
+            properties.put("text", "extendedTESTValue");
+            properties.put("other", "extendedOther");
+            properties.put(SlingConstants.NAMESPACE_PREFIX + ":" + 
SlingConstants.PROPERTY_RESOURCE_TYPE,
+                    "sling/delegate/extended");
+            ResourceUtil.getOrCreateResource(adminResolver, 
extendedComponentPath, properties, null, false);
+            properties.clear();
+
+            properties.put(SlingConstants.NAMESPACE_PREFIX + ":" + 
SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE,
+                    "sling/delegate/base");
+            ResourceUtil.getOrCreateResource(adminResolver, 
"/apps/sling/delegate/extended", properties, null, false);
+            properties.clear();
+
+            adminResolver.commit();
+        } finally {
+            if (adminResolver != null && adminResolver.isLive()) {
+                adminResolver.close();
+            }
+        }
+    }
+
+    @Test
+    public void testCreateDelegateModel() throws LoginException {
+        ResourceResolver resolver = null;
+        try {
+            resolver = rrFactory.getAdministrativeResourceResolver(null);
+            final Resource baseComponentResource = 
resolver.getResource(baseComponentPath);
+            assertNotNull(baseComponentResource);
+            final FakeRequest baseRequest = new 
FakeRequest(baseComponentResource);
+            final DelegateInterface modelFromBase = 
modelFactory.createModel(baseRequest, DelegateInterface.class);
+            assertNotNull("Base Model should not be null", modelFromBase);
+            assertTrue("Model should be DelegateBaseModel", modelFromBase 
instanceof DelegateBaseModel);
+            assertEquals("baseTESTValue", modelFromBase.getText());
+            assertEquals("baseOther", modelFromBase.getOther());
+
+            final Resource extendedComponentResource = 
resolver.getResource(extendedComponentPath);
+            assertNotNull(extendedComponentResource);
+            final FakeRequest extendedRequest = new 
FakeRequest(extendedComponentResource);
+            final DelegateInterface modelFromExtended = 
modelFactory.createModel(extendedRequest, DelegateInterface.class);
+            assertNotNull("Extended Model should not be null", 
modelFromExtended);
+            assertTrue("Model should be DelegateExtendedModel", 
modelFromExtended instanceof DelegateExtendedModel);
+            assertEquals("EXTENDEDTESTVALUE", modelFromExtended.getText());
+            assertEquals("extendedOther", modelFromExtended.getOther());
+        } finally {
+            if (resolver != null && resolver.isLive()) {
+                resolver.close();
+            }
+        }
+    }
+}

Added: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateResourceTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateResourceTest.java?rev=1792071&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateResourceTest.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/DelegateResourceTest.java
 Thu Apr 20 15:06:03 2017
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.it.delegate;
+
+import org.apache.sling.api.SlingConstants;
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
+import org.apache.sling.junit.annotations.TestReference;
+import org.apache.sling.models.it.delegate.resource.DelegateBaseModel;
+import org.apache.sling.models.it.delegate.resource.DelegateExtendedModel;
+import org.apache.sling.models.it.delegate.resource.DelegateInterface;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+@RunWith(SlingAnnotationsTestRunner.class)
+public class DelegateResourceTest {
+
+    @TestReference
+    private ResourceResolverFactory rrFactory;
+
+    private final String baseComponentPath = "/content/delegate/baseComponent";
+    private final String extendedComponentPath = 
"/content/delegate/extendedComponent";
+
+    @Before
+    public void setup() throws LoginException, PersistenceException {
+        ResourceResolver adminResolver = null;
+        try {
+            adminResolver = rrFactory.getAdministrativeResourceResolver(null);
+            Map<String, Object> properties = new HashMap<String, Object>();
+            properties.put("text", "baseTESTValue");
+            properties.put("other", "baseOther");
+            properties.put(SlingConstants.NAMESPACE_PREFIX + ":" + 
SlingConstants.PROPERTY_RESOURCE_TYPE,
+                    "sling/delegate/base");
+            ResourceUtil.getOrCreateResource(adminResolver, baseComponentPath, 
properties, null, false);
+            properties.clear();
+
+            properties.put("text", "extendedTESTValue");
+            properties.put("other", "extendedOther");
+            properties.put(SlingConstants.NAMESPACE_PREFIX + ":" + 
SlingConstants.PROPERTY_RESOURCE_TYPE,
+                    "sling/delegate/extended");
+            ResourceUtil.getOrCreateResource(adminResolver, 
extendedComponentPath, properties, null, false);
+            properties.clear();
+
+            properties.put(SlingConstants.NAMESPACE_PREFIX + ":" + 
SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE,
+                    "sling/delegate/base");
+            ResourceUtil.getOrCreateResource(adminResolver, 
"/apps/sling/delegate/extended", properties, null, false);
+            properties.clear();
+
+            adminResolver.commit();
+        } finally {
+            if (adminResolver != null && adminResolver.isLive()) {
+                adminResolver.close();
+            }
+        }
+    }
+
+    @Test
+    public void testCreateDelegateModel() throws LoginException {
+        ResourceResolver resolver = null;
+        try {
+            resolver = rrFactory.getAdministrativeResourceResolver(null);
+            final Resource baseComponentResource = 
resolver.getResource(baseComponentPath);
+            assertNotNull(baseComponentResource);
+            final DelegateInterface modelFromBase = 
baseComponentResource.adaptTo(DelegateInterface.class);
+            assertNotNull("Model should not be null", modelFromBase);
+            assertTrue("Model should be DelegateBaseModel", modelFromBase 
instanceof DelegateBaseModel);
+            assertEquals("baseTESTValue", modelFromBase.getText());
+            assertEquals("baseOther", modelFromBase.getOther());
+
+            final Resource extendedComponentResource = 
resolver.getResource(extendedComponentPath);
+            assertNotNull(extendedComponentResource);
+            final DelegateInterface modelFromExtended = 
extendedComponentResource.adaptTo(DelegateInterface.class);
+            assertNotNull("Model should not be null", modelFromExtended);
+            assertTrue("Model should be DelegateExtendedModel", 
modelFromExtended instanceof DelegateExtendedModel);
+            assertEquals("EXTENDEDTESTVALUE", modelFromExtended.getText());
+            assertEquals("extendedOther", modelFromExtended.getOther());
+        } finally {
+            if (resolver != null && resolver.isLive()) {
+                resolver.close();
+            }
+        }
+    }
+}

Copied: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java?p2=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java
 Thu Apr 20 15:06:03 2017
@@ -14,21 +14,31 @@
  * 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.it.delegate.request;
 
-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.
- */
-@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Via {
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Via;
+
+import javax.inject.Inject;
+
+@Model(adaptables = SlingHttpServletRequest.class, adapters = 
DelegateInterface.class,
+    resourceType = "sling/delegate/base")
+public class DelegateBaseModel implements DelegateInterface {
+
+    @Inject @Via("resource")
+    private String text;
+
+    @Inject @Via("resource")
+    private String other;
 
-    public String value();
+    @Override
+    public String getText() {
+        return text;
+    }
 
-}
\ No newline at end of file
+    @Override
+    public String getOther() {
+        return other;
+    }
+}

Added: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java?rev=1792071&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java
 Thu Apr 20 15:06:03 2017
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.it.delegate.request;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Via;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+import org.apache.sling.models.annotations.via.ResourceSuperType;
+
+@Model(adaptables = SlingHttpServletRequest.class, adapters = 
DelegateInterface.class,
+        resourceType = "sling/delegate/extended")
+public class DelegateExtendedModel implements DelegateInterface {
+
+    @Self @Via(type = ResourceSuperType.class)
+    private DelegateInterface delegate;
+
+    @Override
+    public String getOther() {
+        return delegate.getOther();
+    }
+
+    @Override
+    public String getText() {
+        return delegate.getText().toUpperCase();
+    }
+}

Copied: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java?p2=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java
 Thu Apr 20 15:06:03 2017
@@ -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.it.delegate.request;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+public interface DelegateInterface {
+
+    String getText();
+
+    String getOther();
+
+}

Copied: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java?p2=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java
 Thu Apr 20 15:06:03 2017
@@ -14,21 +14,30 @@
  * 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.it.delegate.resource;
 
-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.
- */
-@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Via {
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+
+import javax.inject.Inject;
+
+@Model(adaptables = Resource.class, adapters = DelegateInterface.class,
+    resourceType = "sling/delegate/base")
+public class DelegateBaseModel implements DelegateInterface {
+
+    @Inject
+    private String text;
+
+    @Inject
+    private String other;
 
-    public String value();
+    @Override
+    public String getText() {
+        return text;
+    }
 
-}
\ No newline at end of file
+    @Override
+    public String getOther() {
+        return other;
+    }
+}

Copied: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java?p2=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/Via.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java
 Thu Apr 20 15:06:03 2017
@@ -14,21 +14,28 @@
  * 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.it.delegate.resource;
 
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Via;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+import org.apache.sling.models.annotations.via.ResourceSuperType;
 
-/**
- * Indicate that this injection point should be handled using a projected
- * property of the adaptable.
- */
-@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Via {
+@Model(adaptables = Resource.class, adapters = DelegateInterface.class,
+        resourceType = "sling/delegate/extended")
+public class DelegateExtendedModel implements DelegateInterface {
+
+    @Self @Via(type = ResourceSuperType.class)
+    private DelegateInterface delegate;
 
-    public String value();
+    @Override
+    public String getOther() {
+        return delegate.getOther();
+    }
 
-}
\ No newline at end of file
+    @Override
+    public String getText() {
+        return delegate.getText().toUpperCase();
+    }
+}

Copied: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java
 (from r1792046, 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java?p2=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java&p1=sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java&r1=1792046&r2=1792071&rev=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/api/src/main/java/org/apache/sling/models/annotations/package-info.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java
 Thu Apr 20 15:06:03 2017
@@ -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.it.delegate.resource;
 
-import aQute.bnd.annotation.Version;
\ No newline at end of file
+public interface DelegateInterface {
+
+    String getText();
+
+    String getOther();
+
+}

Modified: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/rtbound/FakeRequest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/rtbound/FakeRequest.java?rev=1792071&r1=1792070&r2=1792071&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/rtbound/FakeRequest.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/rtbound/FakeRequest.java
 Thu Apr 20 15:06:03 2017
@@ -38,11 +38,11 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
 
-class FakeRequest implements SlingHttpServletRequest {
+public class FakeRequest implements SlingHttpServletRequest {
 
     private final Resource resource;
 
-    FakeRequest(Resource r) {
+    public FakeRequest(Resource r) {
         this.resource = r;
     }
 


Reply via email to