You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:54:28 UTC

[sling-org-apache-sling-models-api] annotated tag org.apache.sling.models.api-1.1.0 created (now d147ac1)

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

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


      at d147ac1  (tag)
 tagging a2bc972e0faedaeea1da9cd4477cdc970c2222a3 (commit)
      by Justin Edelson
      on Tue Sep 2 19:13:34 2014 +0000

- Log -----------------------------------------------------------------
org.apache.sling.models.api-1.1.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new ec1ba92  SLING-3313 - adding initial version of Sling Models (nee YAMF)
     new 7927f09  set svn:ignore
     new 3d1d240  trivial change
     new 45329bf  [maven-release-plugin] prepare release org.apache.sling.models.api-1.0.0
     new a50b83e  [maven-release-plugin] prepare for next development iteration
     new ae66b2b  Update to parent pom v19
     new 1e5625a  SLING-3499 - adding support for custom annotation per injector (thanks Konrad Windszus for the patch!)
     new d2fec0e  SLING-3683 - breaking apart annotation processor factory selection from injector selection
     new 3e99fd3  SLING-3696 - adding support for defining a default injection strategy of required or optional. Also adding a @Required annotation
     new 0fec2aa  [maven-release-plugin] prepare release org.apache.sling.models.api-1.0.2
     new d9ac6ff  [maven-release-plugin] prepare for next development iteration
     new e442e40  Updated to parent version 20
     new 58c47dd  SLING-3716 SLING-3718 - adding support for constructor injection and self injection based on a patch from Stefan Seifert
     new 27a5d46  SLING-3861 - adding condition option for @Model annotation
     new 459c12d  SLING-3869 - fixing branding issues with Sling Models. Thanks to Stefan Seifert for the patch!
     new 037bb9e  SLING-3877 - adding a resource path injector. also did some minor refactoring to avoid code duplication between injectors.
     new 40eaf4e  SLING-3715 - adding sling object injector. Thanks to Stefan for the patch!
     new 85dbcb5  SLING-3879 - fixing NPE in PathInjector. Thanks Stefan for the patch!
     new 1df4b0e  SLING-3886 - adding support for adapter indirection where the adapting target is a superclass or implemented interface of the implementation class. Thanks to Stefan for the patch!
     new b542260  [maven-release-plugin] prepare release org.apache.sling.models.api-1.1.0
     new a2bc972  [maven-release-plugin]  copy for tag org.apache.sling.models.api-1.1.0

The 21 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


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

[sling-org-apache-sling-models-api] 07/11: SLING-3715 - adding sling object injector. Thanks to Stefan for the patch!

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 40eaf4e3e5aa3a5a54c36712b2533f4dfd44ec71
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Sun Aug 24 19:09:39 2014 +0000

    SLING-3715 - adding sling object injector. Thanks to Stefan for the patch!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1620175 13f79535-47bb-0310-9956-ffa450edef68
---
 .../annotations/injectorspecific/SlingObject.java  | 47 ++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/SlingObject.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/SlingObject.java
new file mode 100644
index 0000000..40e0968
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/SlingObject.java
@@ -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.annotations.injectorspecific;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.sling.models.annotations.Source;
+import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
+
+/**
+ * Annotation to be used on either methods, fields or constructor parameters to let Sling Models inject a
+ * Sling-related context object.
+ */
+@Target({ METHOD, FIELD, PARAMETER })
+@Retention(RUNTIME)
+@InjectAnnotation
+@Source("sling-object")
+public @interface SlingObject {
+
+  /**
+   * If set to true, the model can be instantiated even if there is no request attribute
+   * with the given name found.
+   * Default = false.
+   */
+  boolean optional() default false;
+
+}

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

[sling-org-apache-sling-models-api] 08/11: SLING-3879 - fixing NPE in PathInjector. Thanks Stefan for the patch!

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 85dbcb539542e7450e8cc8fac1913f59659a7f9d
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Mon Aug 25 11:44:46 2014 +0000

    SLING-3879 - fixing NPE in PathInjector. Thanks Stefan for the patch!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1620296 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/models/annotations/injectorspecific/ResourcePath.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ResourcePath.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ResourcePath.java
