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