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:35 UTC

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

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>.