@ConsumerType
public interface ResourceChangeListener
ResourceChangeListener
objects are registered with the Framework service
registry and are notified with ResourceChange
objects when a
change occurs.
ResourceChangeListener
objects can inspect the received ResourceChange
objects to
determine the type of change, location and other properties.
ResourceChangeListener
objects must be registered with a service property
PATHS
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 a ResourceChangeListener
service.
Modifier and Type | Field and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
onChange(List<ResourceChange> changes)
Report resource changes based on the filter properties of this listener.
|
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:
*
character matches zero or more characters of a name component without crossing directory boundaries.**
characters match zero or more characters crossing directory boundaries.
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.
static final String CHANGES
ResourceChange.ChangeType
.static final String PROPERTY_NAMES_HINT
void onChange(@Nonnull List<ResourceChange> changes)
Starting with version 1.2 of this API, an instance of ResoureChangeList
is passed
as the parameter to allow passing additional information.
changes
- The changes list. This list is immutable.Copyright © 2017 The Apache Software Foundation. All rights reserved.