Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 97128 invoked from network); 18 May 2007 05:25:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 May 2007 05:25:02 -0000 Received: (qmail 74069 invoked by uid 500); 18 May 2007 05:25:07 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 74041 invoked by uid 500); 18 May 2007 05:25:07 -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 74032 invoked by uid 99); 18 May 2007 05:25:07 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 May 2007 22:25:07 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [192.18.19.6] (HELO sineb-mail-1.sun.com) (192.18.19.6) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 May 2007 22:25:00 -0700 Received: from fe-apac-06.sun.com (fe-apac-06.sun.com [192.18.19.177] (may be forged)) by sineb-mail-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l4I5Obre022325 for ; Fri, 18 May 2007 05:24:38 GMT Received: from conversion-daemon.mail-apac.sun.com by mail-apac.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) id <0JI8009011MNCP00@mail-apac.sun.com> (original mail from Ruchi.Goel@Sun.COM) for dev@jackrabbit.apache.org; Fri, 18 May 2007 13:24:37 +0800 (SGT) Received: from [129.158.227.83] by mail-apac.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPSA id <0JI8007GY1OY6Y4Q@mail-apac.sun.com>; Fri, 18 May 2007 13:24:34 +0800 (SGT) Date: Fri, 18 May 2007 10:54:35 +0530 From: ruchi goel Subject: Re: storing PersistenceManager in httpSession ( jcr mapping layer) In-reply-to: Sender: Ruchi.Goel@Sun.COM To: dev@jackrabbit.apache.org Cc: Christophe Lombart Message-id: <464D3893.8000801@sun.com> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_tqCzk94ZJkXNTt2n7e7D1g)" References: <464C5362.6060303@sun.com> User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) X-Virus-Checked: Checked by ClamAV on apache.org --Boundary_(ID_tqCzk94ZJkXNTt2n7e7D1g) Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT Please find it attatched. -Ruchi Alexandru Popescu ? wrote: > On 5/17/07, ruchi goel wrote: >> Hi, >> As per Jukka's proposal, it is a good idea to >> > > Can you provide a pointer to this? > >> * have repository as ServletContextAttribute within >> ServletContextListener >> * jcr session can be stored in httpSession >> >> >> If I am using jcr mapping layer (OCM) , I access jackrabbit via OCM's >> PersistenceManager which is something like >> >> new PersistenceManagerImpl(mapper, objectConverter, queryManager, >> jcrSession); >> >> >> Is it a good idea to have >> >> * mapper, objectConverter, queryManager set in ServletContext >> (after reading mapping files as context parameters) within >> ServletContextListener. >> * store persistenceManager in httpSession whenever jcrSession is >> added/modified , within HttpSessionAttributeListener . >> >> In the mapped java objects , persistencemanager can be retrieved from >> httpSession. > > Well, probably I should read firstly Jukka's proposal, but based on my > usual parallel with Hibernate Session/JPA EntityManager I don't think > this will really work mainly due to concurrent access, serialization > issues. > > ./alex > -- > .w( the_mindstorm )p. > >> Thanks, >> Ruchi >> >> --Boundary_(ID_tqCzk94ZJkXNTt2n7e7D1g) Content-type: message/rfc822; name="Proposal for managing JCR resources in webapps.eml" Return-path: Received: from fe-apac-05.sun.com ([192.18.19.176]) by sedge2-mail1.singapore.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTP id <0JI300CELRHU78E0@sedge2-mail1.singapore.sun.com> for rg149970@sedge2-mail1.Singapore.Sun.COM; Wed, 16 May 2007 05:53:54 +0800 (SGT) Received: from conversion-daemon.mail-apac.sun.com by mail-apac.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) id <0JI300B01RC53Y00@mail-apac.sun.com> for rg149970@sedge2-mail1.Singapore.Sun.COM (ORCPT Ruchi.Goel@sun.com); Wed, 16 May 2007 05:53:54 +0800 (SGT) Received: from phys-sedge2-1.singapore.sun.com ([129.158.123.14]) by mail-apac.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTP id <0JI300FJCRHUWQD6@mail-apac.sun.com> for rg149970@sedge2-mail1.Singapore.Sun.COM (ORCPT Ruchi.Goel@sun.com); Wed, 16 May 2007 05:53:54 +0800 (SGT) Received: from dm-india-01.singapore.sun.com ([129.158.71.103]) by sedge2-mail1.singapore.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTP id <0JI300C6WRHT7DE0@sedge2-mail1.singapore.sun.com> for rg149970@sedge2-mail1.Singapore.Sun.COM (ORCPT Ruchi.Goel@sun.com); Wed, 16 May 2007 05:53:54 +0800 (SGT) Received: from sunmail4.Singapore.Sun.COM (sunmail4 [129.158.71.19]) by dm-india-01.singapore.sun.com (8.13.4+Sun/8.13.3/ENSMAIL,v2.2) with ESMTP id l4FLrrM5003558 for ; Wed, 16 May 2007 05:53:53 +0800 (SGT) Received: from nwk-avmta-1.SFBay.Sun.COM (nwk-avmta-1.SFBay.Sun.COM [129.146.11.74]) by sunmail4.Singapore.Sun.COM (8.13.4+Sun/8.13.3/ENSMAIL,v2.2) with ESMTP id l4FLrmmk003329 for <@sunmail2sca.sfbay.sun.com:Ruchi.Goel@sun.com>; Wed, 16 May 2007 05:53:53 +0800 (SGT) Received: from pmxchannel-daemon.nwk-avmta-1.sfbay.Sun.COM by nwk-avmta-1.sfbay.Sun.COM (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005)) id <0JI300A05RHRQD00@nwk-avmta-1.sfbay.Sun.COM> for Ruchi.Goel@sun.com (ORCPT Ruchi.Goel@sun.com); Tue, 15 May 2007 14:53:51 -0700 (PDT) Received: from sca-ea-mail-2.sun.com ([192.18.43.25]) by nwk-avmta-1.sfbay.Sun.COM (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005)) with ESMTP id <0JI300HCPRHQQ280@nwk-avmta-1.sfbay.Sun.COM> for Ruchi.Goel@sun.com (ORCPT Ruchi.Goel@sun.com); Tue, 15 May 2007 14:53:50 -0700 (PDT) Received: from relay23.sun.com (relay23.sun.com [192.12.251.54] (may be forged)) by sca-ea-mail-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id l4FLroEf020046 for ; Tue, 15 May 2007 21:53:50 +0000 (GMT) Received: from mms25es.sun.com ([150.143.232.94] [150.143.232.94]) by relay23.sun.com with ESMTP id BT-MMP-17832 for Ruchi.Goel@sun.com; Tue, 15 May 2007 21:53:49 +0000 (Z) Received: from relay22.sun.com (relay22.sun.com [192.12.251.34]) by mms25es.sun.com with ESMTP id BT-MMP-103195 for Ruchi.Goel@sun.com; Tue, 15 May 2007 21:53:49 +0000 (Z) Received: from mail.apache.org ([140.211.11.2] [140.211.11.2]) by relay22.sun.com id BT-MMP-150492 for Ruchi.Goel@sun.com; Tue, 15 May 2007 21:53:49 +0000 (Z) Received: (qmail 107 invoked by uid 500); Tue, 15 May 2007 21:53:55 +0000 Received: (qmail 99992 invoked by uid 99); Tue, 15 May 2007 21:53:55 +0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 May 2007 14:53:55 -0700 Received: from [66.249.82.232] (HELO wx-out-0506.google.com) (66.249.82.232) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 May 2007 14:53:48 -0700 Received: by wx-out-0506.google.com with SMTP id i28so1982167wxd for ; Tue, 15 May 2007 14:53:27 -0700 (PDT) Received: by 10.90.75.10 with SMTP id x10mr7011751aga.1179266006907; Tue, 15 May 2007 14:53:26 -0700 (PDT) Received: by 10.100.163.1 with HTTP; Tue, 15 May 2007 14:53:26 -0700 (PDT) Date: Wed, 16 May 2007 00:53:26 +0300 From: Jukka Zitting Subject: Proposal for managing JCR resources in webapps Sender: dev-return-11996-Ruchi.Goel=sun.com@jackrabbit.apache.org To: dev@jackrabbit.apache.org Reply-to: dev@jackrabbit.apache.org Message-id: <510143ac0705151453t7a0eb4cam859a40fb106e81f5@mail.gmail.com> X-Envelope-from: Ruchi.Goel@Sun.COM X-Envelope-to: christophe.lombart@gmail.com, dev@jackrabbit.apache.org MIME-version: 1.0 Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7BIT Content-disposition: inline Precedence: bulk Delivered-to: mailing list dev@jackrabbit.apache.org Received-SPF: pass (herse.apache.org: domain of jukka.zitting@gmail.com designates 66.249.82.232 as permitted sender) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=tp6MK5m1XBAt8rjM0sCqSqyIj6qf4+aiY3yVwE349PpGl0Fp0G4IV9XgcRZApWhDFp+45mtpelX5MXowqBTyoDM6BpeI18wXyFtipxMtQt9/jwsk6rpp6YBqn51142PE0Mm3YuWcnAsRA+MZ8/0YYOuBgYbVmBvG4jt78uHwGL8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=RavAbACDxZZXf4E0PxyRTjivTlVe7YZoZYaPbHIlEXH0688UXKOga16CgbReDdEmgJ/UP9izFPJmoy/uzGnSYybQoN6Vv4X6Q2Smv7jctRWoVZbO9MAsLRGgUuoogypymUQK14hCYer5tLc8BNe4q4wl4r2CfZ7oDkNSGEgR73A= X-PMX-Version: 5.2.0.264296 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org X-Virus-Checked: Checked by ClamAV on apache.org Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm List-Post: List-Unsubscribe: List-Help: List-Id: Original-recipient: rfc822;Ruchi.Goel@sun.com Hi, I must confess that I don't really like the RepositoryStartupServlet and RepositoryAccessServlet mechanisms we currently have in jackrabbit-webapp. The classes are complex and correctly configuring them is non-trivial. To simplify things I propose an alternative approach to managing JCR resources (Repositories, Sessions, Items, etc.) in webapps, including the jackrabbit-webapp. The proposal is based on using the standard servlet scope and attribute model for managing JCR resources. The JCR repository used by a webapp would be placed in the servlet context as the "javax.jcr.Repository" attribute. If a webapp uses multiple repositories, they can be managed as "javax.jcr.Repository." attributes. A JCR session would typically be managed as the "javax.jcr.Session" attribute of a servlet session or a request. The canonical code to access the repository would be something like this: String name = getInitParameter(Repository.class.getName()); if (name == null) { name = Repository.class.getName(); } Repository repository = getServletContext().getAttribute(name); Using the standard attribute model allows nice separation of concerns and plays very well with various tools available in the servlet environment. For example I could implement the Repository startup or lookup code as a ServletContextListener that manages the repository lifecycle. Separate ServletContextAttributeListeners could be used to optionally expose the repository instance through RMI or JNDI. I could also easily mix and match things, for example to configure a ServetContextAttributeListener that automatically provides a decorated version of the repository as a separate attribute, which could again be further processed by other attribute listeners or servlets. The same options also apply to JCR sessions on a servlet session or request level. A typical approach could be to use a session or request listener or a filter to associate a JCR session with the processing of a request. The servlet or JSP page that ends up processing the request can simply look up the respective attribute to get the JCR session. What this would mean for jackrabbit-webapp? First I would move the RMI and JNDI binding code from RepositoryStartupServlet into separate ServletContextAttributeListeners. Then I would replace the RepositoryStartupServlet dependencies in the other serlets like SimpleWebdavServlet with the standard servlet context attributes. Finally I'd split the configuration part of the RepositoryStartupServlet into a separate class and perhaps turn the remaining RepositoryStartupServlet code into a ServletContext(Attribute)Listener class. BR, Jukka Zitting --Boundary_(ID_tqCzk94ZJkXNTt2n7e7D1g)--