Coverage Report - org.apache.camel.component.xmpp.XmppComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
XmppComponent
83% 
100% 
0
 
 1  
 /**
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.component.xmpp;
 18  
 
 19  
 import java.net.URI;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.apache.camel.CamelContext;
 23  
 import org.apache.camel.Endpoint;
 24  
 import org.apache.camel.impl.DefaultComponent;
 25  
 
 26  
 /**
 27  
  * @version $Revision:520964 $
 28  
  */
 29  
 public class XmppComponent extends DefaultComponent<XmppExchange> {
 30  
 
 31  2
     public XmppComponent() {
 32  2
     }
 33  
 
 34  
     public XmppComponent(CamelContext context) {
 35  0
         super(context);
 36  0
     }
 37  
 
 38  
     /**
 39  
      * Static builder method
 40  
      */
 41  
     public static XmppComponent xmppComponent() {
 42  0
         return new XmppComponent();
 43  
     }
 44  
 
 45  
     @Override
 46  
     protected Endpoint<XmppExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
 47  2
         XmppEndpoint endpoint = new XmppEndpoint(uri, this);
 48  
 
 49  2
         URI u = new URI(uri);
 50  2
         endpoint.setHost(u.getHost());
 51  2
         endpoint.setPort(u.getPort());
 52  2
         if (u.getUserInfo() != null) {
 53  2
             endpoint.setUser(u.getUserInfo());
 54  
         }
 55  2
         String remainingPath = u.getPath();
 56  2
         if (remainingPath != null) {
 57  2
             if (remainingPath.startsWith("/")) {
 58  1
                 remainingPath = remainingPath.substring(1);
 59  
             }
 60  
 
 61  
             // assume its a participant
 62  2
             if (remainingPath.length() > 0) {
 63  1
                 endpoint.setParticipant(remainingPath);
 64  
             }
 65  
         }
 66  2
         return endpoint;
 67  
     }
 68  
 }