View Javadoc

1   /*
2    * Copyright 2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   *  
16   */
17  package org.apache.kandula.initiator;
18  
19  import org.apache.axiom.soap.SOAPHeader;
20  import org.apache.axis2.AxisFault;
21  import org.apache.axis2.context.MessageContext;
22  import org.apache.axis2.handlers.AbstractHandler;
23  import org.apache.kandula.Constants;
24  import org.apache.kandula.context.AbstractContext;
25  import org.apache.kandula.context.CoordinationContext;
26  import org.apache.kandula.faults.AbstractKandulaException;
27  
28  public class TransactionOutHandler extends AbstractHandler {
29  
30  	private static final long serialVersionUID = 4133392345837905499L;
31  
32  	public void invoke(MessageContext msgContext) throws AxisFault {
33  
34  		AbstractContext context;
35  		try {
36  			String wsaAction = msgContext.getWSAAction();
37  			if ((wsaAction != Constants.WS_COOR_CREATE_COORDINATIONCONTEXT)
38  					&& (wsaAction != Constants.WS_COOR_REGISTER)
39  					&& (wsaAction != Constants.WS_AT_COMMIT)
40  					&& (wsaAction != Constants.WS_AT_ROLLBACK)) {
41  				context = TransactionManager.getTransaction();
42  				SOAPHeader soapHeader = msgContext.getEnvelope().getHeader();
43  				CoordinationContext coorContext = context
44  						.getCoordinationContext();
45  				soapHeader.addChild(coorContext.toOM());
46  			}
47  		} catch (AbstractKandulaException e) {
48  			throw new AxisFault(e);
49  		}
50  	}
51  }