You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ee7arh <an...@2e-systems.com> on 2010/01/17 12:21:25 UTC

invoking a bean via an interface in ContentRouter

Hi,

I would like to invoke methods in my pojo classes from the ContentRouter
where the bean is an interface. However I get the error:
org.apache.camel.NoSuchBeanException: No bean could be found in the registry
for: serviceEventHandler

I have an interface with the @Service annotation at the top as so:

@Service(value = "serviceEventHandler")
public interface ServiceEventHandler {

    
    public void registerServiceEvent(ServiceEvent serviceEvent);


Then I have 2 classes which implement this interface, both of which do not
have the @Service annotation at the top (although I tried adding the
annotation there too but ran into duplicate bean problems).

Then in my Camel route I want to have:

               .to("bean:serviceEventHandler?method=registerServiceEvent")

And based on the type of object coming through the route I would hope that
the correct subclass is called. However it looks like the package-scan does
not setup this interface as a bean or try to setup the subclasses as I get
the above error.

Perhaps this is something which is fundamentally not possible with beans but
it would be nice. 

Thanks
Andrew
-- 
View this message in context: http://old.nabble.com/invoking-a-bean-via-an-interface-in-ContentRouter-tp27197844p27197844.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: invoking a bean via an interface in ContentRouter

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I think you need to add that Spring snippet for letting it scan classes as well

Its something like this. Check the Spring documentation.
 <context:annotation-config/>


On Sun, Jan 17, 2010 at 12:21 PM, ee7arh <an...@2e-systems.com> wrote:
>
> Hi,
>
> I would like to invoke methods in my pojo classes from the ContentRouter
> where the bean is an interface. However I get the error:
> org.apache.camel.NoSuchBeanException: No bean could be found in the registry
> for: serviceEventHandler
>
> I have an interface with the @Service annotation at the top as so:
>
> @Service(value = "serviceEventHandler")
> public interface ServiceEventHandler {
>
>
>    public void registerServiceEvent(ServiceEvent serviceEvent);
>
>
> Then I have 2 classes which implement this interface, both of which do not
> have the @Service annotation at the top (although I tried adding the
> annotation there too but ran into duplicate bean problems).
>
> Then in my Camel route I want to have:
>
>               .to("bean:serviceEventHandler?method=registerServiceEvent")
>
> And based on the type of object coming through the route I would hope that
> the correct subclass is called. However it looks like the package-scan does
> not setup this interface as a bean or try to setup the subclasses as I get
> the above error.
>
> Perhaps this is something which is fundamentally not possible with beans but
> it would be nice.
>
> Thanks
> Andrew
> --
> View this message in context: http://old.nabble.com/invoking-a-bean-via-an-interface-in-ContentRouter-tp27197844p27197844.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus