On Wed, Apr 22, 2009 at 4:26 PM, Carl Hall carl.h...@gmail.com wrote:
I've searched through docs but have yet to discover this though I'm
probably just overlooking something. What's the suggested way to
access data in a jcr repository when not coming from a user related
request (ie. when in an event listener)? Also, how do I get hold of
the observation manager to register my listener?
The o.a.s.jcr.api.SlingRepository interface [1] can be used for that
(it is simply an extension of the Repository interface). It is
directly available as OSGi service. With scr and annotations through
the maven scr plugin, this typically looks like this:
/** @scr.reference */
private SlingRepository repository;
To use it, simply work with standard JCR API calls:
Session session = repository.login(new SimpleCredentials(user, password));
or for handy admin-sessions (password is globally configured in the
SlingRepository service config):
Session adminSession = repository.loginAdministrative(null);
[1]
https://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/jcr/api/src/main/java/org/apache/sling/jcr/api/SlingRepository.java
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetsc...@day.com