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