Merge branch 'via-resource-type-force'

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

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1792071 13f79535-47bb-0310-9956-ffa450edef68
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/ViaProviderType.java b/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java
new file mode 100644
index 0000000..0abc629
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/ViaProviderType.java
@@ -0,0 +1,23 @@
+/*
+ * 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.annotations;
+
+/**
+ * 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/via/BeanProperty.java b/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java
new file mode 100644
index 0000000..11b3d02
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/via/BeanProperty.java
@@ -0,0 +1,25 @@
+/*
+ * 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.annotations.via;
+
+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/via/ChildResource.java b/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java
new file mode 100644
index 0000000..adeef76
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/via/ChildResource.java
@@ -0,0 +1,25 @@
+/*
+ * 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.annotations.via;
+
+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/via/ForcedResourceType.java b/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java
new file mode 100644
index 0000000..5bf7847
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/via/ForcedResourceType.java
@@ -0,0 +1,25 @@
+/*
+ * 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.annotations.via;
+
+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/via/ResourceSuperType.java b/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java
new file mode 100644
index 0000000..ab13228
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/via/ResourceSuperType.java
@@ -0,0 +1,25 @@
+/*
+ * 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.annotations.via;
+
+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/via/package-info.java b/src/main/java/org/apache/sling/models/annotations/via/package-info.java
new file mode 100644
index 0000000..8453287
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/via/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+@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/spi/ViaProvider.java b/src/main/java/org/apache/sling/models/spi/ViaProvider.java
new file mode 100644
index 0000000..daaf75e
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/spi/ViaProvider.java
@@ -0,0 +1,46 @@
+/*
+ * 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.spi;
+
+import org.apache.sling.models.annotations.ViaProviderType;
+
+/**
+ * SPI interface for providers of the @Via annotation.
+ */
+public interface ViaProvider {
+
+    /**
+     * Return the marker class for use in the @Via annotation
+     *
+     * @return the marker class
+     */
+    Class<? extends ViaProviderType> getType();
+
+    /**
+     * 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();
+}