Return-Path: X-Original-To: apmail-jackrabbit-dev-archive@www.apache.org Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8545969A5 for ; Wed, 18 May 2011 21:06:50 +0000 (UTC) Received: (qmail 46169 invoked by uid 500); 18 May 2011 21:06:50 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 46128 invoked by uid 500); 18 May 2011 21:06:50 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 46121 invoked by uid 99); 18 May 2011 21:06:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2011 21:06:50 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mlrajesh@gmail.com designates 209.85.215.170 as permitted sender) Received: from [209.85.215.170] (HELO mail-ey0-f170.google.com) (209.85.215.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2011 21:06:45 +0000 Received: by eyf5 with SMTP id 5so1235516eyf.1 for ; Wed, 18 May 2011 14:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=n3IYDtDDidWrqyhKe8WibeVIJCz9qRBHb2LN1W6cZh8=; b=oUTe8xl91fA00HZZeVAj3Y/r3NG2TLnhaqipR2DMmF8mKGGIG1Alpeztb9siOQP49y 3k7f8UydiWMQLXlozADlWkOkL5tLdlWB5H6ZDddY5h3XpO102xCngBNznrr65xv/HXXw wEcnlv6dg6XRGQxIu8Kl6JvKlurc75naoRT4Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=XYf/em4TD8yd2+x9NMeyxGiuARkFb9/H7EtruQj3vgY0EuOYfBk9I/JHceGhZj37sn 7kPKnzMmJ+GlcFZrtuEprVIINvi+oSWW8vr99xOGspTsmTI0QK81u5d/S0OPXNxusIcJ D7pAbS6FbAsU2sR8Dj3se8EE2TXTJEh2XZKwo= MIME-Version: 1.0 Received: by 10.14.49.210 with SMTP id x58mr838803eeb.12.1305752782658; Wed, 18 May 2011 14:06:22 -0700 (PDT) Received: by 10.14.47.74 with HTTP; Wed, 18 May 2011 14:06:22 -0700 (PDT) In-Reply-To: References: <1305744920849-3533604.post@n4.nabble.com> Date: Wed, 18 May 2011 14:06:22 -0700 Message-ID: Subject: Re: How to get a Repository objector jcrSession from a Java Class From: Rajesh Muguda To: dev@jackrabbit.apache.org Content-Type: multipart/alternative; boundary=0023543a27b8c65d2f04a393420b --0023543a27b8c65d2f04a393420b Content-Type: text/plain; charset=ISO-8859-1 Well you could use the JCR API's by having those libraries in your path. Repository repository = JcrUtils.getRepository("jndi://com.day.util.jndi.provider.MemoryInitialContextFactory/crx"); SimpleCredentials creds = new SimpleCredentials("admin", "admin".toCharArray()); Session slingsession = repository.login(creds, "crx.default"); you can refer the jackrabbit api for more details. Thanks Rajesh On Wed, May 18, 2011 at 12:51 PM, Alexander Klimetschek wrote: > On 18.05.11 20:55, "davidjgonzalez" wrote: > >http://pastie.org/1923026 > > > new RepoTest().isNull() > > > SCR handled components are created by the framework, you can't use a > normal constructor. To get it, either reference from another component > (such as a servlet for example) using @Reference / @scr.reference, or use > sling.getService() in JSPs for example. But that depends on the context - > if it's a true background service (you are using immediate=true, > indicating that), it might just run for itself. > > Regards, > Alex > > -- > Alexander Klimetschek > Developer // Adobe (Day) // Berlin - Basel > > > > > --0023543a27b8c65d2f04a393420b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Well you could use the JCR API's by having those libraries in your path= .

=A0Repository repository =3D JcrUtils.getRepository("jndi://c= om.day.util.jndi.provider.MemoryInitialContextFactory/crx");
=A0=A0= =A0 SimpleCredentials creds =3D
=A0=A0 new SimpleCredentials("admin", "admin".toCharArr= ay());
=A0=A0 Session slingsession =3D repository.login(creds, "crx= .default");

you can refer the jackrabbit api for more details.<= br>
Thanks
Rajesh

On Wed, May 18, 2011 at = 12:51 PM, Alexander Klimetschek <aklimets@adobe.com> wrote:
On 18.05.11 20:55, "davidjgonzalez" <davidjgonzalez@gmail.com> wrote:
>http://pastie.o= rg/1923026

> new RepoTest().isNull()


SCR handled components are created by the framework, you can't use a normal constructor. To get it, either reference from another component
(such as a servlet for example) using @Reference / @scr.reference, or use sling.getService() in JSPs for example. But that depends on the context - if it's a true background service (you are using immediate=3Dtrue,
indicating that), it might just run for itself.

Regards,
Alex

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





--0023543a27b8c65d2f04a393420b--