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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to