Coverage Report - org.mule.transport.xmpp.XmppConversationFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
XmppConversationFactory
0%
0/11
0%
0/4
2.75
XmppConversationFactory$1
0%
0/1
N/A
2.75
 
 1  
 /*
 2  
  * $Id: XmppConversationFactory.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 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  
  * A factory that creates {@link XmppConversation} instances based on the endpoint's configuration.
 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  
         // we should never get here as valueOf on the enum above will choke if you pass
 40  
         // in an invalid string
 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