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