This repository has been archived by the owner on Dec 10, 2019. It is now read-only.
/
SmbEndpoint.java
80 lines (63 loc) · 1.88 KB
/
SmbEndpoint.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.redpill_linpro.component.smb;
import java.util.Map;
import jcifs.smb.SmbFile;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.file.GenericFile;
import org.apache.camel.component.file.GenericFileEndpoint;
import org.apache.camel.component.file.GenericFileProducer;
import org.apache.camel.impl.DefaultExchange;
public class SmbEndpoint extends GenericFileEndpoint<SmbFile> {
protected SmbClient smbClient;
protected Map<String, Object> props;
public SmbEndpoint(String uri, SmbComponent smbComponent, SmbConfiguration configuration) {
super(uri, smbComponent);
this.configuration = configuration;
}
@Override
public SmbConfiguration getConfiguration() {
return (SmbConfiguration) configuration;
}
@Override
public SmbConsumer createConsumer(Processor processor) throws Exception {
SmbConsumer consumer = new SmbConsumer(this, processor, createSmbOperations());
consumer.setMaxMessagesPerPoll(getMaxMessagesPerPoll());
configureConsumer(consumer);
return consumer;
}
@Override
public GenericFileProducer<SmbFile> createProducer() throws Exception {
return new SmbProducer(this, createSmbOperations());
}
@Override
public Exchange createExchange(GenericFile<SmbFile> file) {
Exchange answer = new DefaultExchange(this);
if (file != null) {
file.bindToExchange(answer);
}
return answer;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public SmbOperations<SmbFile> createSmbOperations(){
SmbClient client = new SmbClient();
SmbOperations operations = new SmbOperations(client);
operations.setEndpoint(this);
return operations;
}
@Override
public String getScheme() {
return "smb";
}
@Override
public char getFileSeparator() {
return '/';
}
@Override
public boolean isAbsolute(String name) {
return true;
}
@Override
public boolean isSingleton(){
return false;
}
}