Interface ResourceChangeListener
-
- All Known Implementing Classes:
IdMapService
@ConsumerType public interface ResourceChangeListener
Listener for resource change events.ResourceChangeListener
objects are registered with the Framework service registry and are notified withResourceChange
objects when a change occurs.ResourceChangeListener
objects can inspect the receivedResourceChange
objects to determine the type of change, location and other properties.ResourceChangeListener
objects must be registered with a service propertyPATHS
whose value is the list of resource paths for which the listener is interested in getting change events.By default a resource listener gets only local events which means events caused by changes persisted on the same instance as this listener is registered. If the resource listener is interested in external events, the implementation should implement the
ExternalResourceChangeListener
interface, but still register the service as aResourceChangeListener
service.- Since:
- 1.0.0 (Sling API Bundle 2.11.0)
-
-
Field Summary
Fields Modifier and Type Field Description static String
CHANGE_ADDED
String constant forResourceChange.ChangeType.ADDED
.static String
CHANGE_CHANGED
String constant forResourceChange.ChangeType.CHANGED
.static String
CHANGE_PROVIDER_ADDED
String constant forResourceChange.ChangeType.PROVIDER_ADDED
.static String
CHANGE_PROVIDER_REMOVED
String constant forResourceChange.ChangeType.PROVIDER_REMOVED
.static String
CHANGE_REMOVED
String constant forResourceChange.ChangeType.REMOVED
.static String
CHANGES
Array of change types - optional.static String
PATHS
Array of paths or glob patterns - required.static String
PROPERTY_NAMES_HINT
An optional hint indicating to the underlying implementation that for changes regarding properties (added/removed/changed) the listener is only interested in those property names listed inhere.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
onChange(@NotNull List<ResourceChange> changes)
Report resource changes based on the filter properties of this listener.
-
-
-
Field Detail
-
PATHS
static final String PATHS
Array of paths or glob patterns - required.
A path is either absolute or relative. If it's a relative path, the relative path will be appended to all search paths of the resource resolver.
If the whole tree of all search paths should be observed, the special value
.
should be used.A glob pattern must start with the
glob:
prefix (e.g.glob:**/*.html
). The following rules are used to interpret glob patterns:- The
*
character matches zero or more characters of a name component without crossing directory boundaries. - The
**
characters match zero or more characters crossing directory boundaries. - If the pattern is relative (does not start with a slash), the relative path will be appended to all search paths of the resource resolver.
In general, it can't be guaranteed that the underlying implementation of the resources will send a remove event for each removed resource. For example if the root of a tree, like
/foo
is removed, the underlying implementation might only send a single remove event for/foo
but not for any child resources. Therefore if a listener is interested in resource remove events, it might get remove events for resources that not directly match the specified pattern/filters. For example if a listener is registered for/foo/bar
and/foo
is removed, the listener will get a remove event for/foo
. The same is true if any pattern is used and any parent of a matching resource is removed. If a listener is interested in remove events, it will get a remove of any parent resource from the specified paths or patterns. The listener must handle these events accordingly.If one of the paths is a sub resource of another specified path, the sub path is ignored.
If this property is missing or invalid, the listener is ignored. The type of the property must either be String, or a String array.
- See Also:
- Constant Field Values
- The
-
CHANGES
static final String CHANGES
Array of change types - optional. If this property is missing, added, removed and changed events for resources and added and removed events for resource providers are reported. If this property is invalid, the listener is ignored. The type of the property must either be String, or a String array. Valid values are the constants from this class whose names are starting withCHANGE_
. They map to one of the values ofResourceChange.ChangeType
.- See Also:
- Constant Field Values
-
CHANGE_ADDED
static final String CHANGE_ADDED
String constant forResourceChange.ChangeType.ADDED
.- Since:
- 1.3.0 (Sling API Bundle 2.23.0)
- See Also:
- Constant Field Values
-
CHANGE_REMOVED
static final String CHANGE_REMOVED
String constant forResourceChange.ChangeType.REMOVED
.- Since:
- 1.3.0 (Sling API Bundle 2.23.0)
- See Also:
- Constant Field Values
-
CHANGE_CHANGED
static final String CHANGE_CHANGED
String constant forResourceChange.ChangeType.CHANGED
.- Since:
- 1.3.0 (Sling API Bundle 2.23.0)
- See Also:
- Constant Field Values
-
CHANGE_PROVIDER_ADDED
static final String CHANGE_PROVIDER_ADDED
String constant forResourceChange.ChangeType.PROVIDER_ADDED
.- Since:
- 1.3.0 (Sling API Bundle 2.23.0)
- See Also:
- Constant Field Values
-
CHANGE_PROVIDER_REMOVED
static final String CHANGE_PROVIDER_REMOVED
String constant forResourceChange.ChangeType.PROVIDER_REMOVED
.- Since:
- 1.3.0 (Sling API Bundle 2.23.0)
- See Also:
- Constant Field Values
-
PROPERTY_NAMES_HINT
static final String PROPERTY_NAMES_HINT
An optional hint indicating to the underlying implementation that for changes regarding properties (added/removed/changed) the listener is only interested in those property names listed inhere. If the underlying implementation supports this, events for property names that are not enlisted here will not be delivered, however events concerning resources are not affected by this hint. This is only a hint, a change listener registering with this property must be prepared that the underlying implementation is not able to filter based on this property. In this case the listener gets all events as defined with the other properties.- See Also:
- Constant Field Values
-
-
Method Detail
-
onChange
void onChange(@NotNull @NotNull List<ResourceChange> changes)
Report resource changes based on the filter properties of this listener.Starting with version 1.2 of this API, an instance of
ResoureChangeList
is passed as the parameter to allow passing additional information.- Parameters:
changes
- The changes list. This list is immutable.
-
-