Return-Path: X-Original-To: apmail-chemistry-dev-archive@www.apache.org Delivered-To: apmail-chemistry-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 48D0D6576 for ; Thu, 9 Jun 2011 09:01:52 +0000 (UTC) Received: (qmail 52842 invoked by uid 500); 9 Jun 2011 09:01:52 -0000 Delivered-To: apmail-chemistry-dev-archive@chemistry.apache.org Received: (qmail 52803 invoked by uid 500); 9 Jun 2011 09:01:51 -0000 Mailing-List: contact dev-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list dev@chemistry.apache.org Received: (qmail 52795 invoked by uid 99); 9 Jun 2011 09:01:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2011 09:01:51 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of florian.mueller@alfresco.com designates 207.126.144.119 as permitted sender) Received: from [207.126.144.119] (HELO eu1sys200aog105.obsmtp.com) (207.126.144.119) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 09 Jun 2011 09:01:45 +0000 Received: from zimbra.alfresco.com ([88.151.129.3]) by eu1sys200aob105.postini.com ([207.126.147.11]) with SMTP ID DSNKTfCL4jTNfd/f2XyQW6ueVFxVeZtBg00I@postini.com; Thu, 09 Jun 2011 09:01:24 UTC Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.alfresco.com (Postfix) with ESMTP id 8B80728C370 for ; Thu, 9 Jun 2011 10:01:19 +0100 (BST) X-Virus-Scanned: amavisd-new at unx-d-manc4.tc.ifeltd.com Received: from zimbra.alfresco.com ([127.0.0.1]) by localhost (zimbra.alfresco.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0SxgcYTGaKBt for ; Thu, 9 Jun 2011 10:01:19 +0100 (BST) Received: from Florian-Mullers-MacBook-Pro-2.local (unknown [194.75.202.169]) (Authenticated sender: florian.mueller) by zimbra.alfresco.com (Postfix) with ESMTP id 65D6428C36F for ; Thu, 9 Jun 2011 10:01:18 +0100 (BST) Message-ID: <4DF08BDD.8090701@alfresco.com> Date: Thu, 09 Jun 2011 10:01:17 +0100 From: =?ISO-8859-1?Q?Florian_M=FCller?= User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: dev@chemistry.apache.org Subject: Re: OpenCMIS: should Session extend Serializable? References: <1C39FC46-5696-4FF5-BAF6-45362974AF91@alfresco.com> <4DE75745.4010206@alfresco.com> <9CE042C9-2E89-4D32-BD98-54085E5AD28C@alfresco.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit +1 Florian On 08/06/2011 20:11, Peter Monks wrote: > Yeah, though it sounds like it would be rare that anyone would actually serialize / deserialize NuxeoSession's anyway (even if they were serializable), so that might allow some simplifying assumptions? > > Opening the discussion up to the wider audience - would anyone object if I were to raise an enhancement request for org.apache.chemistry.opencmis.client.api.Session to extend java.io.Serializable? > > Cheers, > Peter > > > On Jun 8, 2011, at 9:14 am, Florent Guillaume wrote: > >> Hi Peter, >> >> Yes that would probably work. >> The responsibility for who will be closing the connection when it's >> been restablished during deserialization is a bit muddy, but that's >> another concern. >> >> So if there's really a need to have Session be Serializable again, I >> won't vote against it. >> >> Florent >> >> >> On Wed, Jun 8, 2011 at 5:42 PM, Peter Monks wrote: >>> Thanks for the clarification Florent. >>> >>> Question for you - if Session was Serializable, couldn't org.nuxeo.ecm.core.opencmis.impl.client.NuxeoSession hold a transient reference to the non-serializable objects, with the "connection" re-estalished automatically post-deserialization? Presumably this would require some serialization of the session parameters, but generally speaking those are fairly small / lightweight. >>> >>> Cheers, >>> Peter >>> >>> >>> >>> On Jun 8, 2011, at 8:11 am, Florent Guillaume wrote: >>> >>>> Hi Peter, >>>> >>>> FYI, here's an example of non-Serializable Session implementation: >>>> Nuxeo plugins can use OpenCMIS APIs directly in same-JVM mode (without >>>> a networking layer being invoked), using >>>> org.nuxeo.ecm.core.opencmis.impl.client.NuxeoSession. This >>>> implementation of Session holds (indirectly) a reference to a >>>> non-Serializable low-level connection-like object (think >>>> java.sql.Connection), that by definition is not Serializable. >>>> >>>> Florent >>>> >>>> >>>> On Thu, Jun 2, 2011 at 9:21 PM, Peter Monks wrote: >>>>> Thanks Florian. I'm still a little confused though - if Session is not Serializable, how can I rely on an arbitrary Session implementation class being Serializable? What if someone configures my client to use one of these non-Chemistry Session implementations? >>>>> >>>>> Possible workarounds include: >>>>> Checking whether the implementation class is an instanceof Serializable, and not caching it if it isn't (which implies poor performance for Session implementations that aren't serializable) >>>>> Wrapping Session in a Serializable wrapper that has a transient reference to the Session (Session will be cached as long as it's kept in memory by the JVM - as soon as the cache serializes a Session for whatever reason, that Session will effectively become decached and incur the creation cost next time that user does something that requires CMIS) >>>>> >>>>> In the specific client I'm working on right now I can live with either workaround, but in general (and imho) they are both quite undesirable given that this is likely to be a common use case. I notice for example that the Liferay guys identified a need for Session caching in their "CMIS Document Library" implementation (see [1], in particular the comments). We can probably assume that either the Liferay cache doesn't require items to be Serializable, or they worked around it in something like one of the two ways described above. >>>>> >>>>> Thinking along different lines for a moment - why does creating a Session have to hit the CMIS server at all - is it to validate the username and password? If so, is it worth delaying that check until the first "real" CMIS call, thereby significantly reducing the cost of establishing a Session (i.e. by eliminating any RPCs to the CMIS server at Session creation time)? This could even be configured via a flag to the SessionFactory to preserve backwards compatibility. >>>>> >>>>> Cheers, >>>>> Peter >>>>> >>>>> [1] http://www.liferay.com/web/alexander.chow/blog/-/blogs/7670631 >>>>> >>>>> >>>>> >>>>> >>>>> On Jun 2, 2011, at 2:26 am, Florian M�ller wrote: >>>>> >>>>>> Hi Peter, >>>>>> >>>>>> We had some discussions about that in the past. There are actually other implementations of the OpenCMIS interfaces (not part of Apache Chemistry) that can not and need not be serializable. We don't want to force them to do something crazy just to implement the OpenCMIS interfaces. >>>>>> >>>>>> The OpenCMIS classes have been designed to be serializable from the start to support HTTP sessions. Casting to Serializable is safe now and will be safe in the future -- even though it might feel weird. >>>>>> >>>>>> What surprises me is that creating a session takes several seconds. Connecting to a Alfresco server on a local network takes about 100ms. If it takes significantly longer then there is something wrong... >>>>>> >>>>>> >>>>>> Florian >>>>>> >>>>>> >>>>>> On 01/06/2011 23:35, Peter Monks wrote: >>>>>>> G'day everyone, >>>>>>> >>>>>>> Creating an org.apache.chemistry.opencmis.client.api.Session is quite an expensive operation (it typically takes several seconds), so I'm looking to cache Session objects in a per-user cache in my client app so that I don't have to recreate Sessions for every single interaction with the CMIS server. >>>>>>> >>>>>>> Unfortunately the cache library I'm using requires that cached objects implement java.io.Serializable, which Session does not. However the default implementation class (org.apache.chemistry.opencmis.client.runtime.SessionImpl) does in fact implement Serializable, allowing me the workaround of casting the Session object to Serializable prior to adding to the cache. I'm not particularly comfortable with this approach however, given that this seems to be an implementation detail and not officially part of the contract for Sessions. >>>>>>> >>>>>>> Is there a compelling reason that Session doesn't implement Serializable? Is this something that could be added (noting that this change is backwards compatible)? >>>>>>> >>>>>>> Thanks in advance, >>>>>>> Peter >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Florent Guillaume, Director of R&D, Nuxeo >>>> Open Source, Java EE based, Enterprise Content Management (ECM) >>>> http://www.nuxeo.com http://www.nuxeo.org +33 1 40 33 79 87 >>> >>> >> >> >> >> -- >> Florent Guillaume, Director of R&D, Nuxeo >> Open Source, Java EE based, Enterprise Content Management (ECM) >> http://www.nuxeo.com http://www.nuxeo.org +33 1 40 33 79 87 >