Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:15:59+00:00 2026-06-17T22:15:59+00:00

If I have an OrderHandler interface: public interface OrderHandler { public void handle(Order order);

  • 0

If I have an OrderHandler interface:

public interface OrderHandler {
    public void handle(Order order);
}

And have several implementations (DefaultOrderHandler, ComplexOrderHandler, SpecialOrderHandler, etc.) of it, how do I specify which one to use in Camel’s SimpleRegistry? For instance, if I have the following route:

from("direct:pointA")
    .bean(OrderHandler.class)
    .to("direct:pointB");

How do I specify a SimpleRegistry, and how do I configure that registry to “inject” a DefaultOrderHandler when I specify a processor of type bean(OrderHandler.class)?

I ask because it would be nice (for unit testing) to be able to inject a DummyOrderHandler during testing, and a real impl during production. Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:16:00+00:00Added an answer on June 17, 2026 at 10:16 pm

    When using

    bean(MyClass.class)
    

    Then usually the class type (eg MyClass.class) must be a class (not abstract, not interface) as Camel will use that to instantiate an instance.

    However if the method that is being invoked is a static method, then Camel does not need to instantiate an object, and therefore the class can be abstract etc. You can supply the method name as a 2nd parameter to pint point which method to call.

    In your case have 3 different implementations of an interface. You need to specify the type to use

    bean(MyImpl.class)
    

    Or refer to a bean by a name to lookup in the registry, or provide an object instance
    For example:

    OrderHandler handler  = new DummyOrderHandler;
    ...
    bean(handler)
    

    As its just Java code, and if you are using RouteBuilder then you can juse have getter/setter for OrderHandler, and then set the desired implementation on RouteBuilder

    RouteBuilder myBuilder = new MyRouteBuilder();
    myBuilder.setOrderHandler(new DummyOrderHandler());
    ...
    

    And then in the configure method in MyRouteBuilder you can use

    bean(handler)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have defined a Java Interface with the annotation @WebService Compiled the code which went
Have a test program public class Path { public static void main(String[] args) {
Have added designer extensions to EDMX designer which allow me to specify additional information
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them
Have got a method which returns IEnumerable<User> which I have been using Linq /
Have started working my way through a book called WebGL: Up and Running, which
Have have created a child of UITableViewCell , MenuItem which contains functionality for my
Have a TSQL view, which I need to group by one column, however, am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.