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