Return-Path: Delivered-To: apmail-hivemind-user-archive@www.apache.org Received: (qmail 74310 invoked from network); 11 Dec 2007 17:40:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2007 17:40:03 -0000 Received: (qmail 6593 invoked by uid 500); 11 Dec 2007 17:39:51 -0000 Delivered-To: apmail-hivemind-user-archive@hivemind.apache.org Received: (qmail 6582 invoked by uid 500); 11 Dec 2007 17:39:51 -0000 Mailing-List: contact user-help@hivemind.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hivemind.apache.org Delivered-To: mailing list user@hivemind.apache.org Received: (qmail 6573 invoked by uid 99); 11 Dec 2007 17:39:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 09:39:51 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of aleboo@gmail.com designates 66.249.92.169 as permitted sender) Received: from [66.249.92.169] (HELO ug-out-1314.google.com) (66.249.92.169) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 17:39:27 +0000 Received: by ug-out-1314.google.com with SMTP id j3so338887ugf.49 for ; Tue, 11 Dec 2007 09:39:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=2R+h3D7lU3LgyN7d5EORJG4yXZ9IyI35vbH2skREkds=; b=XUcZcGBIbpnE94f0IZBZw3TkIwP0O4cSb7NZzeoHsXm/gZ3ZKL775ED9K6/4Rd+iKLaA1NeK+RdMnV5l1qkHa7QBFkBctIUB97Vbmidhc6AKkXJicN65n9hnr+UdeAam5q7cgq2OqWoFn4M451mnRjFHLOpZSONi4kTMObER8kA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=sGO0NujkUVCY7h7z1PoORi8TedzLpJFIJK0S0nZXuZoNbvea1XaiFqW9IDDFMsThKKtECbroiDlK4kbal86ODGMpXUWRdDVi/vmXKU9NMTqbNdeuOKFN+m/kGafRmi7hC/K9IXpAtO/B3OKu0k2CWt36IpQFyVNZBQMZU/3l/3o= Received: by 10.86.98.18 with SMTP id v18mr5289019fgb.1197394769151; Tue, 11 Dec 2007 09:39:29 -0800 (PST) Received: from ?213.164.110.153? ( [213.164.110.153]) by mx.google.com with ESMTPS id e11sm3324487fga.2007.12.11.09.39.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 11 Dec 2007 09:39:27 -0800 (PST) Message-ID: <475ED9BE.30008@gmail.com> Date: Tue, 11 Dec 2007 19:41:02 +0100 From: Alebu User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: user@hivemind.apache.org Subject: Re: Using Hivemind to wrap a transaction around a request References: <56C48B07-EE78-4EC0-9F3E-455D6E1B06E7@inf.ethz.ch> <000c01c83740$19e8c920$0301a8c0@VAIOSZ330> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Hi Kaspar, There is a tutorial on TSS about Hivemind by James Carman. http://www.theserverside.com/tt/articles/article.tss?l=HivemindBuzz And as example of interceptor there is a TransactionInterceptor. Perhaps it can help you to start your own solution. And dont be shy to ask help in mailing list. Hivemind is a great product but lack of documentation is most is thing about it, so others people help is very important. Kaspar Fischer wrote: > Dear Jean-Fran�ois, > > Thank you for your email. I think I get the basic idea of what you are > saying: > Tell Hivemind to put the "begin()" and "commit()" around the relevant > methods > of Tapestry (and make it call "rollback()" on uncaught exceptions). Is > this > correct, so far? > > One first uncertainty in this is what Tapestry method I should intercept? > It can't be around a single page-request as redirecting, rewinding, > etc. won't > work then. Do you happen to know what might be the right method? > > I've taken a look at HiveTranse and understand parts of it. However, I do > not know where to start -- obviously, I need to inject my own "begin()" > and "commit()" as I am neither running Hibernate, not JDBC, etc. > directly. > > Could you maybe provide a few directions on how to write my HiveMind > interceptor? > Maybe it's easier without HiveTranse first? > > I am sorry if my questions are very basic, and I imagine it's probably > boring > for you. I can promise that I will post a solution to the tapestry > list and > also extend the article I've written at the Alfresco Wiki: > > > http://wiki.alfresco.com/wiki/Alfresco_and_Tapestry_on_the_Same_Tomcat_Installation > > > With this, you're help will hopefully not just help me but others as > well. > > Best, > Kaspar > > On 05.12.2007, at 14:09, Jean-Francois Poilpret wrote: > >> Hi Kaspar, >> >> I think you'd rather take a look at HiveMind interceptors rather than >> factories. >> You can create an Interceptor that will be called before and after any >> method of another service. >> There are several ways to create interceptors in HiveMind, take a >> look at >> HiveMind website to see simple examples. >> >> If you want to see a real-life implementation of such a system you >> may take >> a look at hivetranse (http://hivetranse.sourceforge.net) which >> implements >> the same kind of behavior as you are looking for. I think you could >> quite >> easily adapt one of the numerous hivetranse interceptors (choose one >> -the >> simples- as an example). >> >> Cheers >> >> Jean-Francois >> >> -----Original Message----- >> From: Kaspar Fischer [mailto:fischerk@inf.ethz.ch] >> Sent: Wednesday, December 05, 2007 7:32 PM >> To: user@hivemind.apache.org >> Subject: Using Hivemind to wrap a transaction around a request >> >> [Note: This is a cross-post; I have initially posted to the list >> users@tapestry.apache.org but I guess the issue is more related to >> hivemind, >> so I post here.] >> >> Hi list, >> >> I need to wrap "begin transaction" and "end transaction" actions around >> a task (a Tapestry web request, actually). I've read about Hivemind, >> >> http://www.nabble.com/hivemind-factory-service-tf251931.html#a704856 >> >> and configured a service point (see below). This works very well: my >> transaction is created, but I cannot see when it is ended (committed/ >> rolled back). >> >> More precisely, I am struggling with: >> >> * What method is called on the object created by the factory when it >> is discarded? It is threadDidDiscardService(), right? >> >> * How can I catch exceptions from my actual task so that I can do a >> rollback >> instead of a commit? >> >> I am new to Hivemind, so please excuse these rather simple questions. >> >> Many thanks for you patience! >> Kaspar >> >> -- >> Here's my configuration: >> >> > interface="org.my.tapestry.alfresco.AlfrescoTransactionContext" >> id="alfrescoContext"> >> > model="threaded" /> >> >> > interface="org.apache.hivemind.ServiceImplementationFactory" >> id="AlfrescoTransactionFactory" parameters-occurs="none"> >> > class="org.my.tapestry.alfresco.AlfrescoTransactionFactory" /> >> >> >> Here is my factory: >> >> public class AlfrescoTransactionFactory implements >> ServiceImplementationFactory, Discardable { >> >> public Object createCoreServiceImplementation >> (ServiceImplementationFactoryParameters factoryParameters) >> { >> System.err.println("createCoreServiceImplementation"); // gets >> called! >> UserTransaction transaction; >> ServiceRegistry serviceRegistry; >> try { >> transaction = >> AlfrescoApplicationInitializer.createAndBeginAuthenticatedTransaction >> (true); >> serviceRegistry = >> AlfrescoApplicationInitializer.getServiceRegistry(); >> } >> catch (Exception e) { >> throw new ApplicationRuntimeException("Could not create an >> Alfresco transactoin.", e); >> } >> return new AlfrescoTransactionContextImpl(transaction, >> serviceRegistry); >> } >> >> public void threadDidDiscardService() >> { >> System.err.println("threadDidDiscardService"); // never called! >> // ... end the transaction here (todo) >> } >> } >> > >