[jira] Created: (CAMEL-2368) Bean Expression for Non Registry beans can't reference an instance

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

[jira] Created: (CAMEL-2368) Bean Expression for Non Registry beans can't reference an instance

JIRA jira@apache.org
Bean Expression for Non Registry beans can't reference an instance
------------------------------------------------------------------

                 Key: CAMEL-2368
                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.1.0, 2.0.0
         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
            Reporter: Michael Mathers
            Priority: Minor


The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).

# Specify Class/method and Camel will create a new instance of the bean and call the method.
#  Specify instance/method and Camel will use the the specified instance and call the method.  

In fact, the doc shows examples of both:

h4. Method 1)
{code}
        from("activemq:topic:OrdersTopic").
                filter().expression(bean(MyBean.class, "isGoldCustomer")).
                to("activemq:BigSpendersQueue");
{code}

h4. Method 2)
{code}
   private MyBean my;

        from("activemq:topic:OrdersTopic").
                filter().expression(bean(my, "isGoldCustomer")).
                to("activemq:BigSpendersQueue");
{code}

I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:

{code}
private Object list;
...
from (getErrorEndpoint())
        .recipientList(list, "getRecipients");
{code}

Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.

Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).

Ideally, I could have...

{code}
Object list = new Object() {
   @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
}
...
from (endpoint).recipientList(<any instance annotated with @RecipientList>)
{code}

or even

{code}
// Look for method "errors" then look for annotation @RecipientList("errors")
from (endpoint).recipientList( bean, "errors" )
{code}


Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

JIRA jira@apache.org

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

Claus Ibsen commented on CAMEL-2368:
------------------------------------

The issue is the documentation was wrong. I have updated that.

You need to do something like this
{code}
                from("direct:start")
                    .filter().expression(BeanLanguage.bean(myBean, "isGoldCustomer"))
                    .to("mock:result");
{code}

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Priority: Minor
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Claus Ibsen commented on CAMEL-2368:
------------------------------------

The issue is that {{bean}} would have a clash if we overloaded it with a new {{bean(Object instance)}} method, clashing the existing {{bean(String ref)}} method.

So I will relax this and let the latter method use a Object type which is dual parameter. If you pass in a String then it will lookup the bean. Otherwise it will assume its a bean instance and use it out of the box.

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Priority: Minor
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Claus Ibsen reassigned CAMEL-2368:
----------------------------------

    Assignee: Claus Ibsen

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Claus Ibsen commented on CAMEL-2368:
------------------------------------

trunk: 899932

Using an existing bean instance is now a first class citizen and there are methods on the builders and method call expressions for that. See updated wiki page:
http://cwiki.apache.org/confluence/display/CAMEL/Bean+Language

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Claus Ibsen commented on CAMEL-2368:
------------------------------------

In terms of your request for a {{Endpoint[]}} then just use a {{.constant}} expression

