Skip to content

Commit

Permalink
Component docs
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed Jun 14, 2015
1 parent 08c850e commit a4e6997
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 25 deletions.
Expand Up @@ -43,7 +43,7 @@ public class SftpConfiguration extends RemoteFileConfiguration {
@UriParam
private String privateKeyPassphrase;
private KeyPair keyPair;
@UriParam(defaultValue = "no")
@UriParam(defaultValue = "no", enums = "no,yes")
private String strictHostKeyChecking = "no";
@UriParam
private int serverAliveInterval;
Expand Down Expand Up @@ -77,6 +77,9 @@ public String getKnownHostsFile() {
return knownHostsFile;
}

/**
* Sets the known_hosts file, so that the SFTP endpoint can do host key verification.
*/
public void setKnownHostsFile(String knownHostsFile) {
this.knownHostsFile = knownHostsFile;
}
Expand All @@ -85,6 +88,9 @@ public String getKnownHostsUri() {
return knownHostsUri;
}

/**
* Sets the known_hosts file (loaded from classpath by default), so that the SFTP endpoint can do host key verification.
*/
public void setKnownHostsUri(String knownHostsUri) {
this.knownHostsUri = knownHostsUri;
}
Expand All @@ -101,6 +107,9 @@ public String getPrivateKeyFile() {
return privateKeyFile;
}

/**
* Set the private key file to that the SFTP endpoint can do private key verification.
*/
public void setPrivateKeyFile(String privateKeyFile) {
this.privateKeyFile = privateKeyFile;
}
Expand All @@ -109,6 +118,9 @@ public String getPrivateKeyUri() {
return privateKeyUri;
}

/**
* Set the private key file (loaded from classpath by default) to that the SFTP endpoint can do private key verification.
*/
public void setPrivateKeyUri(String privateKeyUri) {
this.privateKeyUri = privateKeyUri;
}
Expand All @@ -117,6 +129,9 @@ public byte[] getPrivateKey() {
return privateKey;
}

/**
* Set the private key as byte[] to that the SFTP endpoint can do private key verification.
*/
public void setPrivateKey(byte[] privateKey) {
this.privateKey = privateKey;
}
Expand All @@ -125,6 +140,9 @@ public String getPrivateKeyPassphrase() {
return privateKeyPassphrase;
}

/**
* Set the private key file passphrase to that the SFTP endpoint can do private key verification.
*/
public void setPrivateKeyPassphrase(String privateKeyFilePassphrase) {
this.privateKeyPassphrase = privateKeyFilePassphrase;
}
Expand All @@ -151,10 +169,16 @@ public String getStrictHostKeyChecking() {
return strictHostKeyChecking;
}

/**
* Sets whether to use strict host key checking.
*/
public void setStrictHostKeyChecking(String strictHostKeyChecking) {
this.strictHostKeyChecking = strictHostKeyChecking;
}

/**
* Allows you to set the serverAliveInterval of the sftp session
*/
public void setServerAliveInterval(int serverAliveInterval) {
this.serverAliveInterval = serverAliveInterval;
}
Expand All @@ -163,6 +187,9 @@ public int getServerAliveInterval() {
return serverAliveInterval;
}

/**
* Allows you to set the serverAliveCountMax of the sftp session
*/
public void setServerAliveCountMax(int serverAliveCountMax) {
this.serverAliveCountMax = serverAliveCountMax;
}
Expand All @@ -171,6 +198,9 @@ public int getServerAliveCountMax() {
return serverAliveCountMax;
}

/**
* Allows you to set chmod on the stored file. For example chmod=640.
*/
public void setChmod(String chmod) {
this.chmod = chmod;
}
Expand All @@ -179,6 +209,11 @@ public String getChmod() {
return chmod;
}

/**
* Set a comma separated list of ciphers that will be used in order of preference.
* Possible cipher names are defined by JCraft JSCH. Some examples include: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc.
* If not specified the default list from JSCH will be used.
*/
public void setCiphers(String ciphers) {
this.ciphers = ciphers;
}
Expand All @@ -191,10 +226,18 @@ public int getCompression() {
return compression;
}

/**
* To use compression. Specify a level from 1 to 10.
* Important: You must manually add the needed JSCH zlib JAR to the classpath for compression support.
*/
public void setCompression(int compression) {
this.compression = compression;
}


/**
* Set the preferred authentications which SFTP endpoint will used. Some example include:password,publickey.
* If not specified the default list from JSCH will be used.
*/
public void setPreferredAuthentications(String pAuthentications) {
this.preferredAuthentications = pAuthentications;
}
Expand Down
Expand Up @@ -49,6 +49,8 @@
@UriEndpoint(scheme = "http,https", title = "HTTP,HTTPS", syntax = "http:httpUri", producerOnly = true, label = "http")
public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware {

// Note: all consumer options must be documented with description in annotations so extended components can access the documentation

private static final Logger LOG = LoggerFactory.getLogger(HttpEndpoint.class);

private HttpComponent component;
Expand All @@ -57,7 +59,7 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
private HttpConnectionManager httpConnectionManager;
private UrlRewrite urlRewrite;

@UriPath @Metadata(required = "true", label = "producer")
@UriPath(label = "producer") @Metadata(required = "true")
private URI httpUri;
@UriParam
private HeaderFilterStrategy headerFilterStrategy = new HttpHeaderFilterStrategy();
Expand All @@ -67,11 +69,21 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
private boolean throwExceptionOnFailure = true;
@UriParam(label = "producer")
private boolean bridgeEndpoint;
@UriParam(label = "consumer")
@UriParam(label = "consumer",
description = "Whether or not the consumer should try to find a target consumer by matching the URI prefix if no exact match is found.")
private boolean matchOnUriPrefix;
@UriParam(defaultValue = "true")
private boolean chunked = true;
@UriParam(label = "consumer")
@UriParam(label = "consumer",
description = "Determines whether or not the raw input stream from Jetty is cached or not"
+ " (Camel will read the stream into a in memory/overflow to file, Stream caching) cache."
+ " By default Camel will cache the Jetty input stream to support reading it multiple times to ensure it Camel"
+ " can retrieve all data from the stream. However you can set this option to true when you for example need"
+ " to access the raw stream, such as streaming it directly to a file or other persistent store."
+ " DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body"
+ " if this option is false to support reading the stream multiple times."
+ " If you use Jetty to bridge/proxy an endpoint then consider enabling this option to improve performance,"
+ " in case you do not need to read the message payload multiple times.")
private boolean disableStreamCache;
@UriParam(label = "producer")
private String proxyHost;
Expand All @@ -81,11 +93,14 @@ public class HttpEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
private String authMethodPriority;
@UriParam
private boolean transferException;
@UriParam(label = "consumer")
@UriParam(label = "consumer",
description = "Specifies whether to enable HTTP TRACE for this Jetty consumer. By default TRACE is turned off.")
private boolean traceEnabled;
@UriParam(label = "consumer")
@UriParam(label = "consumer",
description = "Used to only allow consuming if the HttpMethod matches, such as GET/POST/PUT etc. Multiple methods can be specified separated by comma.")
private String httpMethodRestrict;
@UriParam(label = "consumer")
@UriParam(label = "consumer",
description = "To use a custom buffer size on the javax.servlet.ServletResponse.")
private Integer responseBufferSize;

public HttpEndpoint() {
Expand Down Expand Up @@ -346,7 +361,7 @@ public boolean isDisableStreamCache() {
* By default Camel will cache the Jetty input stream to support reading it multiple times to ensure it Camel
* can retrieve all data from the stream. However you can set this option to true when you for example need
* to access the raw stream, such as streaming it directly to a file or other persistent store.
* DefaultHttpBinding will copy the request input stream into a stream cache and put it into message bod
* DefaultHttpBinding will copy the request input stream into a stream cache and put it into message body
* if this option is false to support reading the stream multiple times.
* If you use Jetty to bridge/proxy an endpoint then consider enabling this option to improve performance,
* in case you do not need to read the message payload multiple times.
Expand Down
Expand Up @@ -40,7 +40,7 @@ public class ScpConfiguration extends RemoteFileConfiguration {
private String privateKeyFile;
@UriParam
private String privateKeyFilePassphrase;
@UriParam
@UriParam(enums = "no,yes", defaultValue = "no")
private String strictHostKeyChecking;
@UriParam
private int serverAliveInterval;
Expand Down Expand Up @@ -80,6 +80,9 @@ public boolean isUseUserKnownHostsFile() {
return useUserKnownHostsFile;
}

/**
* If knownHostFile has not been explicit configured, then use the host file from System.getProperty("user.home") + "/.ssh/known_hosts"
*/
public void setUseUserKnownHostsFile(boolean useUserKnownHostsFile) {
this.useUserKnownHostsFile = useUserKnownHostsFile;
}
Expand All @@ -104,6 +107,9 @@ public String getStrictHostKeyChecking() {
return strictHostKeyChecking;
}

/**
* Sets whether to use strict host key checking. Possible values are: no, yes
*/
public void setStrictHostKeyChecking(String strictHostKeyChecking) {
this.strictHostKeyChecking = strictHostKeyChecking;
}
Expand All @@ -124,6 +130,9 @@ public int getServerAliveCountMax() {
return serverAliveCountMax;
}

/**
* Allows you to set chmod on the stored file. For example chmod=664.
*/
public void setChmod(String chmod) {
if (chmod.length() == 3) {
for (byte c : chmod.getBytes()) {
Expand Down Expand Up @@ -158,4 +167,15 @@ public int getCompression() {
public void setCompression(int compression) {
this.compression = compression;
}

public boolean isVerboseLogging() {
return verboseLogging;
}

/**
* To enable verbose logging
*/
public void setVerboseLogging(boolean verboseLogging) {
this.verboseLogging = verboseLogging;
}
}
Expand Up @@ -156,6 +156,9 @@ public String getServletName() {
return servletName;
}

/**
* Default name of servlet to use. The default name is <tt>CamelServlet</tt>.
*/
public void setServletName(String servletName) {
this.servletName = servletName;
}
Expand All @@ -164,6 +167,9 @@ public HttpRegistry getHttpRegistry() {
return httpRegistry;
}

/**
* To use a custom {@link org.apache.camel.component.servlet.HttpRegistry}.
*/
public void setHttpRegistry(HttpRegistry httpRegistry) {
this.httpRegistry = httpRegistry;
}
Expand Down
Expand Up @@ -34,7 +34,7 @@
syntax = "servlet:servletName", consumerOnly = true, consumerClass = ServletConsumer.class, label = "http")
public class ServletEndpoint extends HttpEndpoint {

@UriPath @Metadata(required = "true")
@UriPath(label = "consumer") @Metadata(required = "true")
private String servletName;

public ServletEndpoint() {
Expand Down
Expand Up @@ -33,22 +33,35 @@
*/
public final class DocumentationHelper {

public static String findJavaDoc(String scheme, String extendsScheme, String fieldName) {
public static String findComponentJavaDoc(String scheme, String extendsScheme, String fieldName) {
File file = jsonFile(scheme, extendsScheme);
if (file != null) {
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
String json = loadText(fis);
List<Map<String, String>> rows = parseJsonSchema("properties", json, true);
List<Map<String, String>> rows = parseJsonSchema("componentProperties", json, true);
return getPropertyDescription(rows, fieldName);
} catch (Exception e) {
// ignore
} finally {
IOHelper.close(fis);
}
}

for (Map<String, String> row : rows) {
String name = row.get("name");
String description = row.get("description");
if (fieldName.equals(name)) {
return description;
}
}
// not found
return null;
}

public static String findEndpointJavaDoc(String scheme, String extendsScheme, String fieldName) {
File file = jsonFile(scheme, extendsScheme);
if (file != null) {
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
String json = loadText(fis);
List<Map<String, String>> rows = parseJsonSchema("properties", json, true);
return getPropertyDescription(rows, fieldName);
} catch (Exception e) {
// ignore
} finally {
Expand All @@ -60,6 +73,23 @@ public static String findJavaDoc(String scheme, String extendsScheme, String fie
return null;
}

private static String getPropertyDescription(List<Map<String, String>> rows, String name) {
for (Map<String, String> row : rows) {
String description = null;
boolean found = false;
if (row.containsKey("name")) {
found = name.equals(row.get("name"));
}
if (row.containsKey("description")) {
description = row.get("description");
}
if (found) {
return description;
}
}
return null;
}

private static File jsonFile(String scheme, String extendsScheme) {
// TODO: scan components for each component and find component name from extendsScheme
// and then find the package name where the json file is
Expand Down

0 comments on commit a4e6997

Please sign in to comment.