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 <[email protected]>
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
"[email protected]" <[email protected]>.

Reply via email to