KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > net > axis > server > TransactionRequestHandler


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 // $Id: TransactionRequestHandler.java,v 1.5.6.1 2005/03/02 14:19:51 tdiesler Exp $
9

10 package org.jboss.net.axis.server;
11
12 import org.jboss.axis.AxisFault;
13 import org.jboss.axis.MessageContext;
14
15 import javax.transaction.NotSupportedException JavaDoc;
16 import javax.transaction.Status JavaDoc;
17 import javax.transaction.SystemException JavaDoc;
18
19 /**
20  * This handler is to create an artifical "client"-side transaction
21  * around the web-service request. Useful for interacting with entity beans.
22  * It should be complemented by a seperate
23  * <code>org.jboss.net.axis.server.TransactionResponseHandler</code>
24  * in the response chain to finish the transaction.
25  * <br>
26  * <h3>Change notes</h3>
27  * <ul>
28  * </ul>
29  * @created 22.03.2002
30  * @author <a HREF="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>
31  * @version $Revision: 1.5.6.1 $
32  */

33
34 public class TransactionRequestHandler extends TransactionResponseHandler
35 {
36
37    protected static final Object JavaDoc MARKER = new Object JavaDoc();
38
39    public TransactionRequestHandler() throws Exception JavaDoc
40    {
41    }
42
43    //
44
// API
45
//
46

47    /**
48     * begins a new transaction if not yet started
49     * @see Handler#invoke(MessageContext)
50     */

51    public void invoke(MessageContext msgContext) throws AxisFault
52    {
53       try
54       {
55          if (userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION
56                  && msgContext.getProperty(Constants.TRANSACTION_PROPERTY) == null)
57          {
58             userTransaction.begin();
59             msgContext.setProperty(Constants.TRANSACTION_PROPERTY, MARKER);
60          }
61       }
62       catch (SystemException JavaDoc e)
63       {
64          throw new AxisFault("Could not analyze tx setting.", e);
65       }
66       catch (NotSupportedException JavaDoc e)
67       {
68          throw new AxisFault("Could not begin tx.", e);
69       }
70    }
71 }
72
Popular Tags