jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@adobe.com>
Subject Re: How to get a Repository objector jcrSession from a Java Class
Date Wed, 18 May 2011 17:59:10 GMT
On 18.05.11 19:45, "davidjgonzalez" <davidjgonzalez@gmail.com> wrote:
>How can I get either a valid SlingRepository object or JCRSession from
>within a standard Java class?
>
>This Java Class may not have access to a SlingHttpRequest object. The JCR
>Session would need to be that of the admin instance.
>
>Can someone provide a short code snippet or point me to documenation on
>how
>to do this?

I think this question is rather something for the sling users mailing list.

To give a short answer: in Sling, you'd typically have a OSGi component or
service for such a background (non-request-handling) use case, which can
use SCR annotations to get a reference to the SlingRepository service:

@Reference
private SlingRepository repository;

Regards,
Alex

-- 
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel





Mime
View raw message