{code}
private Object list;
...
from (getErrorEndpoint())
        .recipientList(constant(list), "getRecipients");
{code}

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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] Issue Comment Edited: (CAMEL-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Claus Ibsen edited comment on CAMEL-2368 at 1/16/10 12:55 PM:
--------------------------------------------------------------

In terms of your request for a {{Endpoint[]}} then just use a {{.constant}} expression

{code}
private Object list;
...
from (getErrorEndpoint())
        .recipientList(constant(list));
{code}

      was (Author: davsclaus):
    In terms of your request for a {{Endpoint[]}} then just use a {{.constant}} expression

{code}
private Object list;
...
from (getErrorEndpoint())
        .recipientList(constant(list), "getRecipients");
{code}
 

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Claus Ibsen resolved CAMEL-2368.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2.0

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.2.0
>
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Claus Ibsen commented on CAMEL-2368:
------------------------------------

If you want to use a @RecipientList bean in the route then just route to it using bean

{code}
from("direct:foo").bean(MyBean.class);
{code}

And have MyBean having a method which is annotated with @RecipientList

See this test
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTest.java

Which also works without the method name
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListNoMethodNameTest

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.2.0
>
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Claus Ibsen updated CAMEL-2368:
-------------------------------

    Issue Type: Improvement  (was: Bug)

Its not a bug but a request for an improvement

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.2.0
>
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Michael Mathers commented on CAMEL-2368:
----------------------------------------

Thanks Claus for the tips and refinements.

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.2.0
>
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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] Issue Comment Edited: (CAMEL-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Michael Mathers edited comment on CAMEL-2368 at 1/19/10 6:32 PM:
-----------------------------------------------------------------

Thanks Claus for the tips and refinements.

In regards to the Endpoint[] question and using "constant"...  Would this be evaluated just once? or dynamically on each message?  My intent is to create a dynamic recipient list (which you've already shown me ways to do) which is why I rejected using "constant" initially.

      was (Author: mbmather):
    Thanks Claus for the tips and refinements.
 

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.2.0
>
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

--
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-2368) Bean Expression for Non Registry beans can't reference an instance

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

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

Michael Mathers commented on CAMEL-2368:
----------------------------------------

As for the @RecipientList annotation.  The examples you site indicate (to me) that I cannot use it with a _non Registry_ bean.  ie, the examples show two methods

# Specifying the registry name
# Specifying the bean class (for which Camel will instantiate a new bean)

What I was hoping for was

{code}from("direct:foo").recipientList(mybean);{code}

where mybean is an existing instance such as

{code}
Object mybean = new Object() {
    @RecipientList
    public Collection<Endpoint> getRecipents(Object body) {... }
}
{code}

However, it seems like this should work, yes (it does require I specify method name though)?

{code}from("direct:foo").recipientList(
    BeanLanguage.bean(myBean, "getRecipients")
);{code}

> Bean Expression for Non Registry beans can't reference an instance
> ------------------------------------------------------------------
>
>                 Key: CAMEL-2368
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-2368
>             Project: Apache Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Compile issue.  Java 6, Windows, Eclipse/Gallileo
>            Reporter: Michael Mathers
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.2.0
>
>
> The documentation at the bottom of this page:  http://camel.apache.org/bean-language.html says that I can use the bean expression DSL to work with beans that are not in the registry in two different ways (2.0-M2+).
> # Specify Class/method and Camel will create a new instance of the bean and call the method.
> #  Specify instance/method and Camel will use the the specified instance and call the method.  
> In fact, the doc shows examples of both:
> h4. Method 1)
> {code}
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(MyBean.class, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> h4. Method 2)
> {code}
>    private MyBean my;
>         from("activemq:topic:OrdersTopic").
>                 filter().expression(bean(my, "isGoldCustomer")).
>                 to("activemq:BigSpendersQueue");
> {code}
> I am unable to do the latter (#2) as the methods are not defined.  I'm using Camel 2.1.0 but I've tried 2.0.0 as well. So either the doc is wrong or the methods are missing/not visible. My code specifically is:
> {code}
> private Object list;
> ...
> from (getErrorEndpoint())
>         .recipientList(list, "getRecipients");
> {code}
> Yes, there are easy ways to avoid this.  But I prefer not to have to create more XML and/or specify a Class name here.
> Finally, is there a good reason ".recipientList()" isn't overloaded to take an Endpoint[] instead of only an Expression?   The @RecipientList annotation seems to anticipate this form but there doesn't seem to be a good way to plug the @RecipientList annotated bean into the route definition.  Even if the bean is in the registry it looks as if you still have to supply the method name anyway despite that its already annotated (unless you also annotate with @Handler which might be undesirable).
> Ideally, I could have...
> {code}
> Object list = new Object() {
>    @RecipientList public Collection<Endpoint> getRecipents(Object body) {... }
> }
> ...
> from (endpoint).recipientList(<any instance annotated with @RecipientList>)
> {code}
> or even
> {code}
> // Look for method "errors" then look for annotation @RecipientList("errors")
> from (endpoint).recipientList( bean, "errors" )
> {code}
> Is this making any sense?  (I'm still very wet behind the ears)

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