You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Nicola Ferraro (JIRA)" <ji...@apache.org> on 2016/07/26 10:02:20 UTC
[jira] [Commented] (CAMEL-10031) camel-spring-boot - Add endpoint
options as type-safe configuration properties
[ https://issues.apache.org/jira/browse/CAMEL-10031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15393563#comment-15393563 ]
Nicola Ferraro commented on CAMEL-10031:
----------------------------------------
I started working on this feature. One thing that can be done is to mimic the endpoint xml configuration.
It means providing the equivalent of the following snippet as spring-boot configuration:
{code:xml}
<camelContext ...>
<endpoint id="foo" uri="ftp://foo@myserver">
<property name="password" value="secret"/>
<property name="recursive" value="true"/>
<property name="ftpClient.dataTimeout" value="30000"/>
<property name="ftpClient.serverLanguageCode" value="fr"/>
</endpoint>
<route>
<from uri="ref:foo"/>
...
</route>
</camelContext>
{code}
I managed to make the following configuration work for a sample component (I did not change the maven-plugin yet):
{code}
camel:
component:
ftp:
endpoint:
id: foo
uri: ftp://foo@myserver
password: secret
{code}
Or the _.properties_ equivalent:
{code}
camel.component.ftp.endpoint.id=foo
camel.component.ftp.endpoint.uri=ftp://foo@myserver
camel.component.ftp.endpoint.password=secret
{code}
The endpoint is created and can be used in routes as "ref:foo".
I considered also *nesting the properties in "camel.endpoint.ftp", probably it's a better choice*, because it's shorter and prevent confusion.
The limitations of this approach is that you can define a *single endpoint per component*, that is obviously not desired, but the IDE toolings (Intellij Idea in my case) have a *pretty bad support for Lists and Maps in configuration*.
The best I could do was adding an _additional-endpoints_ configuration property. The final result is:
{code}
camel:
component:
ftp:
endpoint:
id: foo
uri: ftp://foo@myserver
password: secret
additional-endpoints:
- id: bar
uri: ftp://bar@myserver
password: secret
- id: three
uri: ftp://three@myserver
password: secret
{code}
Or the _.properties_ version:
{code}
camel.component.ftp.endpoint.id=foo
camel.component.ftp.endpoint.uri=ftp://foo@myserver
camel.component.ftp.endpoint.password=secret
camel.component.ftp.additional-endpoints[0].id=bar
camel.component.ftp.additional-endpoints[0].uri=ftp://bar@myserver
camel.component.ftp.additional-endpoints[0].password=secret
camel.component.ftp.additional-endpoints[1].id=three
camel.component.ftp.additional-endpoints[1].uri=ftp://three@myserver
camel.component.ftp.additional-endpoints[1].password=secret
{code}
The *auto-completion works partially only in the .properties version* (only when you press "." after _endpoints\[0\]_ the IDE lets you choose the properties from the list, *without descriptions or default values*). Auto-completion was not working in my IDE when I used Maps instead of Lists.
> camel-spring-boot - Add endpoint options as type-safe configuration properties
> ------------------------------------------------------------------------------
>
> Key: CAMEL-10031
> URL: https://issues.apache.org/jira/browse/CAMEL-10031
> Project: Camel
> Issue Type: New Feature
> Components: camel-spring-boot
> Reporter: Claus Ibsen
>
> See CAMEL-9419.
> We can now configure this for all the components. But for endpoints its a bit more as you can have many endpoints with different configuration.
> So either you assign an id to the endpoint you configure, and then need to refer to the endpoint by id, in the camel routes. Or we figure out something else.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)