Coverage Report - org.apache.camel.component.file.remote.RemoteFileComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
RemoteFileComponent
60% 
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.file.remote;
 19  
 
 20  
 import org.apache.camel.CamelContext;
 21  
 import org.apache.camel.RuntimeCamelException;
 22  
 import org.apache.camel.impl.DefaultComponent;
 23  
 import org.apache.camel.util.IntrospectionSupport;
 24  
 
 25  
 import java.net.URI;
 26  
 import java.util.Map;
 27  
 
 28  7
 public class RemoteFileComponent extends DefaultComponent<RemoteFileExchange> {
 29  
     private RemoteFileConfiguration configuration;
 30  
 
 31  7
     public RemoteFileComponent() {
 32  7
         this.configuration = new RemoteFileConfiguration();
 33  7
     }
 34  
 
 35  0
     public RemoteFileComponent(RemoteFileConfiguration configuration) {
 36  0
         this.configuration = configuration;
 37  0
     }
 38  
 
 39  
     public RemoteFileComponent(CamelContext context) {
 40  0
         super(context);
 41  0
         this.configuration = new RemoteFileConfiguration();
 42  0
     }
 43  
 
 44  
     public static RemoteFileComponent remoteFileComponent() {
 45  0
         return new RemoteFileComponent();
 46  
     }
 47  
 
 48  
     protected RemoteFileEndpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
 49  7
         RemoteFileConfiguration config = getConfiguration().copy();
 50  7
         config.configure(new URI(uri));
 51  
 
 52  
         // lets make sure we copy the configuration as each endpoint can customize its own version
 53  
         final RemoteFileEndpoint endpoint;
 54  7
         if ("ftp".equals(config.getProtocol())) {
 55  4
             endpoint = new FtpEndpoint(uri, this, config);
 56  4
         }
 57  3
         else if ("sftp".equals(config.getProtocol())) {
 58  3
             endpoint = new SftpEndpoint(uri, this, config);
 59  3
         }
 60  
         else {
 61  0
             throw new RuntimeCamelException("Unsupported protocol: " + config.getProtocol());
 62  
         }
 63  
 
 64  7
         IntrospectionSupport.setProperties(endpoint.getConfiguration(), parameters);
 65  7
         return endpoint;
 66  
     }
 67  
 
 68  
     public RemoteFileConfiguration getConfiguration() {
 69  7
         return configuration;
 70  
     }
 71  
 
 72  
     public void setConfiguration(RemoteFileConfiguration configuration) {
 73  0
         this.configuration = configuration;
 74  0
     }
 75  
 }