camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom McGee <t.mcgee.lazy...@gmail.com>
Subject Global configuration of CamelContext
Date Sat, 27 Jun 2015 00:17:51 GMT
In an app I’m working on we have a need to make sure that all
CamelContext’s have some default configurations on them. We are using
CamelConfiguration. It would be best in our case if we could do this
configuration though spring. This is what I did after looking for an
existing solution.



I defined an interface like this:

*public* *interface* CamelContextConfigVisitor {

    *public* CamelContext config(CamelContext camelContext);

}



Then I sub-classed CamelConfiguration and did this override:

@Override

*protected* CamelContext createCamelContext() *throws* Exception {

    CamelContext camelContext = *super*.createCamelContext();

   Map<String,CamelContextConfigVisitor> decorators =

         getApplicationContext().getBeansOfType(CamelContextConfigVisitor.
*class*);

   *for*(String name: decorators.keySet()){

      CamelContextConfigVisitor visitor =
getApplicationContext().getBean(name,

            CamelContextConfigVisitor.*class*);

      camelContext = visitor.config(camelContext);

   }

   *return* camelContext;

}



Is there an existing solution I could use?

Does this solution look ok?

Would it be possible to get this added code to the CamelConfiguration?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message