commit | df7565ce9df43b5f25aaa9cba265661700589f84 | [log] [tgz] |
---|---|---|
author | Oliver Lietz <olli@apache.org> | Tue Mar 21 10:58:17 2017 +0000 |
committer | Oliver Lietz <olli@apache.org> | Tue Mar 21 10:58:17 2017 +0000 |
tree | 4338a52ab0a01df8758476a53379af0f697686f1 | |
parent | bd7e7f189a8de09da5b13fa0d0a2a918e5867411 [diff] |
SLING-6677 Add documentation for Resource Presence add README git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1787936 13f79535-47bb-0310-9956-ffa450edef68
This module allows presentation of Resource
s as OSGi services and comes with a simple presenter and presence.
Configure a service user mapping for org.apache.sling.resource.presence
to allow reading resources, using e.g. service user sling-readall
.
Configure a presenter to observe a resource by path, e.g. path=/apps
Whenever resource /apps
is available the presenter will register an OSGi service for it and unregisters the service whenever /apps
gets removed.
You can depend on that service now, e.g. using a @Reference
annotation on your component:
@Reference( target = "(path=/apps)" ) private ResourcePresence apps;
When running tests with resources involved, you can use a resource presence to delay test execution until required resources are available.
@Inject @Filter(value = "(path=/apps)") private ResourcePresence apps; @Configuration public Option[] configuration() { return new Option[]{ [...], factoryConfiguration("org.apache.sling.resource.presence.internal.ResourcePresenter") .put("path", "/apps") .asOption() }; } @Test public void testApps() { assertThat(apps.getPath(), is("/apps")); }