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 via email to