1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transport.xmpp; |
12 | |
|
13 | |
import org.mule.api.MuleRuntimeException; |
14 | |
import org.mule.api.endpoint.ImmutableEndpoint; |
15 | |
import org.mule.transport.xmpp.i18n.XmppMessages; |
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | 0 | public class XmppConversationFactory |
21 | |
{ |
22 | |
public XmppConversation create(ImmutableEndpoint endpoint) |
23 | |
{ |
24 | 0 | String host = endpoint.getEndpointURI().getHost(); |
25 | 0 | XmppMessageType type = XmppMessageType.valueOf(host); |
26 | |
|
27 | 0 | switch (type) |
28 | |
{ |
29 | |
case MESSAGE: |
30 | 0 | return createMessageConversation(endpoint); |
31 | |
|
32 | |
case CHAT: |
33 | 0 | return createChatConversation(endpoint); |
34 | |
|
35 | |
case GROUPCHAT: |
36 | 0 | return createGroupchatConversation(endpoint); |
37 | |
} |
38 | |
|
39 | |
|
40 | |
|
41 | 0 | throw new MuleRuntimeException(XmppMessages.invalidConversationType(type)); |
42 | |
} |
43 | |
|
44 | |
protected XmppConversation createMessageConversation(ImmutableEndpoint endpoint) |
45 | |
{ |
46 | 0 | return new XmppMessageConversation(endpoint); |
47 | |
} |
48 | |
|
49 | |
protected XmppConversation createChatConversation(ImmutableEndpoint endpoint) |
50 | |
{ |
51 | 0 | return new XmppChatConversation(endpoint); |
52 | |
} |
53 | |
|
54 | |
protected XmppConversation createGroupchatConversation(ImmutableEndpoint endpoint) |
55 | |
{ |
56 | 0 | return new XmppMultiUserChatConversation(endpoint); |
57 | |
} |
58 | |
} |
59 | |
|
60 | |
|