View Javadoc

1   /*
2    * Copyright  2004 The Apache Software Foundation.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of 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,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package org.apache.kandula.wscoor;
18  
19  import org.apache.axiom.om.OMElement;
20  import org.apache.axis2.AxisFault;
21  import org.apache.axis2.context.OperationContext;
22  import org.apache.axis2.wsdl.WSDLConstants;
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.storage.StorageFactory;
27  
28  /***
29   * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
30   */
31  
32  public class ActivationRequesterPortTypeRawXMLSkeleton {
33  	private OperationContext opContext;
34  
35  	public void setOperationContext(OperationContext opContext) {
36  		this.opContext = opContext;
37  	}
38  
39  	public OMElement createCoordinationContextResponseOperation(
40  			OMElement responseElement) throws AxisFault {
41  		OMElement response = responseElement.getFirstElement();
42  		if ("CoordinationContext".equals(response.getLocalName())) {
43  			OMElement header = opContext.getMessageContext(
44  					WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope()
45  					.getHeader();
46  			String requesterID = header.getFirstChildWithName(
47  					Constants.REQUESTER_ID_PARAMETER).getText();
48  			CoordinationContext coordinationContext = CoordinationContext.Factory
49  					.newContext(response);
50  			AbstractContext context = (AbstractContext) StorageFactory
51  					.getInstance().getInitiatorStore().get(requesterID);
52  			context.setCoordinationContext(coordinationContext);
53  		}
54  		return null;
55  	}
56  }