hivemind-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean-Francois Poilpret" <>
Subject RE: Using Hivemind to wrap a transaction around a request
Date Wed, 05 Dec 2007 13:09:38 GMT
Hi Kaspar,

I think you'd rather take a look at HiveMind interceptors rather than
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 ( 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).



-----Original Message-----
From: Kaspar Fischer [] 
Sent: Wednesday, December 05, 2007 7:32 PM
Subject: Using Hivemind to wrap a transaction around a request

[Note: This is a cross-post; I have initially posted to the list but I guess the issue is more related to  
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,

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  
  instead of a commit?

I am new to Hivemind, so please excuse these rather simple questions.

Many thanks for you patience!

Here's my configuration:

   <invoke-factory service-id="AlfrescoTransactionFactory"  
model="threaded" />
id="AlfrescoTransactionFactory" parameters-occurs="none">
class="" />

Here is my factory:

public class AlfrescoTransactionFactory implements  
ServiceImplementationFactory, Discardable {

   public Object createCoreServiceImplementation 
(ServiceImplementationFactoryParameters factoryParameters)
     System.err.println("createCoreServiceImplementation"); // gets  
     UserTransaction transaction;
     ServiceRegistry serviceRegistry;
     try {
       transaction =  
       serviceRegistry =  
     catch (Exception e) {
       throw new ApplicationRuntimeException("Could not create an  
Alfresco transactoin.", e);
     return new AlfrescoTransactionContextImpl(transaction,  

   public void threadDidDiscardService()
     System.err.println("threadDidDiscardService"); // never called!
     // ... end the transaction here (todo)

View raw message