| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.camel.component.file.remote; |
| 18 |
|
|
| 19 |
|
import java.net.URI; |
| 20 |
|
import java.util.Map; |
| 21 |
|
|
| 22 |
|
import org.apache.camel.CamelContext; |
| 23 |
|
import org.apache.camel.RuntimeCamelException; |
| 24 |
|
import org.apache.camel.impl.DefaultComponent; |
| 25 |
|
import org.apache.camel.util.IntrospectionSupport; |
| 26 |
|
|
| 27 |
6 |
public class RemoteFileComponent extends DefaultComponent<RemoteFileExchange> { |
| 28 |
|
private RemoteFileConfiguration configuration; |
| 29 |
|
|
| 30 |
6 |
public RemoteFileComponent() { |
| 31 |
6 |
this.configuration = new RemoteFileConfiguration(); |
| 32 |
6 |
} |
| 33 |
|
|
| 34 |
0 |
public RemoteFileComponent(RemoteFileConfiguration configuration) { |
| 35 |
0 |
this.configuration = configuration; |
| 36 |
0 |
} |
| 37 |
|
|
| 38 |
|
public RemoteFileComponent(CamelContext context) { |
| 39 |
0 |
super(context); |
| 40 |
0 |
this.configuration = new RemoteFileConfiguration(); |
| 41 |
0 |
} |
| 42 |
|
|
| 43 |
|
public String toString() { |
| 44 |
0 |
return "RemoteFileComponent"; |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
public static RemoteFileComponent remoteFileComponent() { |
| 48 |
0 |
return new RemoteFileComponent(); |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
protected RemoteFileEndpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { |
| 52 |
6 |
RemoteFileConfiguration config = getConfiguration().copy(); |
| 53 |
6 |
config.configure(new URI(uri)); |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
final RemoteFileEndpoint endpoint; |
| 58 |
6 |
if ("ftp".equals(config.getProtocol())) { |
| 59 |
3 |
endpoint = new FtpEndpoint(uri, this, config); |
| 60 |
3 |
} else if ("sftp".equals(config.getProtocol())) { |
| 61 |
3 |
endpoint = new SftpEndpoint(uri, this, config); |
| 62 |
3 |
} else { |
| 63 |
0 |
throw new RuntimeCamelException("Unsupported protocol: " + config.getProtocol()); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
6 |
IntrospectionSupport.setProperties(endpoint.getConfiguration(), parameters); |
| 67 |
6 |
return endpoint; |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
public RemoteFileConfiguration getConfiguration() { |
| 71 |
6 |
return configuration; |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
public void setConfiguration(RemoteFileConfiguration configuration) { |
| 75 |
0 |
this.configuration = configuration; |
| 76 |
0 |
} |
| 77 |
|
} |