[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    Using Hivemind to wrap a transaction around a request
From:       Kaspar Fischer <fischerk () inf ! ethz ! ch>
Date:       2007-11-30 20:42:20
Message-ID: C9E78DBA-A6C6-4E23-81A6-1A60499C5408 () inf ! ethz ! ch
[Download RAW message or body]

Hi list,

I need to wrap "begin transaction" and "end transaction" actions around
a request cycle. 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 closed (committed)?

More precisely,

* What method is called on the object created by the factory when it
   is discarded? It is threadDidDiscardService(), right?

* Using a model="threaded" approach as I am doing, when exactly does
   a thread end in Tapestry? It seems I am wrong in assuming that the
   thread handles the request cycle and is then cleaned/ended!

* How can I catch exceptions so that I can do a rollback instead of
   a commit?

Many thanks,
Kaspar

--  

Here's my configuration:

  <service-point  
interface="org.my.tapestry.alfresco.AlfrescoTransactionContext"  
id="alfrescoContext">
   <invoke-factory service-id="AlfrescoTransactionFactory"  
model="threaded" />
  </service-point>
  <service-point  
interface="org.apache.hivemind.ServiceImplementationFactory"  
id="AlfrescoTransactionFactory" parameters-occurs="none">
   <create-instance  
class="org.my.tapestry.alfresco.AlfrescoTransactionFactory" />
  </service-point>

Here is my facory:

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!
   }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic