http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java b/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java index f7d9cc8..6f9d239 100644 --- a/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java +++ b/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConfiguration.java @@ -17,10 +17,11 @@ package org.apache.camel.component.smpp.springboot; import java.util.Map; -import org.apache.camel.component.smpp.SmppConfiguration; +import org.apache.camel.component.smpp.SmppComponent; import org.apache.camel.component.smpp.SmppSplittingPolicy; import org.jsmpp.session.SessionStateListener; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * To send and receive SMS using a SMSC (Short Message Service Center). @@ -31,509 +32,604 @@ import org.springframework.boot.context.properties.ConfigurationProperties; public class SmppComponentConfiguration { /** - * To use the shared SmppConfiguration as configuration. Properties of the - * shared configuration can also be set individually. + * To use the shared SmppConfiguration as configuration. */ - private SmppConfiguration configuration; - /** - * Hostname for the SMSC server to use. - */ - private String host; - /** - * Port number for the SMSC server to use. - */ - private Integer port; - /** - * The system id (username) for connecting to SMSC server. - */ - private String systemId; - /** - * Defines the data coding according the SMPP 3.4 specification section - * 5.2.19. Example data encodings are: 0: SMSC Default Alphabet 3: Latin 1 - * (ISO-8859-1) 4: Octet unspecified (8-bit binary) 8: UCS2 (ISO/IEC-10646) - * 13: Extended Kanji JIS(X 0212-1990) - */ - private Byte dataCoding; - /** - * Defines encoding of data according the SMPP 3.4 specification section - * 5.2.19. 0: SMSC Default Alphabet 4: 8 bit Alphabet 8: UCS2 Alphabet - */ - private Byte alphabet; - /** - * Defines the encoding scheme of the short message user data. Only for - * SubmitSm ReplaceSm and SubmitMulti. - */ - private String encoding; - /** - * The password for connecting to SMSC server. - */ - private String password; - /** - * Defines the interval in milliseconds between the confidence checks. The - * confidence check is used to test the communication path between an ESME - * and an SMSC. - */ - private Integer enquireLinkTimer; - /** - * Defines the maximum period of inactivity allowed after a transaction - * after which an SMPP entity may assume that the session is no longer - * active. This timer may be active on either communicating SMPP entity - * (i.e. SMSC or ESME). - */ - private Integer transactionTimer; - /** - * This parameter is used to categorize the type of ESME (External Short - * Message Entity) that is binding to the SMSC (max. 13 characters). - */ - private String systemType; - /** - * Is used to request an SMSC delivery receipt and/or SME originated - * acknowledgements. The following values are defined: 0: No SMSC delivery - * receipt requested. 1: SMSC delivery receipt requested where final - * delivery outcome is success or failure. 2: SMSC delivery receipt - * requested where the final delivery outcome is delivery failure. - */ - private Byte registeredDelivery; - /** - * The service type parameter can be used to indicate the SMS Application - * service associated with the message. The following generic service_types - * are defined: CMT: Cellular Messaging CPT: Cellular Paging VMN: Voice Mail - * Notification VMA: Voice Mail Alerting WAP: Wireless Application Protocol - * USSD: Unstructured Supplementary Services Data - */ - private String serviceType; - /** - * Defines the type of number (TON) to be used in the SME originator address - * parameters. The following TON values are defined: 0: Unknown 1: - * International 2: National 3: Network Specific 4: Subscriber Number 5: - * Alphanumeric 6: Abbreviated - */ - private Byte sourceAddrTon; - /** - * Defines the type of number (TON) to be used in the SME destination - * address parameters. Only for SubmitSm SubmitMulti CancelSm and DataSm. - * The following TON values are defined: 0: Unknown 1: International 2: - * National 3: Network Specific 4: Subscriber Number 5: Alphanumeric 6: - * Abbreviated - */ - private Byte destAddrTon; - /** - * Defines the numeric plan indicator (NPI) to be used in the SME originator - * address parameters. The following NPI values are defined: 0: Unknown 1: - * ISDN (E163/E164) 2: Data (X.121) 3: Telex (F.69) 6: Land Mobile (E.212) - * 8: National 9: Private 10: ERMES 13: Internet (IP) 18: WAP Client Id (to - * be defined by WAP Forum) - */ - private Byte sourceAddrNpi; - /** - * Defines the type of number (TON) to be used in the SME destination - * address parameters. Only for SubmitSm SubmitMulti CancelSm and DataSm. - * The following NPI values are defined: 0: Unknown 1: ISDN (E163/E164) 2: - * Data (X.121) 3: Telex (F.69) 6: Land Mobile (E.212) 8: National 9: - * Private 10: ERMES 13: Internet (IP) 18: WAP Client Id (to be defined by - * WAP Forum) - */ - private Byte destAddrNpi; - /** - * The protocol id - */ - private Byte protocolId; - /** - * Allows the originating SME to assign a priority level to the short - * message. Only for SubmitSm and SubmitMulti. Four Priority Levels are - * supported: 0: Level 0 (lowest) priority 1: Level 1 priority 2: Level 2 - * priority 3: Level 3 (highest) priority - */ - private Byte priorityFlag; - /** - * Used to request the SMSC to replace a previously submitted message that - * is still pending delivery. The SMSC will replace an existing message - * provided that the source address destination address and service type - * match the same fields in the new message. The following replace if - * present flag values are defined: 0: Don't replace 1: Replace - */ - private Byte replaceIfPresentFlag; - /** - * Defines the address of SME (Short Message Entity) which originated this - * message. - */ - private String sourceAddr; - /** - * Defines the destination SME address. For mobile terminated messages this - * is the directory number of the recipient MS. Only for SubmitSm - * SubmitMulti CancelSm and DataSm. - */ - private String destAddr; - /** - * Defines the type of number (TON) to be used in the SME. The following TON - * values are defined: 0: Unknown 1: International 2: National 3: Network - * Specific 4: Subscriber Number 5: Alphanumeric 6: Abbreviated - */ - private Byte typeOfNumber; - /** - * Defines the numeric plan indicator (NPI) to be used in the SME. The - * following NPI values are defined: 0: Unknown 1: ISDN (E163/E164) 2: Data - * (X.121) 3: Telex (F.69) 6: Land Mobile (E.212) 8: National 9: Private 10: - * ERMES 13: Internet (IP) 18: WAP Client Id (to be defined by WAP Forum) - */ - private Byte numberingPlanIndicator; - /** - * Whether using SSL with the smpps protocol - */ - private Boolean usingSSL; - /** - * Defines the initial delay in milliseconds after the consumer/producer - * tries to reconnect to the SMSC after the connection was lost. - */ - private long initialReconnectDelay; - /** - * Defines the interval in milliseconds between the reconnect attempts if - * the connection to the SMSC was lost and the previous was not succeed. - */ - private long reconnectDelay; - /** - * Sessions can be lazily created to avoid exceptions if the SMSC is not - * available when the Camel producer is started. Camel will check the in - * message headers 'CamelSmppSystemId' and 'CamelSmppPassword' of the first - * exchange. If they are present Camel will use these data to connect to the - * SMSC. - */ - private Boolean lazySessionCreation; - /** - * If you need to tunnel SMPP through a HTTP proxy set this attribute to the - * hostname or ip address of your HTTP proxy. - */ - private String httpProxyHost; - /** - * If you need to tunnel SMPP through a HTTP proxy set this attribute to the - * port of your HTTP proxy. - */ - private Integer httpProxyPort; - /** - * If your HTTP proxy requires basic authentication set this attribute to - * the username required for your HTTP proxy. - */ - private String httpProxyUsername; - /** - * If your HTTP proxy requires basic authentication set this attribute to - * the password required for your HTTP proxy. - */ - private String httpProxyPassword; - /** - * You can refer to a org.jsmpp.session.SessionStateListener in the Registry - * to receive callbacks when the session state changed. - */ - private SessionStateListener sessionStateListener; - /** - * You can specify the address range for the SmppConsumer as defined in - * section 5.2.7 of the SMPP 3.4 specification. The SmppConsumer will - * receive messages only from SMSC's which target an address (MSISDN or IP - * address) within this range. - */ - private String addressRange; - /** - * You can specify a policy for handling long messages: ALLOW - the default - * long messages are split to 140 bytes per message TRUNCATE - long messages - * are split and only the first fragment will be sent to the SMSC. Some - * carriers drop subsequent fragments so this reduces load on the SMPP - * connection sending parts of a message that will never be delivered. - * REJECT - if a message would need to be split it is rejected with an SMPP - * NegativeResponseException and the reason code signifying the message is - * too long. - */ - private SmppSplittingPolicy splittingPolicy; - /** - * These headers will be passed to the proxy server while establishing the - * connection. - */ - private Map<String, String> proxyHeaders; + private SmppConfigurationNestedConfiguration configuration; - public SmppConfiguration getConfiguration() { + public SmppConfigurationNestedConfiguration getConfiguration() { return configuration; } - public void setConfiguration(SmppConfiguration configuration) { + public void setConfiguration( + SmppConfigurationNestedConfiguration configuration) { this.configuration = configuration; } - 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 String getSystemId() { - return systemId; - } - - public void setSystemId(String systemId) { - this.systemId = systemId; - } - - public Byte getDataCoding() { - return dataCoding; - } - - public void setDataCoding(Byte dataCoding) { - this.dataCoding = dataCoding; - } + public static class SmppConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.smpp.SmppConfiguration.class; + /** + * Hostname for the SMSC server to use. + */ + private String host = "localhost"; + /** + * Port number for the SMSC server to use. + */ + private Integer port; + /** + * The system id (username) for connecting to SMSC server. + */ + private String systemId = "smppclient"; + private String password; + /** + * Defines the data coding according the SMPP 3.4 specification, section + * 5.2.19. Example data encodings are: + * <ul> + * <li>0: SMSC Default Alphabet</li> + * <li>3: Latin 1 (ISO-8859-1)</li> + * <li>4: Octet unspecified (8-bit binary)</li> + * <li>8: UCS2 (ISO/IEC-10646)</li> + * <li>13: Extended Kanji JIS(X 0212-1990)</li> + * </ul> + */ + private Byte dataCoding; + /** + * Defines encoding of data according the SMPP 3.4 specification, + * section 5.2.19. + * <ul> + * <li>0: SMSC Default Alphabet + * <li>4: 8 bit Alphabet</li> + * <li>8: UCS2 Alphabet</li></li> + * </ul> + */ + private Byte alphabet; + /** + * Defines the encoding scheme of the short message user data. Only for + * SubmitSm, ReplaceSm and SubmitMulti. + */ + private String encoding = "ISO-8859-1"; + /** + * Defines the interval in milliseconds between the confidence checks. + * The confidence check is used to test the communication path between + * an ESME and an SMSC. + */ + private Integer enquireLinkTimer; + /** + * Defines the maximum period of inactivity allowed after a transaction, + * after which an SMPP entity may assume that the session is no longer + * active. This timer may be active on either communicating SMPP entity + * (i.e. SMSC or ESME). + */ + private Integer transactionTimer; + /** + * This parameter is used to categorize the type of ESME (External Short + * Message Entity) that is binding to the SMSC (max. 13 characters). + */ + private String systemType = "cp"; + /** + * Is used to request an SMSC delivery receipt and/or SME originated + * acknowledgements. The following values are defined: + * <ul> + * <li>0: No SMSC delivery receipt requested.</li> + * <li>1: SMSC delivery receipt requested where final delivery outcome + * is success or failure.</li> + * <li>2: SMSC delivery receipt requested where the final delivery + * outcome is delivery failure.</li> + * </ul> + */ + private Byte registeredDelivery; + /** + * The service type parameter can be used to indicate the SMS + * Application service associated with the message. The following + * generic service_types are defined: + * <ul> + * <li>CMT: Cellular Messaging</li> + * <li>CPT: Cellular Paging</li> + * <li>VMN: Voice Mail Notification</li> + * <li>VMA: Voice Mail Alerting</li> + * <li>WAP: Wireless Application Protocol</li> + * <li>USSD: Unstructured Supplementary Services Data</li> + * </ul> + */ + private String serviceType = "CMT"; + /** + * Defines the type of number (TON) to be used in the SME originator + * address parameters. The following TON values are defined: + * <ul> + * <li>0: Unknown</li> + * <li>1: International</li> + * <li>2: National</li> + * <li>3: Network Specific</li> + * <li>4: Subscriber Number</li> + * <li>5: Alphanumeric</li> + * <li>6: Abbreviated</li> + * </ul> + */ + private Byte sourceAddrTon; + /** + * Defines the type of number (TON) to be used in the SME destination + * address parameters. Only for SubmitSm, SubmitMulti, CancelSm and + * DataSm. The following TON values are defined: + * <ul> + * <li>0: Unknown</li> + * <li>1: International</li> + * <li>2: National</li> + * <li>3: Network Specific</li> + * <li>4: Subscriber Number</li> + * <li>5: Alphanumeric</li> + * <li>6: Abbreviated</li> + * </ul> + */ + private Byte destAddrTon; + /** + * Defines the numeric plan indicator (NPI) to be used in the SME + * originator address parameters. The following NPI values are defined: + * <ul> + * <li>0: Unknown</li> + * <li>1: ISDN (E163/E164)</li> + * <li>2: Data (X.121)</li> + * <li>3: Telex (F.69)</li> + * <li>6: Land Mobile (E.212)</li> + * <li>8: National</li> + * <li>9: Private</li> + * <li>10: ERMES</li> + * <li>13: Internet (IP)</li> + * <li>18: WAP Client Id (to be defined by WAP Forum)</li> + * </ul> + */ + private Byte sourceAddrNpi; + /** + * Defines the type of number (TON) to be used in the SME destination + * address parameters. Only for SubmitSm, SubmitMulti, CancelSm and + * DataSm. The following NPI values are defined: + * <ul> + * <li>0: Unknown</li> + * <li>1: ISDN (E163/E164)</li> + * <li>2: Data (X.121)</li> + * <li>3: Telex (F.69)</li> + * <li>6: Land Mobile (E.212)</li> + * <li>8: National</li> + * <li>9: Private</li> + * <li>10: ERMES</li> + * <li>13: Internet (IP)</li> + * <li>18: WAP Client Id (to be defined by WAP Forum)</li> + * </ul> + */ + private Byte destAddrNpi; + /** + * The protocol id + */ + private Byte protocolId; + /** + * Allows the originating SME to assign a priority level to the short + * message. Only for SubmitSm and SubmitMulti. Four Priority Levels are + * supported: + * <ul> + * <li>0: Level 0 (lowest) priority</li> + * <li>1: Level 1 priority</li> + * <li>2: Level 2 priority</li> + * <li>3: Level 3 (highest) priority</li> + * </ul> + */ + private Byte priorityFlag; + /** + * Used to request the SMSC to replace a previously submitted message, + * that is still pending delivery. The SMSC will replace an existing + * message provided that the source address, destination address and + * service type match the same fields in the new message. The following + * replace if present flag values are defined: + * <ul> + * <li>0: Don't replace</li> + * <li>1: Replace</li> + * </ul> + */ + private Byte replaceIfPresentFlag; + /** + * Defines the address of SME (Short Message Entity) which originated + * this message. + */ + private String sourceAddr = "1616"; + /** + * Defines the destination SME address. For mobile terminated messages, + * this is the directory number of the recipient MS. Only for SubmitSm, + * SubmitMulti, CancelSm and DataSm. + */ + private String destAddr = "1717"; + /** + * Defines the type of number (TON) to be used in the SME. The following + * TON values are defined: + * <ul> + * <li>0: Unknown</li> + * <li>1: International</li> + * <li>2: National</li> + * <li>3: Network Specific</li> + * <li>4: Subscriber Number</li> + * <li>5: Alphanumeric</li> + * <li>6: Abbreviated</li> + * </ul> + */ + private Byte typeOfNumber; + /** + * Defines the numeric plan indicator (NPI) to be used in the SME. The + * following NPI values are defined: + * <ul> + * <li>0: Unknown</li> + * <li>1: ISDN (E163/E164)</li> + * <li>2: Data (X.121)</li> + * <li>3: Telex (F.69)</li> + * <li>6: Land Mobile (E.212)</li> + * <li>8: National</li> + * <li>9: Private</li> + * <li>10: ERMES</li> + * <li>13: Internet (IP)</li> + * <li>18: WAP Client Id (to be defined by WAP Forum)</li> + * </ul> + */ + private Byte numberingPlanIndicator; + /** + * Whether using SSL with the smpps protocol + */ + private Boolean usingSSL; + /** + * Defines the initial delay in milliseconds after the consumer/producer + * tries to reconnect to the SMSC, after the connection was lost. + */ + private Long initialReconnectDelay; + /** + * Defines the interval in milliseconds between the reconnect attempts, + * if the connection to the SMSC was lost and the previous was not + * succeed. + */ + private Long reconnectDelay; + private Integer maxReconnect; + /** + * Sessions can be lazily created to avoid exceptions, if the SMSC is + * not available when the Camel producer is started. Camel will check + * the in message headers 'CamelSmppSystemId' and 'CamelSmppPassword' of + * the first exchange. If they are present, Camel will use these data to + * connect to the SMSC. + */ + private Boolean lazySessionCreation; + /** + * If you need to tunnel SMPP through a HTTP proxy, set this attribute + * to the hostname or ip address of your HTTP proxy. + */ + private String httpProxyHost; + /** + * If you need to tunnel SMPP through a HTTP proxy, set this attribute + * to the port of your HTTP proxy. + */ + private Integer httpProxyPort; + /** + * If your HTTP proxy requires basic authentication, set this attribute + * to the username required for your HTTP proxy. + */ + private String httpProxyUsername; + /** + * If your HTTP proxy requires basic authentication, set this attribute + * to the password required for your HTTP proxy. + */ + private String httpProxyPassword; + /** + * You can refer to a org.jsmpp.session.SessionStateListener in the + * Registry to receive callbacks when the session state changed. + */ + @NestedConfigurationProperty + private SessionStateListener sessionStateListener; + /** + * You can specify the address range for the SmppConsumer as defined in + * section 5.2.7 of the SMPP 3.4 specification. The SmppConsumer will + * receive messages only from SMSC's which target an address (MSISDN or + * IP address) within this range. + */ + private String addressRange; + /** + * You can specify a policy for handling long messages: + * <ul> + * <li>ALLOW - the default, long messages are split to 140 bytes per + * message</li> + * <li>TRUNCATE - long messages are split and only the first fragment + * will be sent to the SMSC. Some carriers drop subsequent fragments so + * this reduces load on the SMPP connection sending parts of a message + * that will never be delivered.</li> + * <li>REJECT - if a message would need to be split, it is rejected with + * an SMPP NegativeResponseException and the reason code signifying the + * message is too long.</li> + * </ul> + */ + private SmppSplittingPolicy splittingPolicy = SmppSplittingPolicy.ALLOW; + /** + * These headers will be passed to the proxy server while establishing + * the connection. + */ + private Map proxyHeaders; + + 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 String getSystemId() { + return systemId; + } + + public void setSystemId(String systemId) { + this.systemId = systemId; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Byte getDataCoding() { + return dataCoding; + } + + public void setDataCoding(Byte dataCoding) { + this.dataCoding = dataCoding; + } + + public Byte getAlphabet() { + return alphabet; + } + + public void setAlphabet(Byte alphabet) { + this.alphabet = alphabet; + } + + public String getEncoding() { + return encoding; + } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public Integer getEnquireLinkTimer() { + return enquireLinkTimer; + } + + public void setEnquireLinkTimer(Integer enquireLinkTimer) { + this.enquireLinkTimer = enquireLinkTimer; + } + + public Integer getTransactionTimer() { + return transactionTimer; + } + + public void setTransactionTimer(Integer transactionTimer) { + this.transactionTimer = transactionTimer; + } + + public String getSystemType() { + return systemType; + } + + public void setSystemType(String systemType) { + this.systemType = systemType; + } + + public Byte getRegisteredDelivery() { + return registeredDelivery; + } + + public void setRegisteredDelivery(Byte registeredDelivery) { + this.registeredDelivery = registeredDelivery; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } - public Byte getAlphabet() { - return alphabet; - } + public Byte getSourceAddrTon() { + return sourceAddrTon; + } - public void setAlphabet(Byte alphabet) { - this.alphabet = alphabet; - } + public void setSourceAddrTon(Byte sourceAddrTon) { + this.sourceAddrTon = sourceAddrTon; + } - public String getEncoding() { - return encoding; - } + public Byte getDestAddrTon() { + return destAddrTon; + } - public void setEncoding(String encoding) { - this.encoding = encoding; - } + public void setDestAddrTon(Byte destAddrTon) { + this.destAddrTon = destAddrTon; + } - public String getPassword() { - return password; - } + public Byte getSourceAddrNpi() { + return sourceAddrNpi; + } - public void setPassword(String password) { - this.password = password; - } + public void setSourceAddrNpi(Byte sourceAddrNpi) { + this.sourceAddrNpi = sourceAddrNpi; + } - public Integer getEnquireLinkTimer() { - return enquireLinkTimer; - } + public Byte getDestAddrNpi() { + return destAddrNpi; + } - public void setEnquireLinkTimer(Integer enquireLinkTimer) { - this.enquireLinkTimer = enquireLinkTimer; - } + public void setDestAddrNpi(Byte destAddrNpi) { + this.destAddrNpi = destAddrNpi; + } - public Integer getTransactionTimer() { - return transactionTimer; - } + public Byte getProtocolId() { + return protocolId; + } - public void setTransactionTimer(Integer transactionTimer) { - this.transactionTimer = transactionTimer; - } + public void setProtocolId(Byte protocolId) { + this.protocolId = protocolId; + } - public String getSystemType() { - return systemType; - } + public Byte getPriorityFlag() { + return priorityFlag; + } - public void setSystemType(String systemType) { - this.systemType = systemType; - } + public void setPriorityFlag(Byte priorityFlag) { + this.priorityFlag = priorityFlag; + } - public Byte getRegisteredDelivery() { - return registeredDelivery; - } + public Byte getReplaceIfPresentFlag() { + return replaceIfPresentFlag; + } - public void setRegisteredDelivery(Byte registeredDelivery) { - this.registeredDelivery = registeredDelivery; - } + public void setReplaceIfPresentFlag(Byte replaceIfPresentFlag) { + this.replaceIfPresentFlag = replaceIfPresentFlag; + } - public String getServiceType() { - return serviceType; - } + public String getSourceAddr() { + return sourceAddr; + } - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } + public void setSourceAddr(String sourceAddr) { + this.sourceAddr = sourceAddr; + } - public Byte getSourceAddrTon() { - return sourceAddrTon; - } + public String getDestAddr() { + return destAddr; + } - public void setSourceAddrTon(Byte sourceAddrTon) { - this.sourceAddrTon = sourceAddrTon; - } + public void setDestAddr(String destAddr) { + this.destAddr = destAddr; + } - public Byte getDestAddrTon() { - return destAddrTon; - } + public Byte getTypeOfNumber() { + return typeOfNumber; + } - public void setDestAddrTon(Byte destAddrTon) { - this.destAddrTon = destAddrTon; - } + public void setTypeOfNumber(Byte typeOfNumber) { + this.typeOfNumber = typeOfNumber; + } - public Byte getSourceAddrNpi() { - return sourceAddrNpi; - } + public Byte getNumberingPlanIndicator() { + return numberingPlanIndicator; + } - public void setSourceAddrNpi(Byte sourceAddrNpi) { - this.sourceAddrNpi = sourceAddrNpi; - } + public void setNumberingPlanIndicator(Byte numberingPlanIndicator) { + this.numberingPlanIndicator = numberingPlanIndicator; + } - public Byte getDestAddrNpi() { - return destAddrNpi; - } + public Boolean getUsingSSL() { + return usingSSL; + } - public void setDestAddrNpi(Byte destAddrNpi) { - this.destAddrNpi = destAddrNpi; - } + public void setUsingSSL(Boolean usingSSL) { + this.usingSSL = usingSSL; + } - public Byte getProtocolId() { - return protocolId; - } + public Long getInitialReconnectDelay() { + return initialReconnectDelay; + } - public void setProtocolId(Byte protocolId) { - this.protocolId = protocolId; - } + public void setInitialReconnectDelay(Long initialReconnectDelay) { + this.initialReconnectDelay = initialReconnectDelay; + } - public Byte getPriorityFlag() { - return priorityFlag; - } + public Long getReconnectDelay() { + return reconnectDelay; + } - public void setPriorityFlag(Byte priorityFlag) { - this.priorityFlag = priorityFlag; - } + public void setReconnectDelay(Long reconnectDelay) { + this.reconnectDelay = reconnectDelay; + } - public Byte getReplaceIfPresentFlag() { - return replaceIfPresentFlag; - } + public Integer getMaxReconnect() { + return maxReconnect; + } - public void setReplaceIfPresentFlag(Byte replaceIfPresentFlag) { - this.replaceIfPresentFlag = replaceIfPresentFlag; - } + public void setMaxReconnect(Integer maxReconnect) { + this.maxReconnect = maxReconnect; + } - public String getSourceAddr() { - return sourceAddr; - } + public Boolean getLazySessionCreation() { + return lazySessionCreation; + } - public void setSourceAddr(String sourceAddr) { - this.sourceAddr = sourceAddr; - } + public void setLazySessionCreation(Boolean lazySessionCreation) { + this.lazySessionCreation = lazySessionCreation; + } - public String getDestAddr() { - return destAddr; - } + public String getHttpProxyHost() { + return httpProxyHost; + } - public void setDestAddr(String destAddr) { - this.destAddr = destAddr; - } + public void setHttpProxyHost(String httpProxyHost) { + this.httpProxyHost = httpProxyHost; + } - public Byte getTypeOfNumber() { - return typeOfNumber; - } + public Integer getHttpProxyPort() { + return httpProxyPort; + } - public void setTypeOfNumber(Byte typeOfNumber) { - this.typeOfNumber = typeOfNumber; - } + public void setHttpProxyPort(Integer httpProxyPort) { + this.httpProxyPort = httpProxyPort; + } - public Byte getNumberingPlanIndicator() { - return numberingPlanIndicator; - } + public String getHttpProxyUsername() { + return httpProxyUsername; + } - public void setNumberingPlanIndicator(Byte numberingPlanIndicator) { - this.numberingPlanIndicator = numberingPlanIndicator; - } + public void setHttpProxyUsername(String httpProxyUsername) { + this.httpProxyUsername = httpProxyUsername; + } - public Boolean getUsingSSL() { - return usingSSL; - } + public String getHttpProxyPassword() { + return httpProxyPassword; + } - public void setUsingSSL(Boolean usingSSL) { - this.usingSSL = usingSSL; - } + public void setHttpProxyPassword(String httpProxyPassword) { + this.httpProxyPassword = httpProxyPassword; + } - public long getInitialReconnectDelay() { - return initialReconnectDelay; - } - - public void setInitialReconnectDelay(long initialReconnectDelay) { - this.initialReconnectDelay = initialReconnectDelay; - } - - public long getReconnectDelay() { - return reconnectDelay; - } - - public void setReconnectDelay(long reconnectDelay) { - this.reconnectDelay = reconnectDelay; - } - - public Boolean getLazySessionCreation() { - return lazySessionCreation; - } - - public void setLazySessionCreation(Boolean lazySessionCreation) { - this.lazySessionCreation = lazySessionCreation; - } - - public String getHttpProxyHost() { - return httpProxyHost; - } - - public void setHttpProxyHost(String httpProxyHost) { - this.httpProxyHost = httpProxyHost; - } - - public Integer getHttpProxyPort() { - return httpProxyPort; - } - - public void setHttpProxyPort(Integer httpProxyPort) { - this.httpProxyPort = httpProxyPort; - } - - public String getHttpProxyUsername() { - return httpProxyUsername; - } - - public void setHttpProxyUsername(String httpProxyUsername) { - this.httpProxyUsername = httpProxyUsername; - } - - public String getHttpProxyPassword() { - return httpProxyPassword; - } - - public void setHttpProxyPassword(String httpProxyPassword) { - this.httpProxyPassword = httpProxyPassword; - } - - public SessionStateListener getSessionStateListener() { - return sessionStateListener; - } - - public void setSessionStateListener( - SessionStateListener sessionStateListener) { - this.sessionStateListener = sessionStateListener; - } - - public String getAddressRange() { - return addressRange; - } - - public void setAddressRange(String addressRange) { - this.addressRange = addressRange; - } - - public SmppSplittingPolicy getSplittingPolicy() { - return splittingPolicy; - } - - public void setSplittingPolicy(SmppSplittingPolicy splittingPolicy) { - this.splittingPolicy = splittingPolicy; - } - - public Map<String, String> getProxyHeaders() { - return proxyHeaders; - } + public SessionStateListener getSessionStateListener() { + return sessionStateListener; + } - public void setProxyHeaders(Map<String, String> proxyHeaders) { - this.proxyHeaders = proxyHeaders; + public void setSessionStateListener( + SessionStateListener sessionStateListener) { + this.sessionStateListener = sessionStateListener; + } + + public String getAddressRange() { + return addressRange; + } + + public void setAddressRange(String addressRange) { + this.addressRange = addressRange; + } + + public SmppSplittingPolicy getSplittingPolicy() { + return splittingPolicy; + } + + public void setSplittingPolicy(SmppSplittingPolicy splittingPolicy) { + this.splittingPolicy = splittingPolicy; + } + + public Map getProxyHeaders() { + return proxyHeaders; + } + + public void setProxyHeaders(Map proxyHeaders) { + this.proxyHeaders = proxyHeaders; + } } } \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentAutoConfiguration.java b/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentAutoConfiguration.java index 0c946cd..ec93210 100644 --- a/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentAutoConfiguration.java +++ b/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class SparkComponentAutoConfiguration { 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-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentConfiguration.java b/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentConfiguration.java index be99251..29cb06d 100644 --- a/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentConfiguration.java +++ b/components-starter/camel-spark-rest-starter/src/main/java/org/apache/camel/component/sparkrest/springboot/SparkComponentConfiguration.java @@ -17,8 +17,8 @@ package org.apache.camel.component.sparkrest.springboot; import org.apache.camel.component.sparkrest.SparkBinding; -import org.apache.camel.component.sparkrest.SparkConfiguration; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * The spark-rest component is used for hosting REST services which has been @@ -70,10 +70,11 @@ public class SparkComponentConfiguration { /** * To use the shared SparkConfiguration */ - private SparkConfiguration sparkConfiguration; + private SparkConfigurationNestedConfiguration sparkConfiguration; /** * To use a custom SparkBinding to map to/from Camel message. */ + @NestedConfigurationProperty private SparkBinding sparkBinding; public Integer getPort() { @@ -148,11 +149,12 @@ public class SparkComponentConfiguration { this.truststorePassword = truststorePassword; } - public SparkConfiguration getSparkConfiguration() { + public SparkConfigurationNestedConfiguration getSparkConfiguration() { return sparkConfiguration; } - public void setSparkConfiguration(SparkConfiguration sparkConfiguration) { + public void setSparkConfiguration( + SparkConfigurationNestedConfiguration sparkConfiguration) { this.sparkConfiguration = sparkConfiguration; } @@ -163,4 +165,92 @@ public class SparkComponentConfiguration { public void setSparkBinding(SparkBinding sparkBinding) { this.sparkBinding = sparkBinding; } + + public static class SparkConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.sparkrest.SparkConfiguration.class; + /** + * If this option is enabled, then during binding from Spark to Camel + * Message then the headers will be mapped as well (eg added as header + * to the Camel Message as well). You can turn off this option to + * disable this. The headers can still be accessed from the + * org.apache.camel.component.sparkrest.SparkMessage message with the + * method getRequest() that returns the Spark HTTP request instance. + */ + private Boolean mapHeaders; + /** + * Determines whether or not the raw input stream from Spark + * HttpRequest#getContent() is cached or not (Camel will read the stream + * into a in light-weight memory based Stream caching) cache. By default + * Camel will cache the Netty input stream to support reading it + * multiple times to ensure 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. Mind that if you enable this option, then you + * cannot read the Netty stream multiple times out of the box, and you + * would need manually to reset the reader index on the Spark raw + * stream. + */ + private Boolean disableStreamCache; + /** + * If this option is enabled, then during binding from Spark to Camel + * Message then the header values will be URL decoded (eg %20 will be a + * space character.) + */ + private Boolean urlDecodeHeaders; + /** + * If enabled and an Exchange failed processing on the consumer side, + * and if the caused Exception was send back serialized in the response + * as a application/x-java-serialized-object content type. + * <p/> + * This is by default turned off. If you enable this then be aware that + * Java will deserialize the incoming data from the request to Java and + * that can be a potential security risk. + */ + private Boolean transferException; + /** + * 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; + + public Boolean getMapHeaders() { + return mapHeaders; + } + + public void setMapHeaders(Boolean mapHeaders) { + this.mapHeaders = mapHeaders; + } + + public Boolean getDisableStreamCache() { + return disableStreamCache; + } + + public void setDisableStreamCache(Boolean disableStreamCache) { + this.disableStreamCache = disableStreamCache; + } + + public Boolean getUrlDecodeHeaders() { + return urlDecodeHeaders; + } + + public void setUrlDecodeHeaders(Boolean urlDecodeHeaders) { + this.urlDecodeHeaders = urlDecodeHeaders; + } + + public Boolean getTransferException() { + return transferException; + } + + public void setTransferException(Boolean transferException) { + this.transferException = transferException; + } + + public Boolean getMatchOnUriPrefix() { + return matchOnUriPrefix; + } + + public void setMatchOnUriPrefix(Boolean matchOnUriPrefix) { + this.matchOnUriPrefix = matchOnUriPrefix; + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentAutoConfiguration.java b/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentAutoConfiguration.java index 0f6e970..ba36376 100644 --- a/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentAutoConfiguration.java +++ b/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class SparkComponentAutoConfiguration { 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-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentConfiguration.java b/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentConfiguration.java index eedf908..e107fbb 100644 --- a/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentConfiguration.java +++ b/components-starter/camel-spark-starter/src/main/java/org/apache/camel/component/spark/springboot/SparkComponentConfiguration.java @@ -19,6 +19,7 @@ package org.apache.camel.component.spark.springboot; import org.apache.camel.component.spark.RddCallback; import org.apache.spark.api.java.JavaRDDLike; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * The spark component can be used to send RDD or DataFrame jobs to Apache Spark @@ -32,10 +33,12 @@ public class SparkComponentConfiguration { /** * RDD to compute against. */ + @NestedConfigurationProperty private JavaRDDLike rdd; /** * Function performing action against an RDD. */ + @NestedConfigurationProperty private RddCallback rddCallback; public JavaRDDLike getRdd() { http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentAutoConfiguration.java b/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentAutoConfiguration.java index 8a968eb..cfff77c 100644 --- a/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentAutoConfiguration.java +++ b/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class SplunkComponentAutoConfiguration { 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-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentConfiguration.java b/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentConfiguration.java index 2100393..d2c16e1 100644 --- a/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentConfiguration.java +++ b/components-starter/camel-splunk-starter/src/main/java/org/apache/camel/component/splunk/springboot/SplunkComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.splunk.springboot; import org.apache.camel.component.splunk.SplunkConfigurationFactory; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * The splunk component allows to publish or search for events in Splunk. @@ -30,6 +31,7 @@ public class SplunkComponentConfiguration { /** * To use the SplunkConfigurationFactory */ + @NestedConfigurationProperty private SplunkConfigurationFactory splunkConfigurationFactory; public SplunkConfigurationFactory getSplunkConfigurationFactory() { http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java b/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java index 3ffd8c6..b4ccffa 100644 --- a/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java +++ b/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java @@ -45,6 +45,26 @@ public class SpringBatchComponentAutoConfiguration { 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-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConfiguration.java b/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConfiguration.java index 36914a5..1f45b84 100644 --- a/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConfiguration.java +++ b/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConfiguration.java @@ -19,6 +19,7 @@ package org.apache.camel.component.spring.batch.springboot; import org.springframework.batch.core.configuration.JobRegistry; import org.springframework.batch.core.launch.JobLauncher; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * The spring-batch component allows to send messages to Spring Batch for @@ -32,10 +33,12 @@ public class SpringBatchComponentConfiguration { /** * Explicitly specifies a JobLauncher to be used. */ + @NestedConfigurationProperty private JobLauncher jobLauncher; /** * Explicitly specifies a JobRegistry to be used. */ + @NestedConfigurationProperty private JobRegistry jobRegistry; public JobLauncher getJobLauncher() { http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java b/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java index 38e9000..db6e1c0 100644 --- a/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java +++ b/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class EventComponentAutoConfiguration { 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-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentConfiguration.java b/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentConfiguration.java index a2cc856..63f9847 100644 --- a/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentConfiguration.java +++ b/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.event.springboot; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.context.ApplicationContext; /** @@ -30,6 +31,7 @@ public class EventComponentConfiguration { /** * The Spring ApplicationContext */ + @NestedConfigurationProperty private ApplicationContext applicationContext; public ApplicationContext getApplicationContext() { http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java index 85c8dba..4281b7c 100644 --- a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java +++ b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class SqlComponentAutoConfiguration { 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-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java index 2ed59e1..dc9da83 100644 --- a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java +++ b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java @@ -45,6 +45,26 @@ public class SqlStoredComponentAutoConfiguration { 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-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java b/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java index d7dd8a5..f2bead0 100644 --- a/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java +++ b/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class SshComponentAutoConfiguration { 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-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java b/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java index 7d2813a..7730311 100644 --- a/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java +++ b/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java @@ -16,10 +16,10 @@ */ package org.apache.camel.component.ssh.springboot; -import org.apache.camel.component.ssh.SshConfiguration; import org.apache.sshd.common.KeyPairProvider; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * The ssh component enables access to SSH servers such that you can send an SSH @@ -33,7 +33,7 @@ public class SshComponentConfiguration { /** * To use the shared SSH configuration */ - private SshConfiguration configuration; + private SshConfigurationNestedConfiguration configuration; /** * Sets the hostname of the remote SSH server. */ @@ -62,6 +62,7 @@ public class SshComponentConfiguration { * Sets the KeyPairProvider reference to use when connecting using * Certificates to the remote SSH Server. */ + @NestedConfigurationProperty private KeyPairProvider keyPairProvider; /** * Sets the key type to pass to the KeyPairProvider as part of @@ -73,7 +74,7 @@ public class SshComponentConfiguration { * Sets the timeout in milliseconds to wait in establishing the remote SSH * server connection. Defaults to 30000 milliseconds. */ - private long timeout; + private Long timeout; /** * Sets the resource path of the certificate to use for Authentication. */ @@ -86,11 +87,12 @@ public class SshComponentConfiguration { */ private String certResource; - public SshConfiguration getConfiguration() { + public SshConfigurationNestedConfiguration getConfiguration() { return configuration; } - public void setConfiguration(SshConfiguration configuration) { + public void setConfiguration( + SshConfigurationNestedConfiguration configuration) { this.configuration = configuration; } @@ -150,11 +152,11 @@ public class SshComponentConfiguration { this.keyType = keyType; } - public long getTimeout() { + public Long getTimeout() { return timeout; } - public void setTimeout(long timeout) { + public void setTimeout(Long timeout) { this.timeout = timeout; } @@ -176,4 +178,177 @@ public class SshComponentConfiguration { public void setCertResource(String certResource) { this.certResource = certResource; } + + public static class SshConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.ssh.SshConfiguration.class; + /** + * Sets the username to use in logging into the remote SSH server. + * + * @param username + * String representing login username. + */ + private String username; + /** + * Sets the hostname of the remote SSH server. + * + * @param host + * String representing hostname of SSH server. + */ + private String host; + /** + * Sets the port number for the remote SSH server. + * + * @param port + * int representing port number on remote host. Defaults to + * 22. + */ + private Integer port; + /** + * Sets the password to use in connecting to remote SSH server. Requires + * keyPairProvider to be set to null. + * + * @param password + * String representing password for username at remote host. + */ + private String password; + /** + * Sets the command string to send to the remote SSH server during every + * poll cycle. Only works with camel-ssh component being used as a + * consumer, i.e. from("ssh://...") You may need to end your command + * with a newline, and that must be URL encoded %0A + * + * @param pollCommand + * String representing the command to send. + */ + private String pollCommand; + /** + * Sets the KeyPairProvider reference to use when connecting using + * Certificates to the remote SSH Server. + * + * @param keyPairProvider + * KeyPairProvider reference to use in authenticating. If set + * to 'null', then will attempt to connect using + * username/password settings. + * @see KeyPairProvider + */ + @NestedConfigurationProperty + private KeyPairProvider keyPairProvider; + /** + * Sets the key type to pass to the KeyPairProvider as part of + * authentication. KeyPairProvider.loadKey(...) will be passed this + * value. Defaults to "ssh-rsa". + * + * @param keyType + * String defining the type of KeyPair to use for + * authentication. + * @see KeyPairProvider + */ + private String keyType = "KeyPairProvider.SSH_RSA"; + /** + * Sets the timeout in milliseconds to wait in establishing the remote + * SSH server connection. Defaults to 30000 milliseconds. + * + * @param timeout + * long milliseconds to wait. + */ + private Long timeout; + /** + * @deprecated As of version 2.11, replaced by + * {@link #setCertResource(String)} + */ + @Deprecated + private String certFilename; + /** + * Sets the resource path of the certificate to use for Authentication. + * Will use {@link ResourceHelperKeyPairProvider} to resolve file based + * certificate, and depends on keyType setting. + * + * @param certResource + * String file, classpath, or http url for the certificate + */ + private String certResource; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + 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 String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPollCommand() { + return pollCommand; + } + + public void setPollCommand(String pollCommand) { + this.pollCommand = pollCommand; + } + + public KeyPairProvider getKeyPairProvider() { + return keyPairProvider; + } + + public void setKeyPairProvider(KeyPairProvider keyPairProvider) { + this.keyPairProvider = keyPairProvider; + } + + public String getKeyType() { + return keyType; + } + + public void setKeyType(String keyType) { + this.keyType = keyType; + } + + public Long getTimeout() { + return timeout; + } + + public void setTimeout(Long timeout) { + this.timeout = timeout; + } + + @Deprecated + @DeprecatedConfigurationProperty + public String getCertFilename() { + return certFilename; + } + + @Deprecated + public void setCertFilename(String certFilename) { + this.certFilename = certFilename; + } + + public String getCertResource() { + return certResource; + } + + public void setCertResource(String certResource) { + this.certResource = certResource; + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentAutoConfiguration.java b/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentAutoConfiguration.java index 1955e56..16a87f4 100644 --- a/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentAutoConfiguration.java +++ b/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentAutoConfiguration.java @@ -44,6 +44,26 @@ public class StompComponentAutoConfiguration { 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-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentConfiguration.java b/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentConfiguration.java index f664a2d..d324632 100644 --- a/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentConfiguration.java +++ b/components-starter/camel-stomp-starter/src/main/java/org/apache/camel/component/stomp/springboot/StompComponentConfiguration.java @@ -16,8 +16,9 @@ */ package org.apache.camel.component.stomp.springboot; -import org.apache.camel.component.stomp.StompConfiguration; +import org.apache.camel.util.jsse.SSLContextParameters; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * The stomp component is used for communicating with Stomp compliant message @@ -31,7 +32,7 @@ public class StompComponentConfiguration { /** * To use the shared stomp configuration */ - private StompConfiguration configuration; + private StompConfigurationNestedConfiguration configuration; /** * The URI of the Stomp broker to connect to */ @@ -49,11 +50,12 @@ public class StompComponentConfiguration { */ private String host; - public StompConfiguration getConfiguration() { + public StompConfigurationNestedConfiguration getConfiguration() { return configuration; } - public void setConfiguration(StompConfiguration configuration) { + public void setConfiguration( + StompConfigurationNestedConfiguration configuration) { this.configuration = configuration; } @@ -88,4 +90,70 @@ public class StompComponentConfiguration { public void setHost(String host) { this.host = host; } + + public static class StompConfigurationNestedConfiguration { + public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.stomp.StompConfiguration.class; + /** + * The URI of the Stomp broker to connect to + */ + private String brokerURL = "tcp://localhost:61613"; + /** + * The virtual host name + */ + private String host; + /** + * The username + */ + private String login; + /** + * The password + */ + private String passcode; + /** + * To configure security using SSLContextParameters + */ + @NestedConfigurationProperty + private SSLContextParameters sslContextParameters; + + public String getBrokerURL() { + return brokerURL; + } + + public void setBrokerURL(String brokerURL) { + this.brokerURL = brokerURL; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getPasscode() { + return passcode; + } + + public void setPasscode(String passcode) { + this.passcode = passcode; + } + + public SSLContextParameters getSslContextParameters() { + return sslContextParameters; + } + + public void setSslContextParameters( + SSLContextParameters sslContextParameters) { + this.sslContextParameters = sslContextParameters; + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/d485f2f0/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java b/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java index 585e76e..4dba406 100644 --- a/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java +++ b/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java @@ -45,6 +45,26 @@ public class TelegramComponentAutoConfiguration { 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-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentAutoConfiguration.java b/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentAutoConfiguration.java index 7e82c23..1e63e96 100644 --- a/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentAutoConfiguration.java +++ b/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentAutoConfiguration.java @@ -45,6 +45,26 @@ public class TwitterComponentAutoConfiguration { 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;