1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.transport.soap.axis.extensions; |
8 | |
|
9 | |
import org.mule.api.DefaultMuleException; |
10 | |
import org.mule.config.i18n.CoreMessages; |
11 | |
import org.mule.transport.soap.axis.AxisConnector; |
12 | |
|
13 | |
import java.util.HashMap; |
14 | |
import java.util.Map; |
15 | |
|
16 | |
import org.apache.axis.client.Transport; |
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
public class MuleTransport extends Transport |
22 | |
{ |
23 | |
|
24 | 0 | private static Map<String, Class> transports = null; |
25 | |
|
26 | |
public MuleTransport() |
27 | 0 | { |
28 | 0 | transportName = "MuleTransport"; |
29 | 0 | } |
30 | |
|
31 | |
public MuleTransport(String protocol) |
32 | 0 | { |
33 | 0 | transportName = protocol; |
34 | 0 | } |
35 | |
|
36 | |
private static void initTransports() |
37 | |
{ |
38 | 0 | transports = new HashMap<String, Class>(); |
39 | 0 | transports.put("http", HTTP.class); |
40 | 0 | transports.put("https", HTTPS.class); |
41 | 0 | transports.put("servlet", SERVLET.class); |
42 | 0 | transports.put("tcp", TCP.class); |
43 | 0 | transports.put("ssl", SSL.class); |
44 | 0 | transports.put("jms", JMS.class); |
45 | 0 | transports.put("vm", VM.class); |
46 | 0 | transports.put("xmpp", XMPP.class); |
47 | 0 | transports.put("smtp", SMTP.class); |
48 | 0 | transports.put("smtps", SMTPS.class); |
49 | 0 | transports.put("pop3", POP3.class); |
50 | 0 | transports.put("pop3s", POP3S.class); |
51 | 0 | transports.put("imap", IMAP.class); |
52 | 0 | transports.put("imaps", IMAPS.class); |
53 | 0 | } |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
public static Class getTransportClass(String protocol) throws DefaultMuleException |
62 | |
{ |
63 | 0 | if (protocol == null) |
64 | |
{ |
65 | 0 | throw new IllegalArgumentException(CoreMessages.objectIsNull("protocol").toString()); |
66 | |
} |
67 | 0 | if (!isTransportSupported(protocol)) |
68 | |
{ |
69 | 0 | throw new DefaultMuleException( |
70 | |
CoreMessages.schemeNotCompatibleWithConnector(protocol, AxisConnector.class)); |
71 | |
} |
72 | 0 | return transports.get(protocol); |
73 | |
} |
74 | |
|
75 | |
public static boolean isTransportSupported(String protocol) |
76 | |
{ |
77 | 0 | if (transports == null) |
78 | |
{ |
79 | 0 | initTransports(); |
80 | |
} |
81 | 0 | return transports.get(protocol) != null; |
82 | |
} |
83 | |
|
84 | |
public static class HTTP extends MuleTransport |
85 | |
{ |
86 | |
public HTTP() |
87 | |
{ |
88 | 0 | super("http"); |
89 | 0 | } |
90 | |
} |
91 | |
|
92 | |
public static class HTTPS extends MuleTransport |
93 | |
{ |
94 | |
public HTTPS() |
95 | |
{ |
96 | 0 | super("https"); |
97 | 0 | } |
98 | |
} |
99 | |
|
100 | |
public static class TCP extends MuleTransport |
101 | |
{ |
102 | |
public TCP() |
103 | |
{ |
104 | 0 | super("tcp"); |
105 | 0 | } |
106 | |
} |
107 | |
|
108 | |
public static class SSL extends MuleTransport |
109 | |
{ |
110 | |
public SSL() |
111 | |
{ |
112 | 0 | super("ssl"); |
113 | 0 | } |
114 | |
} |
115 | |
|
116 | |
public static class JMS extends MuleTransport |
117 | |
{ |
118 | |
public JMS() |
119 | |
{ |
120 | 0 | super("jms"); |
121 | 0 | } |
122 | |
} |
123 | |
|
124 | |
public static class POP3 extends MuleTransport |
125 | |
{ |
126 | |
public POP3() |
127 | |
{ |
128 | 0 | super("pop3"); |
129 | 0 | } |
130 | |
} |
131 | |
|
132 | |
public static class SMTP extends MuleTransport |
133 | |
{ |
134 | |
public SMTP() |
135 | |
{ |
136 | 0 | super("smtp"); |
137 | 0 | } |
138 | |
} |
139 | |
|
140 | |
public static class POP3S extends MuleTransport |
141 | |
{ |
142 | |
public POP3S() |
143 | |
{ |
144 | 0 | super("pop3s"); |
145 | 0 | } |
146 | |
} |
147 | |
|
148 | |
public static class SMTPS extends MuleTransport |
149 | |
{ |
150 | |
public SMTPS() |
151 | |
{ |
152 | 0 | super("smtps"); |
153 | 0 | } |
154 | |
} |
155 | |
|
156 | |
public static class IMAP extends MuleTransport |
157 | |
{ |
158 | |
public IMAP() |
159 | |
{ |
160 | 0 | super("imap"); |
161 | 0 | } |
162 | |
} |
163 | |
|
164 | |
public static class IMAPS extends MuleTransport |
165 | |
{ |
166 | |
public IMAPS() |
167 | |
{ |
168 | 0 | super("imaps"); |
169 | 0 | } |
170 | |
} |
171 | |
|
172 | |
public static class XMPP extends MuleTransport |
173 | |
{ |
174 | |
public XMPP() |
175 | |
{ |
176 | 0 | super("xmpp"); |
177 | 0 | } |
178 | |
} |
179 | |
|
180 | |
public static class VM extends MuleTransport |
181 | |
{ |
182 | |
public VM() |
183 | |
{ |
184 | 0 | super("vm"); |
185 | 0 | } |
186 | |
} |
187 | |
|
188 | |
public static class SERVLET extends MuleTransport |
189 | |
{ |
190 | |
public SERVLET() |
191 | |
{ |
192 | 0 | super("servlet"); |
193 | 0 | } |
194 | |
} |
195 | |
} |