http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-linkedin-starter/src/main/java/org/apache/camel/component/linkedin/springboot/LinkedInComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-linkedin-starter/src/main/java/org/apache/camel/component/linkedin/springboot/LinkedInComponentConfiguration.java b/components-starter/camel-linkedin-starter/src/main/java/org/apache/camel/component/linkedin/springboot/LinkedInComponentConfiguration.java index c534089..38cd520 100644 --- a/components-starter/camel-linkedin-starter/src/main/java/org/apache/camel/component/linkedin/springboot/LinkedInComponentConfiguration.java +++ b/components-starter/camel-linkedin-starter/src/main/java/org/apache/camel/component/linkedin/springboot/LinkedInComponentConfiguration.java @@ -17,11 +17,11 @@ package org.apache.camel.component.linkedin.springboot; import java.util.Map; -import org.apache.camel.component.linkedin.LinkedInConfiguration; import org.apache.camel.component.linkedin.api.OAuthScope; import org.apache.camel.component.linkedin.api.OAuthSecureStorage; import org.apache.camel.component.linkedin.internal.LinkedInApiName; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * The linkedin component is uses for retrieving LinkedIn user profiles @@ -35,153 +35,161 @@ public class LinkedInComponentConfiguration { /** * To use the shared configuration */ - private LinkedInConfiguration configuration; - /** - * What kind of operation to perform - */ - private LinkedInApiName apiName; - /** - * What sub operation to use for the selected operation - */ - private String methodName; - /** - * LinkedIn user account name MUST be provided - */ - private String userName; - /** - * LinkedIn account password - */ - private String userPassword; - /** - * Callback interface for providing an OAuth token or to store the token - * generated by the component. The callback should return null on the first - * call and then save the created token in the saveToken() callback. If the - * callback returns null the first time a userPassword MUST be provided - */ - private OAuthSecureStorage secureStorage; - /** - * LinkedIn application client ID - */ - private String clientId; - /** - * LinkedIn application client secret - */ - private String clientSecret; - /** - * List of LinkedIn scopes as specified at - * https://developer.linkedin.com/documents/authenticationgranting - */ - private OAuthScope[] scopes; - /** - * Application redirect URI although the component never redirects to this - * page to avoid having to have a functioning redirect server. So for - * testing one could use https://localhost - */ - private String redirectUri; - /** - * Custom HTTP params for example proxy host and port use constants from - * AllClientPNames - */ - private Map<String, Object> httpParams; - /** - * Flag to enable/disable lazy OAuth default is true. when enabled OAuth - * token retrieval or generation is not done until the first REST call - */ - private Boolean lazyAuth; + private LinkedInConfigurationNestedConfiguration configuration; - public LinkedInConfiguration getConfiguration() { + public LinkedInConfigurationNestedConfiguration getConfiguration() { return configuration; } - public void setConfiguration(LinkedInConfiguration configuration) { + public void setConfiguration( + LinkedInConfigurationNestedConfiguration configuration) { this.configuration = configuration; } - public LinkedInApiName getApiName() { - return apiName; - } - - public void setApiName(LinkedInApiName apiName) { - this.apiName = apiName; - } - - public String getMethodName() { - return methodName; - } - - public void setMethodName(String methodName) { - this.methodName = methodName; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getUserPassword() { - return userPassword; - } - - public void setUserPassword(String userPassword) { - this.userPassword = userPassword; - } - - public OAuthSecureStorage getSecureStorage() { - return secureStorage; - } - - public void setSecureStorage(OAuthSecureStorage secureStorage) { - this.secureStorage = secureStorage; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - public OAuthScope[] getScopes() { - return scopes; - } - - public void setScopes(OAuthScope[] scopes) { - this.scopes = scopes; - } - - public String getRedirectUri() { - return redirectUri; - } - - public void setRedirectUri(String redirectUri) { - this.redirectUri = redirectUri; - } - - public Map<String, Object> getHttpParams() { - return httpParams; - } - - public void setHttpParams(Map<String, Object> httpParams) { - this.httpParams = httpParams; - } - - public Boolean getLazyAuth() { - return lazyAuth; - } - - public void setLazyAuth(Boolean lazyAuth) { - this.lazyAuth = lazyAuth; + public static class LinkedInConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.linkedin.LinkedInConfiguration.class; + /** + * What kind of operation to perform + */ + private LinkedInApiName apiName; + /** + * What sub operation to use for the selected operation + */ + private String methodName; + /** + * LinkedIn user account name, MUST be provided + */ + private String userName; + /** + * LinkedIn account password + */ + private String userPassword; + /** + * Callback interface for providing an OAuth token or to store the token + * generated by the component. The callback should return null on the + * first call and then save the created token in the saveToken() + * callback. If the callback returns null the first time, a userPassword + * MUST be provided + */ + @NestedConfigurationProperty + private OAuthSecureStorage secureStorage; + /** + * LinkedIn application client ID + */ + private String clientId; + /** + * LinkedIn application client secret + */ + private String clientSecret; + /** + * List of LinkedIn scopes as specified at + * https://developer.linkedin.com/documents/authentication#granting + */ + private OAuthScope[] scopes; + /** + * Application redirect URI, although the component never redirects to + * this page to avoid having to have a functioning redirect server. So + * for testing one could use https://localhost + */ + private String redirectUri; + /** + * Custom HTTP params, for example proxy host and port, use constants + * from AllClientPNames + */ + private Map httpParams; + /** + * Flag to enable/disable lazy OAuth, default is true. when enabled, + * OAuth token retrieval or generation is not done until the first REST + * call + */ + private Boolean lazyAuth; + + public LinkedInApiName getApiName() { + return apiName; + } + + public void setApiName(LinkedInApiName apiName) { + this.apiName = apiName; + } + + public String getMethodName() { + return methodName; + } + + public void setMethodName(String methodName) { + this.methodName = methodName; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPassword() { + return userPassword; + } + + public void setUserPassword(String userPassword) { + this.userPassword = userPassword; + } + + public OAuthSecureStorage getSecureStorage() { + return secureStorage; + } + + public void setSecureStorage(OAuthSecureStorage secureStorage) { + this.secureStorage = secureStorage; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public OAuthScope[] getScopes() { + return scopes; + } + + public void setScopes(OAuthScope[] scopes) { + this.scopes = scopes; + } + + public String getRedirectUri() { + return redirectUri; + } + + public void setRedirectUri(String redirectUri) { + this.redirectUri = redirectUri; + } + + public Map getHttpParams() { + return httpParams; + } + + public void setHttpParams(Map httpParams) { + this.httpParams = httpParams; + } + + public Boolean getLazyAuth() { + return lazyAuth; + } + + public void setLazyAuth(Boolean lazyAuth) { + this.lazyAuth = lazyAuth; + } } } \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java b/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java index f4517b0..b770cd2 100644 --- a/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java +++ b/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class LuceneComponentAutoConfiguration { Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component; http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java b/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java index cd514f7..71e03f6 100644 --- a/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java +++ b/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java @@ -16,8 +16,13 @@ */ package org.apache.camel.component.lucene.springboot; -import org.apache.camel.component.lucene.LuceneConfiguration; +import java.io.File; +import java.net.URI; +import org.apache.camel.component.lucene.LuceneOperation; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.util.Version; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * To insert or query from Apache Lucene databases. @@ -30,13 +35,124 @@ public class LuceneComponentConfiguration { /** * To use a shared lucene configuration */ - private LuceneConfiguration config; + private LuceneConfigurationNestedConfiguration config; - public LuceneConfiguration getConfig() { + public LuceneConfigurationNestedConfiguration getConfig() { return config; } - public void setConfig(LuceneConfiguration config) { + public void setConfig(LuceneConfigurationNestedConfiguration config) { this.config = config; } + + public static class LuceneConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.lucene.LuceneConfiguration.class; + private URI uri; + /** + * The URL to the lucene server + */ + private String host; + /** + * Operation to do such as insert or query. + */ + private LuceneOperation operation; + private String authority; + /** + * An optional directory containing files to be used to be analyzed and + * added to the index at producer startup. + */ + private File sourceDirectory; + /** + * A file system directory in which index files are created upon + * analysis of the document by the specified analyzer + */ + private File indexDirectory; + /** + * An Analyzer builds TokenStreams, which analyze text. It thus + * represents a policy for extracting index terms from text. The value + * for analyzer can be any class that extends the abstract class + * org.apache.lucene.analysis.Analyzer. Lucene also offers a rich set of + * analyzers out of the box + */ + @NestedConfigurationProperty + private Analyzer analyzer; + /** + * An integer value that limits the result set of the search operation + */ + private Integer maxHits; + @NestedConfigurationProperty + private Version luceneVersion; + + public URI getUri() { + return uri; + } + + public void setUri(URI uri) { + this.uri = uri; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public LuceneOperation getOperation() { + return operation; + } + + public void setOperation(LuceneOperation operation) { + this.operation = operation; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public File getSourceDirectory() { + return sourceDirectory; + } + + public void setSourceDirectory(File sourceDirectory) { + this.sourceDirectory = sourceDirectory; + } + + public File getIndexDirectory() { + return indexDirectory; + } + + public void setIndexDirectory(File indexDirectory) { + this.indexDirectory = indexDirectory; + } + + public Analyzer getAnalyzer() { + return analyzer; + } + + public void setAnalyzer(Analyzer analyzer) { + this.analyzer = analyzer; + } + + public Integer getMaxHits() { + return maxHits; + } + + public void setMaxHits(Integer maxHits) { + this.maxHits = maxHits; + } + + public Version getLuceneVersion() { + return luceneVersion; + } + + public void setLuceneVersion(Version luceneVersion) { + this.luceneVersion = luceneVersion; + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java b/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java index 009d941..4018aab 100644 --- a/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java +++ b/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java @@ -45,6 +45,26 @@ public class LumberjackComponentAutoConfiguration { Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component; http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java b/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java index e3dc61d..242d612 100644 --- a/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java +++ b/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.lumberjack.springboot; import org.apache.camel.util.jsse.SSLContextParameters; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * Camel Lumberjack log streaming component @@ -31,6 +32,7 @@ public class LumberjackComponentConfiguration { * Sets the default SSL configuration to use for all the endpoints. You can * also configure it directly at the endpoint level. */ + @NestedConfigurationProperty private SSLContextParameters sslContextParameters; public SSLContextParameters getSslContextParameters() { http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java index 4746a0a..488e31b 100644 --- a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java +++ b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java @@ -45,6 +45,26 @@ public class MailComponentAutoConfiguration { Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component; http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java index dbcdaf7..e5af5c6 100644 --- a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java +++ b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java @@ -21,9 +21,9 @@ import javax.mail.Session; import org.apache.camel.component.mail.AttachmentsContentTransferEncodingResolver; import org.apache.camel.component.mail.ContentTypeResolver; import org.apache.camel.component.mail.JavaMailSender; -import org.apache.camel.component.mail.MailConfiguration; import org.apache.camel.util.jsse.SSLContextParameters; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * To send or receive emails using imap/pop3 or stmp protocols. @@ -34,215 +34,21 @@ import org.springframework.boot.context.properties.ConfigurationProperties; public class MailComponentConfiguration { /** - * Sets the Mail configuration. Properties of the shared configuration can - * also be set individually. + * Sets the Mail configuration */ - private MailConfiguration configuration; + private MailConfigurationNestedConfiguration configuration; /** * Resolver to determine Content-Type for file attachments. */ + @NestedConfigurationProperty private ContentTypeResolver contentTypeResolver; - /** - * To use a custom JavaMailSender for sending emails. - */ - private JavaMailSender javaMailSender; - /** - * The mail server host name - */ - private String host; - /** - * Sets the java mail options. Will clear any default properties and only - * use the properties provided for this method. - */ - private Properties javaMailProperties; - /** - * Sets additional java mail properties that will append/override any - * default properties that is set based on all the other options. This is - * useful if you need to add some special options but want to keep the - * others as is. - */ - private Properties additionalJavaMailProperties; - /** - * The password for login - */ - private String password; - /** - * The Subject of the message being sent. Note: Setting the subject in the - * header takes precedence over this option. - */ - private String subject; - /** - * The port number of the mail server - */ - private Integer port; - /** - * The protocol for communicating with the mail server - */ - private String protocol; - /** - * Specifies the mail session that camel should use for all mail - * interactions. Useful in scenarios where mail sessions are created and - * managed by some other resource such as a JavaEE container. If this is not - * specified Camel automatically creates the mail session for you. - */ - private Session session; - /** - * The username for login - */ - private String username; - /** - * The from email address - */ - private String from; - /** - * Deletes the messages after they have been processed. This is done by - * setting the DELETED flag on the mail message. If false the SEEN flag is - * set instead. As of Camel 2.10 you can override this configuration option - * by setting a header with the key delete to determine if the mail should - * be deleted or not. - */ - private Boolean delete; - /** - * Specifies whether Camel should map the received mail message to Camel - * body/headers. If set to true the body of the mail message is mapped to - * the body of the Camel IN message and the mail headers are mapped to IN - * headers. If this option is set to false then the IN message contains a - * raw javax.mail.Message. You can retrieve this raw message by calling - * exchange.getIn().getBody(javax.mail.Message.class). - */ - private Boolean mapMailMessage; - /** - * The folder to poll. - */ - private String folderName; - /** - * Option to let Camel ignore unsupported charset in the local JVM when - * sending mails. If the charset is unsupported then charset=XXX (where XXX - * represents the unsupported charset) is removed from the content-type and - * it relies on the platform default instead. - */ - private Boolean ignoreUriScheme; - /** - * Whether to limit by unseen mails only. - */ - private Boolean unseen; - /** - * Sets the To email address. Separate multiple email addresses with comma. - */ - private String to; - /** - * Sets the CC email address. Separate multiple email addresses with comma. - */ - private String cc; - /** - * Sets the BCC email address. Separate multiple email addresses with comma. - */ - private String bcc; - /** - * The Reply-To recipients (the receivers of the response mail). Separate - * multiple email addresses with a comma. - */ - private String replyTo; - /** - * Sets the maximum number of messages to consume during a poll. This can be - * used to avoid overloading a mail server if a mailbox folder contains a - * lot of messages. Default value of -1 means no fetch size and all messages - * will be consumed. Setting the value to 0 is a special corner case where - * Camel will not consume any messages at all. - */ - private Integer fetchSize; - /** - * Enable debug mode on the underlying mail framework. The SUN Mail - * framework logs the debug messages to System.out by default. - */ - private Boolean debugMode; - /** - * The connection timeout in milliseconds. - */ - private Integer connectionTimeout; - /** - * To use a dummy security setting for trusting all certificates. Should - * only be used for development mode and not production. - */ - private Boolean dummyTrustManager; - /** - * The mail message content type. Use text/html for HTML mails. - */ - private String contentType; - /** - * Specifies the key to an IN message header that contains an alternative - * email body. For example if you send emails in text/html format and want - * to provide an alternative mail body for non-HTML email clients set the - * alternative mail body with this key as a header. - */ - private String alternativeBodyHeader; - /** - * Whether to use disposition inline or attachment. - */ - private Boolean useInlineAttachments; - /** - * Option to let Camel ignore unsupported charset in the local JVM when - * sending mails. If the charset is unsupported then charset=XXX (where XXX - * represents the unsupported charset) is removed from the content-type and - * it relies on the platform default instead. - */ - private Boolean ignoreUnsupportedCharset; - /** - * Whether the consumer should disconnect after polling. If enabled this - * forces Camel to connect on each poll. - */ - private Boolean disconnect; - /** - * Whether the consumer should close the folder after polling. Setting this - * option to false and having disconnect=false as well then the consumer - * keep the folder open between polls. - */ - private Boolean closeFolder; - /** - * To configure security using SSLContextParameters. - */ - private SSLContextParameters sslContextParameters; - /** - * After processing a mail message it can be copied to a mail folder with - * the given name. You can override this configuration value with a header - * with the key copyTo allowing you to copy messages to folder names - * configured at runtime. - */ - private String copyTo; - /** - * Will mark the javax.mail.Message as peeked before processing the mail - * message. This applies to IMAPMessage messages types only. By using peek - * the mail will not be eager marked as SEEN on the mail server which allows - * us to rollback the mail message if there is an error processing in Camel. - */ - private Boolean peek; - /** - * If the mail consumer cannot retrieve a given mail message then this - * option allows to skip the message and move on to retrieve the next mail - * message. The default behavior would be the consumer throws an exception - * and no mails from the batch would be able to be routed by Camel. - */ - private Boolean skipFailedMessage; - /** - * If the mail consumer cannot retrieve a given mail message then this - * option allows to handle the caused exception by the consumer's error - * handler. By enable the bridge error handler on the consumer then the - * Camel routing error handler can handle the exception instead. The default - * behavior would be the consumer throws an exception and no mails from the - * batch would be able to be routed by Camel. - */ - private Boolean handleFailedMessage; - /** - * To use a custom AttachmentsContentTransferEncodingResolver to resolve - * what content-type-encoding to use for attachments. - */ - private AttachmentsContentTransferEncodingResolver attachmentsContentTransferEncodingResolver; - public MailConfiguration getConfiguration() { + public MailConfigurationNestedConfiguration getConfiguration() { return configuration; } - public void setConfiguration(MailConfiguration configuration) { + public void setConfiguration( + MailConfigurationNestedConfiguration configuration) { this.configuration = configuration; } @@ -254,294 +60,508 @@ public class MailComponentConfiguration { this.contentTypeResolver = contentTypeResolver; } - public JavaMailSender getJavaMailSender() { - return javaMailSender; - } - - public void setJavaMailSender(JavaMailSender javaMailSender) { - this.javaMailSender = javaMailSender; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public Properties getJavaMailProperties() { - return javaMailProperties; - } - - public void setJavaMailProperties(Properties javaMailProperties) { - this.javaMailProperties = javaMailProperties; - } - - public Properties getAdditionalJavaMailProperties() { - return additionalJavaMailProperties; - } - - public void setAdditionalJavaMailProperties( - Properties additionalJavaMailProperties) { - this.additionalJavaMailProperties = additionalJavaMailProperties; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public String getProtocol() { - return protocol; - } - - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - public Session getSession() { - return session; - } - - public void setSession(Session session) { - this.session = session; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public Boolean getDelete() { - return delete; - } - - public void setDelete(Boolean delete) { - this.delete = delete; - } - - public Boolean getMapMailMessage() { - return mapMailMessage; - } - - public void setMapMailMessage(Boolean mapMailMessage) { - this.mapMailMessage = mapMailMessage; - } - - public String getFolderName() { - return folderName; - } - - public void setFolderName(String folderName) { - this.folderName = folderName; - } - - public Boolean getIgnoreUriScheme() { - return ignoreUriScheme; - } - - public void setIgnoreUriScheme(Boolean ignoreUriScheme) { - this.ignoreUriScheme = ignoreUriScheme; - } - - public Boolean getUnseen() { - return unseen; - } - - public void setUnseen(Boolean unseen) { - this.unseen = unseen; - } + public static class MailConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.mail.MailConfiguration.class; + /** + * To use a custom + * {@link org.apache.camel.component.mail.JavaMailSender} for sending + * emails. + */ + @NestedConfigurationProperty + private JavaMailSender javaMailSender; + /** + * The mail server host name + */ + private String host; + /** + * Sets the java mail options. Will clear any default properties and + * only use the properties provided for this method. + */ + private Properties javaMailProperties; + /** + * Sets additional java mail properties, that will append/override any + * default properties that is set based on all the other options. This + * is useful if you need to add some special options but want to keep + * the others as is. + */ + private Properties additionalJavaMailProperties; + /** + * The password for login + */ + private String password; + /** + * The Subject of the message being sent. Note: Setting the subject in + * the header takes precedence over this option. + */ + private String subject; + /** + * The port number of the mail server + */ + private Integer port; + /** + * The protocol for communicating with the mail server + */ + private String protocol; + /** + * Specifies the mail session that camel should use for all mail + * interactions. Useful in scenarios where mail sessions are created and + * managed by some other resource, such as a JavaEE container. If this + * is not specified, Camel automatically creates the mail session for + * you. + */ + private Session session; + /** + * The username for login + */ + private String username; + /** + * The from email address + */ + private String from = "MailConstants.MAIL_DEFAULT_FROM"; + /** + * Deletes the messages after they have been processed. This is done by + * setting the DELETED flag on the mail message. If false, the SEEN flag + * is set instead. As of Camel 2.10 you can override this configuration + * option by setting a header with the key delete to determine if the + * mail should be deleted or not. + */ + private Boolean delete; + /** + * Specifies whether Camel should map the received mail message to Camel + * body/headers. If set to true, the body of the mail message is mapped + * to the body of the Camel IN message and the mail headers are mapped + * to IN headers. If this option is set to false then the IN message + * contains a raw javax.mail.Message. You can retrieve this raw message + * by calling exchange.getIn().getBody(javax.mail.Message.class). + */ + private Boolean mapMailMessage; + /** + * The folder to poll. + */ + private String folderName = "MailConstants.MAIL_DEFAULT_FOLDER"; + /** + * Option to let Camel ignore unsupported charset in the local JVM when + * sending mails. If the charset is unsupported then charset=XXX (where + * XXX represents the unsupported charset) is removed from the + * content-type and it relies on the platform default instead. + */ + private Boolean ignoreUriScheme; + /** + * Whether to limit by unseen mails only. + */ + private Boolean unseen; + /** + * Sets the <tt>To</tt> email address. Separate multiple email addresses + * with comma. + */ + private String to; + /** + * Sets the <tt>CC</tt> email address. Separate multiple email addresses + * with comma. + */ + private String cc; + /** + * Sets the <tt>BCC</tt> email address. Separate multiple email + * addresses with comma. + */ + private String bcc; + /** + * The Reply-To recipients (the receivers of the response mail). + * Separate multiple email addresses with a comma. + */ + private String replyTo; + /** + * Sets the maximum number of messages to consume during a poll. This + * can be used to avoid overloading a mail server, if a mailbox folder + * contains a lot of messages. Default value of -1 means no fetch size + * and all messages will be consumed. Setting the value to 0 is a + * special corner case, where Camel will not consume any messages at + * all. + */ + private Integer fetchSize; + /** + * Enable debug mode on the underlying mail framework. The SUN Mail + * framework logs the debug messages to System.out by default. + */ + private Boolean debugMode; + /** + * The connection timeout in milliseconds. + */ + private Long connectionTimeout; + /** + * To use a dummy security setting for trusting all certificates. Should + * only be used for development mode, and not production. + */ + private Boolean dummyTrustManager; + /** + * The mail message content type. Use text/html for HTML mails. + */ + private String contentType = "text/plain"; + /** + * Specifies the key to an IN message header that contains an + * alternative email body. For example, if you send emails in text/html + * format and want to provide an alternative mail body for non-HTML + * email clients, set the alternative mail body with this key as a + * header. + */ + private String alternativeBodyHeader = "MailConstants.MAIL_ALTERNATIVE_BODY"; + /** + * Whether to use disposition inline or attachment. + */ + private Boolean useInlineAttachments; + /** + * Option to let Camel ignore unsupported charset in the local JVM when + * sending mails. If the charset is unsupported then charset=XXX (where + * XXX represents the unsupported charset) is removed from the + * content-type and it relies on the platform default instead. + */ + private Boolean ignoreUnsupportedCharset; + /** + * Whether the consumer should disconnect after polling. If enabled this + * forces Camel to connect on each poll. + */ + private Boolean disconnect; + /** + * Whether the consumer should close the folder after polling. Setting + * this option to false and having disconnect=false as well, then the + * consumer keep the folder open between polls. + */ + private Boolean closeFolder; + /** + * To configure security using SSLContextParameters. + */ + @NestedConfigurationProperty + private SSLContextParameters sslContextParameters; + /** + * After processing a mail message, it can be copied to a mail folder + * with the given name. You can override this configuration value, with + * a header with the key copyTo, allowing you to copy messages to folder + * names configured at runtime. + */ + private String copyTo; + /** + * Will mark the javax.mail.Message as peeked before processing the mail + * message. This applies to IMAPMessage messages types only. By using + * peek the mail will not be eager marked as SEEN on the mail server, + * which allows us to rollback the mail message if there is an error + * processing in Camel. + */ + private Boolean peek; + /** + * If the mail consumer cannot retrieve a given mail message, then this + * option allows to skip the message and move on to retrieve the next + * mail message. + * <p/> + * The default behavior would be the consumer throws an exception and no + * mails from the batch would be able to be routed by Camel. + */ + private Boolean skipFailedMessage; + /** + * If the mail consumer cannot retrieve a given mail message, then this + * option allows to handle the caused exception by the consumer's error + * handler. By enable the bridge error handler on the consumer, then the + * Camel routing error handler can handle the exception instead. + * <p/> + * The default behavior would be the consumer throws an exception and no + * mails from the batch would be able to be routed by Camel. + */ + private Boolean handleFailedMessage; + /** + * To use a custom AttachmentsContentTransferEncodingResolver to resolve + * what content-type-encoding to use for attachments. + */ + @NestedConfigurationProperty + private AttachmentsContentTransferEncodingResolver attachmentsContentTransferEncodingResolver; + + public JavaMailSender getJavaMailSender() { + return javaMailSender; + } + + public void setJavaMailSender(JavaMailSender javaMailSender) { + this.javaMailSender = javaMailSender; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public Properties getJavaMailProperties() { + return javaMailProperties; + } + + public void setJavaMailProperties(Properties javaMailProperties) { + this.javaMailProperties = javaMailProperties; + } + + public Properties getAdditionalJavaMailProperties() { + return additionalJavaMailProperties; + } + + public void setAdditionalJavaMailProperties( + Properties additionalJavaMailProperties) { + this.additionalJavaMailProperties = additionalJavaMailProperties; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public Session getSession() { + return session; + } + + public void setSession(Session session) { + this.session = session; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getFrom() { + return from; + } + + public void setFrom(String from) { + this.from = from; + } + + public Boolean getDelete() { + return delete; + } + + public void setDelete(Boolean delete) { + this.delete = delete; + } - public String getTo() { - return to; - } + public Boolean getMapMailMessage() { + return mapMailMessage; + } - public void setTo(String to) { - this.to = to; - } + public void setMapMailMessage(Boolean mapMailMessage) { + this.mapMailMessage = mapMailMessage; + } - public String getCc() { - return cc; - } + public String getFolderName() { + return folderName; + } - public void setCc(String cc) { - this.cc = cc; - } - - public String getBcc() { - return bcc; - } - - public void setBcc(String bcc) { - this.bcc = bcc; - } + public void setFolderName(String folderName) { + this.folderName = folderName; + } - public String getReplyTo() { - return replyTo; - } + public Boolean getIgnoreUriScheme() { + return ignoreUriScheme; + } - public void setReplyTo(String replyTo) { - this.replyTo = replyTo; - } + public void setIgnoreUriScheme(Boolean ignoreUriScheme) { + this.ignoreUriScheme = ignoreUriScheme; + } - public Integer getFetchSize() { - return fetchSize; - } + public Boolean getUnseen() { + return unseen; + } - public void setFetchSize(Integer fetchSize) { - this.fetchSize = fetchSize; - } + public void setUnseen(Boolean unseen) { + this.unseen = unseen; + } - public Boolean getDebugMode() { - return debugMode; - } + public String getTo() { + return to; + } - public void setDebugMode(Boolean debugMode) { - this.debugMode = debugMode; - } + public void setTo(String to) { + this.to = to; + } - public Integer getConnectionTimeout() { - return connectionTimeout; - } + public String getCc() { + return cc; + } - public void setConnectionTimeout(Integer connectionTimeout) { - this.connectionTimeout = connectionTimeout; - } + public void setCc(String cc) { + this.cc = cc; + } - public Boolean getDummyTrustManager() { - return dummyTrustManager; - } + public String getBcc() { + return bcc; + } - public void setDummyTrustManager(Boolean dummyTrustManager) { - this.dummyTrustManager = dummyTrustManager; - } + public void setBcc(String bcc) { + this.bcc = bcc; + } - public String getContentType() { - return contentType; - } + public String getReplyTo() { + return replyTo; + } - public void setContentType(String contentType) { - this.contentType = contentType; - } + public void setReplyTo(String replyTo) { + this.replyTo = replyTo; + } - public String getAlternativeBodyHeader() { - return alternativeBodyHeader; - } + public Integer getFetchSize() { + return fetchSize; + } - public void setAlternativeBodyHeader(String alternativeBodyHeader) { - this.alternativeBodyHeader = alternativeBodyHeader; - } + public void setFetchSize(Integer fetchSize) { + this.fetchSize = fetchSize; + } - public Boolean getUseInlineAttachments() { - return useInlineAttachments; - } + public Boolean getDebugMode() { + return debugMode; + } - public void setUseInlineAttachments(Boolean useInlineAttachments) { - this.useInlineAttachments = useInlineAttachments; - } + public void setDebugMode(Boolean debugMode) { + this.debugMode = debugMode; + } - public Boolean getIgnoreUnsupportedCharset() { - return ignoreUnsupportedCharset; - } + public Long getConnectionTimeout() { + return connectionTimeout; + } - public void setIgnoreUnsupportedCharset(Boolean ignoreUnsupportedCharset) { - this.ignoreUnsupportedCharset = ignoreUnsupportedCharset; - } + public void setConnectionTimeout(Long connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } - public Boolean getDisconnect() { - return disconnect; - } + public Boolean getDummyTrustManager() { + return dummyTrustManager; + } - public void setDisconnect(Boolean disconnect) { - this.disconnect = disconnect; - } + public void setDummyTrustManager(Boolean dummyTrustManager) { + this.dummyTrustManager = dummyTrustManager; + } - public Boolean getCloseFolder() { - return closeFolder; - } + public String getContentType() { + return contentType; + } - public void setCloseFolder(Boolean closeFolder) { - this.closeFolder = closeFolder; - } + public void setContentType(String contentType) { + this.contentType = contentType; + } - public SSLContextParameters getSslContextParameters() { - return sslContextParameters; - } + public String getAlternativeBodyHeader() { + return alternativeBodyHeader; + } - public void setSslContextParameters( - SSLContextParameters sslContextParameters) { - this.sslContextParameters = sslContextParameters; - } + public void setAlternativeBodyHeader(String alternativeBodyHeader) { + this.alternativeBodyHeader = alternativeBodyHeader; + } - public String getCopyTo() { - return copyTo; - } + public Boolean getUseInlineAttachments() { + return useInlineAttachments; + } - public void setCopyTo(String copyTo) { - this.copyTo = copyTo; - } + public void setUseInlineAttachments(Boolean useInlineAttachments) { + this.useInlineAttachments = useInlineAttachments; + } - public Boolean getPeek() { - return peek; - } + public Boolean getIgnoreUnsupportedCharset() { + return ignoreUnsupportedCharset; + } - public void setPeek(Boolean peek) { - this.peek = peek; - } + public void setIgnoreUnsupportedCharset(Boolean ignoreUnsupportedCharset) { + this.ignoreUnsupportedCharset = ignoreUnsupportedCharset; + } - public Boolean getSkipFailedMessage() { - return skipFailedMessage; - } + public Boolean getDisconnect() { + return disconnect; + } - public void setSkipFailedMessage(Boolean skipFailedMessage) { - this.skipFailedMessage = skipFailedMessage; - } + public void setDisconnect(Boolean disconnect) { + this.disconnect = disconnect; + } - public Boolean getHandleFailedMessage() { - return handleFailedMessage; - } + public Boolean getCloseFolder() { + return closeFolder; + } - public void setHandleFailedMessage(Boolean handleFailedMessage) { - this.handleFailedMessage = handleFailedMessage; - } + public void setCloseFolder(Boolean closeFolder) { + this.closeFolder = closeFolder; + } - public AttachmentsContentTransferEncodingResolver getAttachmentsContentTransferEncodingResolver() { - return attachmentsContentTransferEncodingResolver; - } + public SSLContextParameters getSslContextParameters() { + return sslContextParameters; + } - public void setAttachmentsContentTransferEncodingResolver( - AttachmentsContentTransferEncodingResolver attachmentsContentTransferEncodingResolver) { - this.attachmentsContentTransferEncodingResolver = attachmentsContentTransferEncodingResolver; + public void setSslContextParameters( + SSLContextParameters sslContextParameters) { + this.sslContextParameters = sslContextParameters; + } + + public String getCopyTo() { + return copyTo; + } + + public void setCopyTo(String copyTo) { + this.copyTo = copyTo; + } + + public Boolean getPeek() { + return peek; + } + + public void setPeek(Boolean peek) { + this.peek = peek; + } + + public Boolean getSkipFailedMessage() { + return skipFailedMessage; + } + + public void setSkipFailedMessage(Boolean skipFailedMessage) { + this.skipFailedMessage = skipFailedMessage; + } + + public Boolean getHandleFailedMessage() { + return handleFailedMessage; + } + + public void setHandleFailedMessage(Boolean handleFailedMessage) { + this.handleFailedMessage = handleFailedMessage; + } + + public AttachmentsContentTransferEncodingResolver getAttachmentsContentTransferEncodingResolver() { + return attachmentsContentTransferEncodingResolver; + } + + public void setAttachmentsContentTransferEncodingResolver( + AttachmentsContentTransferEncodingResolver attachmentsContentTransferEncodingResolver) { + this.attachmentsContentTransferEncodingResolver = attachmentsContentTransferEncodingResolver; + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java b/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java index 7866bc1..475d9fe 100644 --- a/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java +++ b/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java @@ -45,6 +45,26 @@ public class MetricsComponentAutoConfiguration { Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component; http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java b/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java index b0f478e..a8ef666 100644 --- a/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java +++ b/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.metrics.springboot; import com.codahale.metrics.MetricRegistry; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * To collect various metrics directly from Camel routes using the DropWizard @@ -31,6 +32,7 @@ public class MetricsComponentConfiguration { /** * To use a custom configured MetricRegistry. */ + @NestedConfigurationProperty private MetricRegistry metricRegistry; public MetricRegistry getMetricRegistry() { http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java b/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java index b5e3524..7738c08 100644 --- a/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java +++ b/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class Mina2ComponentAutoConfiguration { Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component; http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java b/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java index edb49b5..1cd6587 100644 --- a/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java +++ b/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java @@ -18,12 +18,12 @@ package org.apache.camel.component.mina2.springboot; import java.util.List; import org.apache.camel.LoggingLevel; -import org.apache.camel.component.mina2.Mina2Configuration; +import org.apache.camel.component.mina2.Mina2Component; import org.apache.camel.component.mina2.Mina2TextLineDelimiter; import org.apache.camel.util.jsse.SSLContextParameters; -import org.apache.mina.core.filterchain.IoFilter; import org.apache.mina.filter.codec.ProtocolCodecFactory; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * Socket level networking using TCP or UDP with the Apache Mina 2.x library. @@ -34,344 +34,355 @@ import org.springframework.boot.context.properties.ConfigurationProperties; public class Mina2ComponentConfiguration { /** - * To use the shared mina configuration. Properties of the shared - * configuration can also be set individually. + * To use the shared mina configuration. */ - private Mina2Configuration configuration; - /** - * Protocol to use - */ - private String protocol; - /** - * Hostname to use. Use localhost or 0.0.0.0 for local server as consumer. - * For producer use the hostname or ip address of the remote server. - */ - private String host; - /** - * Port number - */ - private Integer port; - /** - * Setting to set endpoint as one-way or request-response. - */ - private Boolean sync; - /** - * Only used for TCP. If no codec is specified you can use this flag to - * indicate a text line based codec; if not specified or the value is false - * then Object Serialization is assumed over TCP. - */ - private Boolean textline; - /** - * Only used for TCP and if textline=true. Sets the text line delimiter to - * use. If none provided Camel will use DEFAULT. This delimiter is used to - * mark the end of text. - */ - private Mina2TextLineDelimiter textlineDelimiter; - /** - * To use a custom minda codec implementation. - */ - private ProtocolCodecFactory codec; - /** - * You can configure the encoding (a charset name) to use for the TCP - * textline codec and the UDP protocol. If not provided Camel will use the - * JVM default Charset - */ - private String encoding; - /** - * You can configure the timeout that specifies how long to wait for a - * response from a remote server. The timeout unit is in milliseconds so - * 60000 is 60 seconds. - */ - private long timeout; - /** - * Sessions can be lazily created to avoid exceptions if the remote server - * is not up and running when the Camel producer is started. - */ - private Boolean lazySessionCreation; - /** - * Only used for TCP. You can transfer the exchange over the wire instead of - * just the body. The following fields are transferred: In body Out body - * fault body In headers Out headers fault headers exchange properties - * exchange exception. This requires that the objects are serializable. - * Camel will exclude any non-serializable objects and log it at WARN level. - */ - private Boolean transferExchange; - /** - * To set the textline protocol encoder max line length. By default the - * default value of Mina itself is used which are Integer.MAX_VALUE. - */ - private Integer encoderMaxLineLength; - /** - * To set the textline protocol decoder max line length. By default the - * default value of Mina itself is used which are 1024. - */ - private Integer decoderMaxLineLength; - /** - * You can enable the Apache MINA logging filter. Apache MINA uses slf4j - * logging at INFO level to log all input and output. - */ - private Boolean minaLogger; - /** - * You can set a list of Mina IoFilters to use. - */ - private List<IoFilter> filters; - /** - * The mina component installs a default codec if both codec is null and - * textline is false. Setting allowDefaultCodec to false prevents the mina - * component from installing a default codec as the first element in the - * filter chain. This is useful in scenarios where another filter must be - * the first in the filter chain like the SSL filter. - */ - private Boolean allowDefaultCodec; - /** - * Whether or not to disconnect(close) from Mina session right after use. - * Can be used for both consumer and producer. - */ - private Boolean disconnect; - /** - * If sync is enabled then this option dictates MinaConsumer if it should - * disconnect where there is no reply to send back. - */ - private Boolean disconnectOnNoReply; - /** - * If sync is enabled this option dictates MinaConsumer which logging level - * to use when logging a there is no reply to send back. - */ - private LoggingLevel noReplyLogLevel; - /** - * To configure SSL security. - */ - private SSLContextParameters sslContextParameters; - /** - * Whether to auto start SSL handshake. - */ - private Boolean autoStartTls; - /** - * Number of worker threads in the worker pool for TCP and UDP - */ - private Integer maximumPoolSize; - /** - * Whether to use ordered thread pool to ensure events are processed orderly - * on the same channel. - */ - private Boolean orderedThreadPoolExecutor; - /** - * Whether to create the InetAddress once and reuse. Setting this to false - * allows to pickup DNS changes in the network. - */ - private Boolean cachedAddress; - /** - * If the clientMode is true mina consumer will connect the address as a TCP - * client. - */ - private Boolean clientMode; + private Mina2ConfigurationNestedConfiguration configuration; - public Mina2Configuration getConfiguration() { + public Mina2ConfigurationNestedConfiguration getConfiguration() { return configuration; } - public void setConfiguration(Mina2Configuration configuration) { + public void setConfiguration( + Mina2ConfigurationNestedConfiguration configuration) { this.configuration = configuration; } - public String getProtocol() { - return protocol; - } - - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public Boolean getSync() { - return sync; - } - - public void setSync(Boolean sync) { - this.sync = sync; - } + public static class Mina2ConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.mina2.Mina2Configuration.class; + /** + * Protocol to use + */ + private String protocol; + /** + * Hostname to use. Use localhost or 0.0.0.0 for local server as + * consumer. For producer use the hostname or ip address of the remote + * server. + */ + private String host; + /** + * Port number + */ + private Integer port; + /** + * Setting to set endpoint as one-way or request-response. + */ + private Boolean sync; + /** + * Only used for TCP. If no codec is specified, you can use this flag to + * indicate a text line based codec; if not specified or the value is + * false, then Object Serialization is assumed over TCP. + */ + private Boolean textline; + /** + * Only used for TCP and if textline=true. Sets the text line delimiter + * to use. If none provided, Camel will use DEFAULT. This delimiter is + * used to mark the end of text. + */ + private Mina2TextLineDelimiter textlineDelimiter; + /** + * To use a custom minda codec implementation. + */ + @NestedConfigurationProperty + private ProtocolCodecFactory codec; + /** + * You can configure the encoding (a charset name) to use for the TCP + * textline codec and the UDP protocol. If not provided, Camel will use + * the JVM default Charset + */ + private String encoding; + /** + * You can configure the timeout that specifies how long to wait for a + * response from a remote server. The timeout unit is in milliseconds, + * so 60000 is 60 seconds. + */ + private Long timeout; + /** + * Sessions can be lazily created to avoid exceptions, if the remote + * server is not up and running when the Camel producer is started. + */ + private Boolean lazySessionCreation; + /** + * Only used for TCP. You can transfer the exchange over the wire + * instead of just the body. The following fields are transferred: In + * body, Out body, fault body, In headers, Out headers, fault headers, + * exchange properties, exchange exception. This requires that the + * objects are serializable. Camel will exclude any non-serializable + * objects and log it at WARN level. + */ + private Boolean transferExchange; + /** + * To set the textline protocol encoder max line length. By default the + * default value of Mina itself is used which are Integer.MAX_VALUE. + */ + private Integer encoderMaxLineLength; + /** + * To set the textline protocol decoder max line length. By default the + * default value of Mina itself is used which are 1024. + */ + private Integer decoderMaxLineLength; + /** + * You can enable the Apache MINA logging filter. Apache MINA uses slf4j + * logging at INFO level to log all input and output. + */ + private Boolean minaLogger; + /** + * You can set a list of Mina IoFilters to use. + */ + private List filters; + /** + * The mina component installs a default codec if both, codec is null + * and textline is false. Setting allowDefaultCodec to false prevents + * the mina component from installing a default codec as the first + * element in the filter chain. This is useful in scenarios where + * another filter must be the first in the filter chain, like the SSL + * filter. + */ + private Boolean allowDefaultCodec; + /** + * Whether or not to disconnect(close) from Mina session right after + * use. Can be used for both consumer and producer. + */ + private Boolean disconnect; + /** + * If sync is enabled then this option dictates MinaConsumer if it + * should disconnect where there is no reply to send back. + */ + private Boolean disconnectOnNoReply; + /** + * If sync is enabled this option dictates MinaConsumer which logging + * level to use when logging a there is no reply to send back. + */ + private LoggingLevel noReplyLogLevel = LoggingLevel.WARN; + /** + * To configure SSL security. + */ + @NestedConfigurationProperty + private SSLContextParameters sslContextParameters; + /** + * Whether to auto start SSL handshake. + */ + private Boolean autoStartTls; + /** + * Number of worker threads in the worker pool for TCP and UDP + */ + private Integer maximumPoolSize; + /** + * Whether to use ordered thread pool, to ensure events are processed + * orderly on the same channel. + */ + private Boolean orderedThreadPoolExecutor; + /** + * Whether to create the InetAddress once and reuse. Setting this to + * false allows to pickup DNS changes in the network. + */ + private Boolean cachedAddress; + /** + * If the clientMode is true, mina consumer will connect the address as + * a TCP client. + */ + private Boolean clientMode; + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public Boolean getSync() { + return sync; + } + + public void setSync(Boolean sync) { + this.sync = sync; + } + + public Boolean getTextline() { + return textline; + } + + public void setTextline(Boolean textline) { + this.textline = textline; + } + + public Mina2TextLineDelimiter getTextlineDelimiter() { + return textlineDelimiter; + } + + public void setTextlineDelimiter( + Mina2TextLineDelimiter textlineDelimiter) { + this.textlineDelimiter = textlineDelimiter; + } + + public ProtocolCodecFactory getCodec() { + return codec; + } + + public void setCodec(ProtocolCodecFactory codec) { + this.codec = codec; + } + + public String getEncoding() { + return encoding; + } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public Long getTimeout() { + return timeout; + } + + public void setTimeout(Long timeout) { + this.timeout = timeout; + } + + public Boolean getLazySessionCreation() { + return lazySessionCreation; + } + + public void setLazySessionCreation(Boolean lazySessionCreation) { + this.lazySessionCreation = lazySessionCreation; + } + + public Boolean getTransferExchange() { + return transferExchange; + } + + public void setTransferExchange(Boolean transferExchange) { + this.transferExchange = transferExchange; + } + + public Integer getEncoderMaxLineLength() { + return encoderMaxLineLength; + } + + public void setEncoderMaxLineLength(Integer encoderMaxLineLength) { + this.encoderMaxLineLength = encoderMaxLineLength; + } + + public Integer getDecoderMaxLineLength() { + return decoderMaxLineLength; + } + + public void setDecoderMaxLineLength(Integer decoderMaxLineLength) { + this.decoderMaxLineLength = decoderMaxLineLength; + } + + public Boolean getMinaLogger() { + return minaLogger; + } + + public void setMinaLogger(Boolean minaLogger) { + this.minaLogger = minaLogger; + } + + public List getFilters() { + return filters; + } + + public void setFilters(List filters) { + this.filters = filters; + } + + public Boolean getAllowDefaultCodec() { + return allowDefaultCodec; + } + + public void setAllowDefaultCodec(Boolean allowDefaultCodec) { + this.allowDefaultCodec = allowDefaultCodec; + } + + public Boolean getDisconnect() { + return disconnect; + } + + public void setDisconnect(Boolean disconnect) { + this.disconnect = disconnect; + } + + public Boolean getDisconnectOnNoReply() { + return disconnectOnNoReply; + } + + public void setDisconnectOnNoReply(Boolean disconnectOnNoReply) { + this.disconnectOnNoReply = disconnectOnNoReply; + } + + public LoggingLevel getNoReplyLogLevel() { + return noReplyLogLevel; + } - public Boolean getTextline() { - return textline; - } + public void setNoReplyLogLevel(LoggingLevel noReplyLogLevel) { + this.noReplyLogLevel = noReplyLogLevel; + } - public void setTextline(Boolean textline) { - this.textline = textline; - } - - public Mina2TextLineDelimiter getTextlineDelimiter() { - return textlineDelimiter; - } - - public void setTextlineDelimiter(Mina2TextLineDelimiter textlineDelimiter) { - this.textlineDelimiter = textlineDelimiter; - } - - public ProtocolCodecFactory getCodec() { - return codec; - } - - public void setCodec(ProtocolCodecFactory codec) { - this.codec = codec; - } - - public String getEncoding() { - return encoding; - } - - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - public long getTimeout() { - return timeout; - } - - public void setTimeout(long timeout) { - this.timeout = timeout; - } - - public Boolean getLazySessionCreation() { - return lazySessionCreation; - } - - public void setLazySessionCreation(Boolean lazySessionCreation) { - this.lazySessionCreation = lazySessionCreation; - } - - public Boolean getTransferExchange() { - return transferExchange; - } - - public void setTransferExchange(Boolean transferExchange) { - this.transferExchange = transferExchange; - } - - public Integer getEncoderMaxLineLength() { - return encoderMaxLineLength; - } - - public void setEncoderMaxLineLength(Integer encoderMaxLineLength) { - this.encoderMaxLineLength = encoderMaxLineLength; - } - - public Integer getDecoderMaxLineLength() { - return decoderMaxLineLength; - } - - public void setDecoderMaxLineLength(Integer decoderMaxLineLength) { - this.decoderMaxLineLength = decoderMaxLineLength; - } - - public Boolean getMinaLogger() { - return minaLogger; - } - - public void setMinaLogger(Boolean minaLogger) { - this.minaLogger = minaLogger; - } - - public List<IoFilter> getFilters() { - return filters; - } - - public void setFilters(List<IoFilter> filters) { - this.filters = filters; - } - - public Boolean getAllowDefaultCodec() { - return allowDefaultCodec; - } - - public void setAllowDefaultCodec(Boolean allowDefaultCodec) { - this.allowDefaultCodec = allowDefaultCodec; - } - - public Boolean getDisconnect() { - return disconnect; - } - - public void setDisconnect(Boolean disconnect) { - this.disconnect = disconnect; - } - - public Boolean getDisconnectOnNoReply() { - return disconnectOnNoReply; - } - - public void setDisconnectOnNoReply(Boolean disconnectOnNoReply) { - this.disconnectOnNoReply = disconnectOnNoReply; - } - - public LoggingLevel getNoReplyLogLevel() { - return noReplyLogLevel; - } - - public void setNoReplyLogLevel(LoggingLevel noReplyLogLevel) { - this.noReplyLogLevel = noReplyLogLevel; - } - - public SSLContextParameters getSslContextParameters() { - return sslContextParameters; - } - - public void setSslContextParameters( - SSLContextParameters sslContextParameters) { - this.sslContextParameters = sslContextParameters; - } - - public Boolean getAutoStartTls() { - return autoStartTls; - } - - public void setAutoStartTls(Boolean autoStartTls) { - this.autoStartTls = autoStartTls; - } - - public Integer getMaximumPoolSize() { - return maximumPoolSize; - } - - public void setMaximumPoolSize(Integer maximumPoolSize) { - this.maximumPoolSize = maximumPoolSize; - } - - public Boolean getOrderedThreadPoolExecutor() { - return orderedThreadPoolExecutor; - } - - public void setOrderedThreadPoolExecutor(Boolean orderedThreadPoolExecutor) { - this.orderedThreadPoolExecutor = orderedThreadPoolExecutor; - } - - public Boolean getCachedAddress() { - return cachedAddress; - } - - public void setCachedAddress(Boolean cachedAddress) { - this.cachedAddress = cachedAddress; - } - - public Boolean getClientMode() { - return clientMode; - } + public SSLContextParameters getSslContextParameters() { + return sslContextParameters; + } - public void setClientMode(Boolean clientMode) { - this.clientMode = clientMode; + public void setSslContextParameters( + SSLContextParameters sslContextParameters) { + this.sslContextParameters = sslContextParameters; + } + + public Boolean getAutoStartTls() { + return autoStartTls; + } + + public void setAutoStartTls(Boolean autoStartTls) { + this.autoStartTls = autoStartTls; + } + + public Integer getMaximumPoolSize() { + return maximumPoolSize; + } + + public void setMaximumPoolSize(Integer maximumPoolSize) { + this.maximumPoolSize = maximumPoolSize; + } + + public Boolean getOrderedThreadPoolExecutor() { + return orderedThreadPoolExecutor; + } + + public void setOrderedThreadPoolExecutor( + Boolean orderedThreadPoolExecutor) { + this.orderedThreadPoolExecutor = orderedThreadPoolExecutor; + } + + public Boolean getCachedAddress() { + return cachedAddress; + } + + public void setCachedAddress(Boolean cachedAddress) { + this.cachedAddress = cachedAddress; + } + + public Boolean getClientMode() { + return clientMode; + } + + public void setClientMode(Boolean clientMode) { + this.clientMode = clientMode; + } } } \ No newline at end of file