index d013642..23953ed 100644
--- a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ResourcePath.java
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ResourcePath.java
@@ -38,7 +38,7 @@ import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
 public @interface ResourcePath {
 
     /**
-     * Specifies the path of the resource. If not provided, the path is dervied from the proeprty name.
+     * Specifies the path of the resource. If not provided, the path is derived from the property name.
      */
     public String path() default "";
 

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

[sling-org-apache-sling-models-api] 06/11: SLING-3877 - adding a resource path injector. also did some minor refactoring to avoid code duplication between injectors.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 037bb9e044b9f1c564a2a991bbe486f963f4afab
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Aug 22 15:50:07 2014 +0000

    SLING-3877 - adding a resource path injector. also did some minor refactoring to avoid code duplication between injectors.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1619848 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/models/annotations/Path.java  | 37 ++++++++++++++
 .../annotations/injectorspecific/ResourcePath.java | 58 ++++++++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git a/src/main/java/org/apache/sling/models/annotations/Path.java b/src/main/java/org/apache/sling/models/annotations/Path.java
new file mode 100644
index 0000000..a849683
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/Path.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Provide a path on an @Inject. Not necessarily tied to the Resource Path injector (thus no
+ * @Source annotation), may be reused for other injector types.
+ */
+@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
+@Retention(RetentionPolicy.RUNTIME)
+@Qualifier
+public @interface Path {
+
+    public String value();
+
+}
diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ResourcePath.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ResourcePath.java
new file mode 100644
index 0000000..d013642
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ResourcePath.java
@@ -0,0 +1,58 @@
+/*
+ * 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.injectorspecific;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.sling.models.annotations.Source;
+import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
+
+/**
+ * Annotation to be used on either methods, fields or constructor parameters to let Sling Models inject a
+ * resource by path. The path may be either in the path attribute or in a value map property with the given name.
+ */
+@Target({ METHOD, FIELD, PARAMETER })
+@Retention(RUNTIME)
+@InjectAnnotation
+@Source("resource-path")
+public @interface ResourcePath {
+
+    /**
+     * Specifies the path of the resource. If not provided, the path is dervied from the proeprty name.
+     */
+    public String path() default "";
+
+    /**
+     * Specifies the name of the property containing the resource path. If empty or not set, then the name
+     * is derived from the method or field.
+     */
+    public String name() default "";
+
+    /**
+     * If set to true, the model can be instantiated even if there is no request attribute
+     * with the given name found.
+     * Default = false.
+     */
+    public boolean optional() default false;
+
+}

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

[sling-org-apache-sling-models-api] 09/11: SLING-3886 - adding support for adapter indirection where the adapting target is a superclass or implemented interface of the implementation class. Thanks to Stefan for the patch!

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1df4b0ed1519d24bd0793331867f93404ebf6951
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Aug 29 18:53:41 2014 +0000

    SLING-3886 - adding support for adapter indirection where the adapting target is a superclass or implemented interface of the implementation class. Thanks to Stefan for the patch!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1621361 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/models/annotations/Model.java | 16 +++++++-
 .../sling/models/spi/ImplementationPicker.java     | 48 ++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/models/annotations/Model.java b/src/main/java/org/apache/sling/models/annotations/Model.java
index 595b312..6b5616e 100644
--- a/src/main/java/org/apache/sling/models/annotations/Model.java
+++ b/src/main/java/org/apache/sling/models/annotations/Model.java
@@ -23,16 +23,30 @@ import java.lang.annotation.Target;
 
 /**
  * Mark a class as adaptable via Sling Models.
- *
  */
 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Model {
 
+    /**
+     * @return List of classes from which can be adapted.
+     */
     public Class<?>[] adaptables();
 
+    /**
+     * @return List of classes to which can be adapted. If missing, the class that is annotated is used.
+     *   If classes are given, they have to be either the annotated class itself, or interfaces or super classes of the class.
+     */
+    public Class<?>[] adapters() default {};
+
+    /**
+     * @return Default injection strategy (optional or required)
+     */
     public DefaultInjectionStrategy defaultInjectionStrategy() default DefaultInjectionStrategy.REQUIRED;
 
+    /**
+     * @return Condition that is displayed in the felix console adapter plugin
+     */
     public String condition() default "";
 
 }
diff --git a/src/main/java/org/apache/sling/models/spi/ImplementationPicker.java b/src/main/java/org/apache/sling/models/spi/ImplementationPicker.java
new file mode 100644
index 0000000..3a56b5a
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/spi/ImplementationPicker.java
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * Defines a strategy to choose an implementation for a model if multiple are registered 
+ * for the same interface or super class.
+ * <p>
+ * With using the @Model.adapters attribute it is possible to define interfaces or super 
+ * classes to which the model implementation is an adaption target. It is possible that 
+ * multiple models implement the same type.
+ * </p>
+ * <p>
+ * In this case services implementing the {@link ImplementationPicker} interface are 
+ * queried to decide which implementation should be chosen. If multiple implementations 
+ * of this interface exists they are queried one after another by service ranking. 
+ * The first that picks an implementation is the winner.
+ * </p>
+ */
+public interface ImplementationPicker {
+    
+    /**
+     * Select an implementation for the adapter class to which the adaptable should be adapted to.
+     * @param adapterType Adapter type. Never null.
+     * @param implementationsTypes Available implementations. It is guaranteed that they can be assigned to the adapter type.
+     *     Never null and has always at least one entry.
+     * @param adaptable For reference: the adaptable. May be enquired to detect the context of the adaption. Never null.
+     * @return If an implementation is chosen the class is returned, otherwise null.
+     */
+    Class<?> pick(Class<?> adapterType, Class<?>[] implementationsTypes, Object adaptable);
+
+}

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

[sling-org-apache-sling-models-api] 05/11: SLING-3869 - fixing branding issues with Sling Models. Thanks to Stefan Seifert for the patch!

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 459c12da4d934687344976516160f7e4574223eb
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Thu Aug 21 20:46:36 2014 +0000

    SLING-3869 - fixing branding issues with Sling Models. Thanks to Stefan Seifert for the patch!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1619575 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                      | 4 ++--
 src/main/java/org/apache/sling/models/annotations/Model.java | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 193a756..fdc126f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,8 +29,8 @@
     <artifactId>org.apache.sling.models.api</artifactId>
     <packaging>bundle</packaging>
     <version>1.0.3-SNAPSHOT</version>
-    <name>Sling Models API</name>
-    <description>Sling Models API</description>
+    <name>Apache Sling Models API</name>
+    <description>Apache Sling Models API</description>
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api</connection>
         <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api</developerConnection>
diff --git a/src/main/java/org/apache/sling/models/annotations/Model.java b/src/main/java/org/apache/sling/models/annotations/Model.java
index 7ef93d5..595b312 100644
--- a/src/main/java/org/apache/sling/models/annotations/Model.java
+++ b/src/main/java/org/apache/sling/models/annotations/Model.java
@@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * Mark a class as adaptable via YAMF.
+ * Mark a class as adaptable via Sling Models.
  *
  */
 @Target(ElementType.TYPE)

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

[sling-org-apache-sling-models-api] 01/11: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d9ac6ffc396928bc1aa2022df9072bbe8d6c1620
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Jun 25 15:53:26 2014 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1605457 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 488863c..1a6e515 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,13 +28,13 @@
     
     <artifactId>org.apache.sling.models.api</artifactId>
     <packaging>bundle</packaging>
-    <version>1.0.2</version>
+    <version>1.0.3-SNAPSHOT</version>
     <name>Sling Models API</name>
     <description>Sling Models API</description>
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.api-1.0.2</connection>
-        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.api-1.0.2</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.models.api-1.0.2</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api</url>
     </scm>
     <build>
         <plugins>

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

[sling-org-apache-sling-models-api] 04/11: SLING-3861 - adding condition option for @Model annotation

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 27a5d46157129c5ffe026116a15573122e6fcbd5
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Aug 20 16:02:38 2014 +0000

    SLING-3861 - adding condition option for @Model annotation
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1619134 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/models/annotations/Model.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/main/java/org/apache/sling/models/annotations/Model.java b/src/main/java/org/apache/sling/models/annotations/Model.java
index cfb121a..7ef93d5 100644
--- a/src/main/java/org/apache/sling/models/annotations/Model.java
+++ b/src/main/java/org/apache/sling/models/annotations/Model.java
@@ -33,4 +33,6 @@ public @interface Model {
 
     public DefaultInjectionStrategy defaultInjectionStrategy() default DefaultInjectionStrategy.REQUIRED;
 
+    public String condition() default "";
+
 }

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

[sling-org-apache-sling-models-api] 03/11: SLING-3716 SLING-3718 - adding support for constructor injection and self injection based on a patch from Stefan Seifert

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 58c47ddd3abacceb8bfd86b6f865c449b322a224
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Aug 19 22:51:36 2014 +0000

    SLING-3716 SLING-3718 - adding support for constructor injection and self injection based on a patch from Stefan Seifert
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1619007 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/models/annotations/Default.java   |  2 +-
 .../apache/sling/models/annotations/Filter.java    |  2 +-
 .../apache/sling/models/annotations/Optional.java  |  2 +-
 .../apache/sling/models/annotations/Required.java  |  2 +-
 .../apache/sling/models/annotations/Source.java    |  2 +-
 .../org/apache/sling/models/annotations/Via.java   |  2 +-
 .../injectorspecific/ChildResource.java            |  5 ++--
 .../annotations/injectorspecific/OSGiService.java  |  5 ++--
 .../injectorspecific/RequestAttribute.java         |  5 ++--
 .../injectorspecific/ScriptVariable.java           |  5 ++--
 .../{RequestAttribute.java => Self.java}           | 22 +++++++-----------
 .../injectorspecific/ValueMapValue.java            |  6 +++--
 .../annotations/injectorspecific/package-info.java |  2 +-
 .../sling/models/annotations/package-info.java     |  2 +-
 .../apache/sling/models/spi/AcceptsNullName.java   | 27 ++++++++++++++++++++++
 .../org/apache/sling/models/spi/package-info.java  |  2 +-
 16 files changed, 60 insertions(+), 33 deletions(-)

diff --git a/src/main/java/org/apache/sling/models/annotations/Default.java b/src/main/java/org/apache/sling/models/annotations/Default.java
index aa0cc25..963a480 100644
--- a/src/main/java/org/apache/sling/models/annotations/Default.java
+++ b/src/main/java/org/apache/sling/models/annotations/Default.java
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
 /**
  * Default value for an injection.
  */
-@Target({ ElementType.FIELD, ElementType.METHOD })
+@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Default {
 
diff --git a/src/main/java/org/apache/sling/models/annotations/Filter.java b/src/main/java/org/apache/sling/models/annotations/Filter.java
index 355314c..c91f296 100644
--- a/src/main/java/org/apache/sling/models/annotations/Filter.java
+++ b/src/main/java/org/apache/sling/models/annotations/Filter.java
@@ -26,7 +26,7 @@ import javax.inject.Qualifier;
 /**
  * Provide a filter on an @Inject.
  */
-@Target({ ElementType.FIELD, ElementType.METHOD })
+@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
 @Retention(RetentionPolicy.RUNTIME)
 @Source("osgi-services")
 @Qualifier
diff --git a/src/main/java/org/apache/sling/models/annotations/Optional.java b/src/main/java/org/apache/sling/models/annotations/Optional.java
index 5743495..39e068a 100644
--- a/src/main/java/org/apache/sling/models/annotations/Optional.java
+++ b/src/main/java/org/apache/sling/models/annotations/Optional.java
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
 /**
  * Marker annotation for optional injections.
  */
-@Target({ ElementType.FIELD, ElementType.METHOD })
+@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Optional {
 
diff --git a/src/main/java/org/apache/sling/models/annotations/Required.java b/src/main/java/org/apache/sling/models/annotations/Required.java
index 4bd87e7..8992377 100644
--- a/src/main/java/org/apache/sling/models/annotations/Required.java
+++ b/src/main/java/org/apache/sling/models/annotations/Required.java
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
 /**
  * Marker annotation for required injections.
  */
-@Target({ ElementType.FIELD, ElementType.METHOD })
+@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Required {
 
diff --git a/src/main/java/org/apache/sling/models/annotations/Source.java b/src/main/java/org/apache/sling/models/annotations/Source.java
index 0a23c0d..403b4ea 100644
--- a/src/main/java/org/apache/sling/models/annotations/Source.java
+++ b/src/main/java/org/apache/sling/models/annotations/Source.java
@@ -28,7 +28,7 @@ import javax.inject.Qualifier;
  * Can also be used as a meta-annotation to declare that some other annotation implies
  * a source.
  */
-@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE })
+@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
 @Retention(RetentionPolicy.RUNTIME)
 @Qualifier
 public @interface Source {
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 75683f7..e8b5b07 100644
--- a/src/main/java/org/apache/sling/models/annotations/Via.java
+++ b/src/main/java/org/apache/sling/models/annotations/Via.java
@@ -25,7 +25,7 @@ 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 })
+@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Via {
 
diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ChildResource.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ChildResource.java
index bce2cc2..26f32ce 100644
--- a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ChildResource.java
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ChildResource.java
@@ -18,6 +18,7 @@ package org.apache.sling.models.annotations.injectorspecific;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 import java.lang.annotation.Retention;
@@ -27,10 +28,10 @@ import org.apache.sling.models.annotations.Source;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
 
 /**
- * Annotation to be used on either methods or fields to let Sling Models inject a child resource
+ * Annotation to be used on either methods, fields or constructor parameters to let Sling Models inject a child resource
  *
  */
-@Target({ METHOD, FIELD })
+@Target({ METHOD, FIELD, PARAMETER })
 @Retention(RUNTIME)
 @InjectAnnotation
 @Source("child-resources")
diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/OSGiService.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/OSGiService.java
index 92b31bd..a4363c9 100644
--- a/src/main/java/org/apache/sling/models/annotations/injectorspecific/OSGiService.java
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/OSGiService.java
@@ -18,6 +18,7 @@ package org.apache.sling.models.annotations.injectorspecific;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 import java.lang.annotation.Retention;
@@ -27,10 +28,10 @@ import org.apache.sling.models.annotations.Source;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
 
 /**
- * Annotation to be used on either methods or fields to let Sling Models inject an OSGi service
+ * Annotation to be used on either methods, fields or constructor parameters to let Sling Models inject an OSGi service
  *
  */
-@Target({ METHOD, FIELD })
+@Target({ METHOD, FIELD, PARAMETER })
 @Retention(RUNTIME)
 @InjectAnnotation
 @Source("osgi-services")
diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/RequestAttribute.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/RequestAttribute.java
index 6b4d1a6..07626d4 100644
--- a/src/main/java/org/apache/sling/models/annotations/injectorspecific/RequestAttribute.java
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/RequestAttribute.java
@@ -18,6 +18,7 @@ package org.apache.sling.models.annotations.injectorspecific;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 import java.lang.annotation.Retention;
@@ -27,11 +28,11 @@ import org.apache.sling.models.annotations.Source;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
 
 /**
- * Annotation to be used on either methods or fields to let Sling Models inject a
+ * Annotation to be used on either methods, fields or constructor parameters to let Sling Models inject a
  * request attribute.
  *
  */
-@Target({ METHOD, FIELD })
+@Target({ METHOD, FIELD, PARAMETER })
 @Retention(RUNTIME)
 @InjectAnnotation
 @Source("request-attributes")
diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ScriptVariable.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ScriptVariable.java
index b08cece..d25c0e3 100644
--- a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ScriptVariable.java
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ScriptVariable.java
@@ -18,6 +18,7 @@ package org.apache.sling.models.annotations.injectorspecific;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 import java.lang.annotation.Retention;
@@ -27,11 +28,11 @@ import org.apache.sling.models.annotations.Source;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
 
 /**
- * Annotation to be used on either methods or fields to let Sling Models inject a
+ * Annotation to be used on either methods, fields or constructor parameters to let Sling Models inject a
  * script variable (from the {@link org.apache.sling.api.scripting.SlingBindings})
  *
  */
-@Target({ METHOD, FIELD })
+@Target({ METHOD, FIELD, PARAMETER })
 @Retention(RUNTIME)
 @InjectAnnotation
 @Source("script-bindings")
diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/RequestAttribute.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/Self.java
similarity index 76%
copy from src/main/java/org/apache/sling/models/annotations/injectorspecific/RequestAttribute.java
copy to src/main/java/org/apache/sling/models/annotations/injectorspecific/Self.java
index 6b4d1a6..b452a76 100644
--- a/src/main/java/org/apache/sling/models/annotations/injectorspecific/RequestAttribute.java
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/Self.java
@@ -18,6 +18,7 @@ package org.apache.sling.models.annotations.injectorspecific;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 import java.lang.annotation.Retention;
@@ -27,26 +28,19 @@ import org.apache.sling.models.annotations.Source;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
 
 /**
- * Annotation to be used on either methods or fields to let Sling Models inject a
- * request attribute.
- *
+ * Annotation to be used on either methods, fields or constructor parameters to let Sling Models
+ * inject the adaptable itself, or an object that can be adapted from it. 
  */
-@Target({ METHOD, FIELD })
+@Target({ METHOD, FIELD, PARAMETER })
 @Retention(RUNTIME)
 @InjectAnnotation
-@Source("request-attributes")
-public @interface RequestAttribute {
+@Source("self")
+public @interface Self {
 
     /**
-     * Specifies the name of the request attribute. If empty or not set, then the name
-     * is derived from the method or field.
-     */
-    public String name() default "";
-
-    /**
-     * If set to true, the model can be instantiated even if there is no request attribute
-     * with the given name found.
+     * If set to true, the model can be instantiated even if there is no object that can be adapted from the adaptable itself. 
      * Default = false.
      */
     public boolean optional() default false;
+
 }
diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ValueMapValue.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ValueMapValue.java
index bbdaf80..4511d59 100644
--- a/src/main/java/org/apache/sling/models/annotations/injectorspecific/ValueMapValue.java
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/ValueMapValue.java
@@ -18,6 +18,7 @@ package org.apache.sling.models.annotations.injectorspecific;
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 import java.lang.annotation.Retention;
@@ -27,10 +28,11 @@ import org.apache.sling.models.annotations.Source;
 import org.apache.sling.models.spi.injectorspecific.InjectAnnotation;
 
 /**
- * Annotation to be used on either methods or fields to let Sling Models inject a value from the ValueMap of the current resource.
+ * Annotation to be used on either methods, fields or constructor parameter to let Sling Models
+ * inject a value from the ValueMap of the current resource.
  *
  */
-@Target({ METHOD, FIELD })
+@Target({ METHOD, FIELD, PARAMETER })
 @Retention(RUNTIME)
 @InjectAnnotation
 @Source("valuemap")
diff --git a/src/main/java/org/apache/sling/models/annotations/injectorspecific/package-info.java b/src/main/java/org/apache/sling/models/annotations/injectorspecific/package-info.java
index da4fcdb..52eee68 100644
--- a/src/main/java/org/apache/sling/models/annotations/injectorspecific/package-info.java
+++ b/src/main/java/org/apache/sling/models/annotations/injectorspecific/package-info.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.0.0")
+@Version("1.0.2")
 package org.apache.sling.models.annotations.injectorspecific;
 
 import aQute.bnd.annotation.Version;
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/models/annotations/package-info.java b/src/main/java/org/apache/sling/models/annotations/package-info.java
index 1413f05..59b91d4 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.1.0")
+@Version("1.1.2")
 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/spi/AcceptsNullName.java b/src/main/java/org/apache/sling/models/spi/AcceptsNullName.java
new file mode 100644
index 0000000..3f0e80e
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/spi/AcceptsNullName.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+/**
+ * Marker interface for an injector to declare that it ignores the name
+ * parameter.
+ *
+ */
+public interface AcceptsNullName {
+}
diff --git a/src/main/java/org/apache/sling/models/spi/package-info.java b/src/main/java/org/apache/sling/models/spi/package-info.java
index e63fa96..93327e5 100644
--- a/src/main/java/org/apache/sling/models/spi/package-info.java
+++ b/src/main/java/org/apache/sling/models/spi/package-info.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-@Version("1.0.0")
+@Version("1.0.2")
 package org.apache.sling.models.spi;
 
 import aQute.bnd.annotation.Version;
\ No newline at end of file

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

[sling-org-apache-sling-models-api] 02/11: Updated to parent version 20

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e442e40fb61dca77d4d275cbf8950a1e85ac0a8e
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Aug 1 19:16:26 2014 +0000

    Updated to parent version 20
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1615208 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 1a6e515..193a756 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>19</version>
+        <version>20</version>
         <relativePath>../../../../parent/pom.xml</relativePath>
     </parent>
     

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

[sling-org-apache-sling-models-api] 10/11: [maven-release-plugin] prepare release org.apache.sling.models.api-1.1.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b542260157f887543e89f78ac8717c76aa93a828
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Sep 2 19:13:31 2014 +0000

    [maven-release-plugin] prepare release org.apache.sling.models.api-1.1.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api@1622098 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index fdc126f..4d86ae7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,13 +28,13 @@
     
     <artifactId>org.apache.sling.models.api</artifactId>
     <packaging>bundle</packaging>
-    <version>1.0.3-SNAPSHOT</version>
+    <version>1.1.0</version>
     <name>Apache Sling Models API</name>
     <description>Apache Sling Models API</description>
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api</connection>
-        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/api</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/api</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.api-1.1.0</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.api-1.1.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.models.api-1.1.0</url>
     </scm>
     <build>
         <plugins>

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

[sling-org-apache-sling-models-api] 11/11: [maven-release-plugin] copy for tag org.apache.sling.models.api-1.1.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a2bc972e0faedaeea1da9cd4477cdc970c2222a3
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Sep 2 19:13:34 2014 +0000

    [maven-release-plugin]  copy for tag org.apache.sling.models.api-1.1.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.api-1.1.0@1622099 13f79535-47bb-0310-9956-ffa450edef68

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