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

kwin pushed a commit to branch 
feature/document-resource-observation-property-types
in repository https://gitbox.apache.org/repos/asf/sling-site.git

commit 06ae0c88570cd411647445616be98d043ca9d818
Author: Konrad Windszus <[email protected]>
AuthorDate: Fri Mar 1 13:18:29 2024 +0100

    SLING-12247 Document Component Property Type for ResourceChangeListener
---
 .../documentation/the-sling-engine/resources.md    | 34 ++++++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/main/jbake/content/documentation/the-sling-engine/resources.md 
b/src/main/jbake/content/documentation/the-sling-engine/resources.md
index 3217f42e0..9eeee4f45 100644
--- a/src/main/jbake/content/documentation/the-sling-engine/resources.md
+++ b/src/main/jbake/content/documentation/the-sling-engine/resources.md
@@ -231,6 +231,34 @@ Property | Description
 
[ResourceChangeListener.CHANGES](https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/observation/ResourceChangeListener.html#CHANGES)|
 the type of changes you are interested in (optional)
 
[ResourceChangeListener.PROPERTY_NAMES_HINT](https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/observation/ResourceChangeListener.html#PROPERTY_NAMES_HINT)|
 filter only for events affecting the properties with the given names (optional)
 
+#### OSGi Component Property Type
+
+In order to ease creating `ResourceChangeListener`s, there is an according 
[OSGi component property 
type](https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#service.component-component.property.types)
 provided through artifact
+
+    <groupId>org.apache.sling</groupId>
+    <artifactId>org.apache.sling.resource.observation.annotations</artifactId>
+
+It can be used like this:
+
+    ::java
+    import org.apache.sling.api.resource.observation.ResourceChange;
+    import org.apache.sling.api.resource.observation.ResourceChange.ChangeType;
+    import org.apache.sling.api.resource.observation.ResourceChangeListener;
+    import org.osgi.service.component.annotations.Component;
+    
+    @Component
+    @SlingResourceChangeListener(
+            paths = "/examplepath",
+            change_types = {ChangeType.ADDED, ChangeType.REMOVED})
+    public class SampleResourceChangeListener implements 
ResourceChangeListener {
+    
+        @Override
+        public void onChange(List<ResourceChange> changes) {
+            // Do nothing here
+        }
+    }
+
+This will generate the necessary service properties automatically (with the 
help of the Bnd plugin, compare with [Sling Servlet 
Annotations](./servlets.html#registering-a-servlet-using-java-annotations)).
 
 ### OSGi Event based resource changes (deprecated)
 
@@ -247,9 +275,9 @@ This approach is deprecated in favor of the 
ResourceChangeListener described abo
 The Sling API provides an easy way to wrap or decorate a resource before 
returning. Details see [Wrap or Decorate 
Resources](/documentation/the-sling-engine/wrap-or-decorate-resources.html).
 
 
-  [1]: 
http://sling.apache.org/apidocs/sling8/org/apache/sling/api/resource/ResourceMetadata.html
-  [2]: 
http://sling.apache.org/apidocs/sling8/org/apache/sling/api/resource/Resource.html
-  [3]: 
http://sling.apache.org/apidocs/sling8/org/apache/sling/api/resource/AbstractResource.html
+  [1]: 
https://sling.apache.org/apidocs/sling12/org/apache/sling/api/resource/ResourceMetadata.html
+  [2]: 
https://sling.apache.org/apidocs/sling12/org/apache/sling/api/resource/Resource.html
+  [3]: 
https://sling.apache.org/apidocs/sling12/org/apache/sling/api/resource/AbstractResource.html
   [4]: 
https://github.com/apache/sling-org-apache-sling-launchpad-test-services/tree/master/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider
   [5]: 
https://github.com/apache/sling-org-apache-sling-launchpad-test-services/blob/master/src/main/java/org/apache/sling/launchpad/testservices/serversidetests/WriteableResourcesTest.java
   [6]: 
https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/java/org/apache/sling/api/resource/observation/ResourceChangeListener.java

Reply via email to