1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.kandula.context;
18
19 import org.apache.axis2.addressing.EndpointReference;
20 import org.apache.kandula.context.impl.ATActivityContext;
21 import org.apache.kandula.faults.InvalidProtocolException;
22
23 /***
24 * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
25 */
26 public class ContextFactory {
27 private static ContextFactory instance = new ContextFactory();
28
29 public static ContextFactory getInstance() {
30 return instance;
31 }
32
33 public AbstractContext createActivity(CoordinationContext context)
34 throws InvalidProtocolException {
35 if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(context
36 .getCoordinationType())) {
37 return new ATActivityContext(context);
38 } else {
39 throw new InvalidProtocolException("Unsupported Protocol Type");
40 }
41 }
42
43 public AbstractContext createActivity(String protocol)
44 throws InvalidProtocolException {
45 if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
46 return new ATActivityContext();
47 } else {
48 throw new InvalidProtocolException("Unsupported Protocol Type");
49 }
50 }
51
52 /***
53 * To be used by the initaitor TxManager to create the initial context
54 *
55 * @param protocol
56 * @param activationEPR
57 * @return
58 * @throws InvalidProtocolException
59 */
60 public AbstractContext createActivity(String protocol,
61 EndpointReference activationEPR) throws InvalidProtocolException {
62 if (org.apache.kandula.Constants.WS_AT.equalsIgnoreCase(protocol)) {
63 return new ATActivityContext(activationEPR);
64 } else {
65 throw new InvalidProtocolException("Unsupported Protocol Type");
66 }
67 }
68 }