Hi ,
we are using this to sync user profiles. FYI below is the similar parts of code snippets how we used distributor.
1)
@Component(
service = ResourceChangeListener.class,
property = {
ResourceChangeListener.PATHS + "=glob:/home/users/**/profile",
ResourceChangeListener.CHANGES + "=ADDED",
ResourceChangeListener.CHANGES + "=CHANGED"
}
)
2)@Reference
private Distributor distributor;
3)
public void onChange(@Nonnull List<ResourceChange> changes) {
if (publish) {
for (final ResourceChange change : changes) {
ResourceResolver resolver = null;
try {
resolver = resourceResolverFactory
.getServiceResourceResolver(OsgiUtils.getAuthInfoMap(UserDistributionEventHandler.class));
DistributionRequest request = new SimpleDistributionRequest(DistributionRequestType.ADD, change.getPath());
DistributionResponse response = distributor.distribute("user-agent", resolver, request);
log.debug(response.getMessage() + " - " + response.getState());
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
if (resolver != null && resolver.isLive()) {
resolver.close();
}
}
}
}
}
In 6.3 it was available in uber jar itself. now in 6.5/6.5.2 its no longer available. Even after adding below dependency imports related to sling distribution is resolved but bundle is in installed state saying missing requirement [**bundle name**** [615](R 615.0)] osgi.wiring.package; (&(osgi.wiring.package=org.apache.sling.distribution)(version>=0.3.0)(!(version>=1.0.0)))
<dependency>
<artifactId>org.apache.sling.distribution.api</artifactId>
<version>0.3.0</version>
<groupId>org.apache.sling</groupId>
<scope>provided</scope>
</dependency>