[jira] Created: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
DefaultComponent - setProperties should be able to lookup ref in registry
-------------------------------------------------------------------------

                 Key: CAMEL-895
                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
             Project: Apache Camel
          Issue Type: Improvement
          Components: camel-core
    Affects Versions: 1.5.0
            Reporter: Claus Ibsen
             Fix For: 2.0.0


URI configuration of endpoints sometimes supports being able to reference a bean in the registry.

For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.

Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47361#action_47361 ]

Claus Ibsen commented on CAMEL-895:
-----------------------------------

Maybe this is a bit to magical.

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>             Fix For: 2.0.0
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47695#action_47695 ]

Claus Ibsen commented on CAMEL-895:
-----------------------------------

Maybe not as magic

We could allow any {{xxxxRef}} URI option to automatic lookup in the registry and then configure the endpoint if it has a xxx setter.

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>             Fix For: 2.0.0
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Assigned: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-895:
---------------------------------

    Assignee: Claus Ibsen

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47905#action_47905 ]

Claus Ibsen commented on CAMEL-895:
-----------------------------------

I had to try a little experiment and got it working very nicely

{code:java}
    /**
     * Sets the reference properties on the given bean
     * <p/>
     * This is convention over configuration, setting all <tt>xxxRef</tt> parameters by looking it up in registry
     * and setting it on the bean if possible.
     */
    protected void setRefProperties(Object bean, Map parameters) throws Exception {
        Iterator it = parameters.keySet().iterator();
        while (it.hasNext()) {
            String key = it.next().toString();
            if (key.endsWith("Ref")) {
                String value = (String) parameters.get(key);
                Object ref = lookup(value);
                if (ref != null) {
                    String name = key.substring(0, key.lastIndexOf("Ref"));
                    boolean hit = IntrospectionSupport.setProperty(getCamelContext().getTypeConverter(), bean, name, ref);
                    if (hit) {
                        LOG.debug("Configued property: " + name + " on bean: " + bean + " with value: " + ref);
                        // must remove as its a valid option and we could configure it
                        it.remove();
                    }
                }
            }
        }
    }
{code}

Now it's possible to get rid of duplicated code in components and offer this convention right out-of-the-box for all URI options, making it much easier to set URI options leveraging the Registry.
Using Spring XML this is very powerful.

For instance all this code can be removed:
{code}
        // lookup idempotent repository in registry if provided
        String ref = getAndRemoveParameter(parameters, "idempotentRepositoryRef", String.class);
        if (ref != null) {
            IdempotentRepository repository = mandatoryLookup(ref, IdempotentRepository.class);
            result.setIdempotentRepository(repository);
        }

        // lookup file filter in registry if provided
        ref = getAndRemoveParameter(parameters, "fileFilterRef", String.class);
        if (ref != null) {
            FileFilter filter = mandatoryLookup(ref, FileFilter.class);
            result.setFilter(filter);
        }

        // lookup sorter in registry if provided
        ref = getAndRemoveParameter(parameters, "sorterRef", String.class);
        if (ref != null) {
            Comparator<File> sorter = mandatoryLookup(ref, Comparator.class);
            result.setFileSorter(sorter);
        }
{code}

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47906#action_47906 ]

Claus Ibsen commented on CAMEL-895:
-----------------------------------

Dooh I had a 2nd though and would like to propose to use the # syntax that Apache CXF uses (AFAIR)

So you can do this:
{code}
file://target/idempotent/?idempotent=true&idempotentRepository=#myRepo&moveNamePrefix=done/
{code}

As the value starts with a # then it's looked up in the registry. I am wondering it it should be a mandatory option so Camel will raise an exception if not found and not possible to set?

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47907#action_47907 ]

Claus Ibsen commented on CAMEL-895:
-----------------------------------

See proposal on nabble:
http://www.nabble.com/-PROPOSAL----Camel-2.0---support---syntax-in-URI-options-td20869957s22882.html

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Work started: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Work on CAMEL-895 started by Claus Ibsen.

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-895:
------------------------------

    Attachment: CAMEL-895.patch

A patch for the implementation of this feature.

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>         Attachments: CAMEL-895.patch
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-895:
------------------------------

    Attachment:     (was: CAMEL-895.patch)

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-895:
------------------------------

    Attachment: CAMEL-895_2.patch

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>         Attachments: CAMEL-895_2.patch
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (CAMEL-895) DefaultComponent - setProperties should be able to lookup ref in registry

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/activemq/browse/CAMEL-895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-895.
-------------------------------

    Resolution: Fixed

> DefaultComponent - setProperties should be able to lookup ref in registry
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-895
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-895
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 1.5.0
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>             Fix For: 2.0.0
>
>         Attachments: CAMEL-895_2.patch
>
>
> URI configuration of endpoints sometimes supports being able to reference a bean in the registry.
> For instance camel-mina has the codec option. Currently this is speically manually coded in the component factory.
> Would be lovely if setProperties(configBean, parameters) would be able to determine this itself and lookup beans in registry.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.