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.coordinator.at;
18  
19  import org.apache.axis2.addressing.EndpointReference;
20  import org.apache.kandula.Constants;
21  import org.apache.kandula.context.AbstractContext;
22  import org.apache.kandula.context.impl.ATActivityContext;
23  import org.apache.kandula.faults.AbstractKandulaException;
24  import org.apache.kandula.faults.InvalidProtocolException;
25  
26  /***
27   * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
28   */
29  public class ATSubCoordinator extends ATCoordinator {
30  
31  	public EndpointReference addParticipant(AbstractContext context,
32  			String protocol, EndpointReference participantEPR)
33  			throws AbstractKandulaException {
34  		ATActivityContext atContext = (ATActivityContext) context;
35  		if (protocol.equals(Constants.WS_AT_DURABLE2PC)) {
36  			if (!atContext.getSubDurableRegistered()) {
37  				// have to register with the parent coordinator
38  				atContext.setSubDurableRegistered(true);
39  			}
40  			return atContext.addParticipant(participantEPR, protocol);
41  		}
42  
43  		else if (protocol.equals(Constants.WS_AT_VOLATILE2PC)) {
44  			if (!atContext.getSubDurableRegistered()) {
45  				// have to register with the parent coordinator
46  				atContext.setSubDurableRegistered(true);
47  			}
48  			return atContext.addParticipant(participantEPR, protocol);
49  		} else
50  			throw new InvalidProtocolException();
51  	}
52  
53  	public void commitOperation(String id) throws AbstractKandulaException {
54  		throw new InvalidProtocolException(
55  				"This activity is a Sub Ordinate activity. Completion Protocol not supported.");
56  	}
57  
58  	public void rollbackOperation(String id) throws AbstractKandulaException {
59  		throw new InvalidProtocolException(
60  				"This activity is a Sub Ordinate activity. Completion Protocol not supported.");
61  	}
62  
63  }