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 public class XmppConversationFactory
21 {
22 public XmppConversation create(ImmutableEndpoint endpoint)
23 {
24 String host = endpoint.getEndpointURI().getHost();
25 XmppMessageType type = XmppMessageType.valueOf(host);
26
27 switch (type)
28 {
29 case MESSAGE:
30 return createMessageConversation(endpoint);
31
32 case CHAT:
33 return createChatConversation(endpoint);
34
35 case GROUPCHAT:
36 return createGroupchatConversation(endpoint);
37 }
38
39
40
41 throw new MuleRuntimeException(XmppMessages.invalidConversationType(type));
42 }
43
44 protected XmppConversation createMessageConversation(ImmutableEndpoint endpoint)
45 {
46 return new XmppMessageConversation(endpoint);
47 }
48
49 protected XmppConversation createChatConversation(ImmutableEndpoint endpoint)
50 {
51 return new XmppChatConversation(endpoint);
52 }
53
54 protected XmppConversation createGroupchatConversation(ImmutableEndpoint endpoint)
55 {
56 return new XmppMultiUserChatConversation(endpoint);
57 }
58 }
59
60