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

joerghoh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-api.git


The following commit(s) were added to refs/heads/master by this push:
     new 15e61d7  SLING-10895 add getPropertyMap() method (#39)
15e61d7 is described below

commit 15e61d7269e3620a82f9d8f63c7ca71fea9bc961
Author: Jörg Hoh <[email protected]>
AuthorDate: Fri Nov 5 13:06:43 2021 +0100

    SLING-10895 add getPropertyMap() method (#39)
    
    * SLING-10895 add getPropertyMap() method
    
    Co-authored-by: Carsten Ziegeler <[email protected]>
    Co-authored-by: Konrad Windszus <[email protected]>
---
 .../sling/api/resource/ResourceResolver.java       | 22 ++++++++++++++++++++++
 .../api/wrappers/ResourceResolverWrapper.java      |  5 +++++
 2 files changed, 27 insertions(+)

diff --git a/src/main/java/org/apache/sling/api/resource/ResourceResolver.java 
b/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
index b80d25a..9b03431 100644
--- a/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
+++ b/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
@@ -607,8 +607,14 @@ public interface ResourceResolver extends Adaptable, 
Closeable {
      * which was used to create this resolver is no longer active or
      * any of the used resource providers is no longer active.
      *
+     * All objects in the map maintained by {@link #getPropertyMap()} 
implementing
+     * the {@link #Closeable} interface, will be closed by calling {@code 
close()} on each of them.
+     * Any exception thrown by this call will be ignored. The order in which 
the objects are
+     * closed is not defined.
+     *
      * @since 2.1 (Sling API Bundle 2.1.0)
      * @see ResourceResolver Resource Resolver (section lifecycle)
+     * @see #getPropertyMap()
      */
     @Override
     void close();
@@ -859,4 +865,20 @@ public interface ResourceResolver extends Adaptable, 
Closeable {
      */
     Resource move(final String srcAbsPath,
               final String destAbsPath) throws PersistenceException;
+
+    /**
+     * Returns a map to store temporary objects.
+     *
+     * This map is suited to store objects which share the same lifecycle as 
the
+     * resource resolver. The resource resolver itself does not use this map.
+     *
+     * The resource resolver will clear the map during {@link #close()}, so 
afterwards the map is empty.
+     * If a stored value implements the {@link #Closeable} interface, the 
ResourceResolver will invoke the
+     * <code>close()</code> of the value before clearing the map.
+     *
+     * @returns the property map
+     * @see #close()
+     * @since 2.13.0 (Sling API Bundle 2.24.0)
+     */
+    public @NotNull Map<String,Object> getPropertyMap();
 }
diff --git 
a/src/main/java/org/apache/sling/api/wrappers/ResourceResolverWrapper.java 
b/src/main/java/org/apache/sling/api/wrappers/ResourceResolverWrapper.java
index 500ec18..9fa46d4 100644
--- a/src/main/java/org/apache/sling/api/wrappers/ResourceResolverWrapper.java
+++ b/src/main/java/org/apache/sling/api/wrappers/ResourceResolverWrapper.java
@@ -348,6 +348,11 @@ public class ResourceResolverWrapper implements 
ResourceResolver {
     public Resource move(String srcAbsPath, String destAbsPath) throws 
PersistenceException {
         return ResourceResolverResourceWrapper.wrap(this, 
wrapped.move(srcAbsPath, destAbsPath));
     }
+    
+    @Override
+    public Map<String,Object> getPropertyMap() {
+        return wrapped.getPropertyMap();
+    }
 
     @Override
     public <AdapterType> AdapterType adaptTo(@NotNull Class<AdapterType> type) 
{

Reply via email to