Hi,

I have the following question.

What is the best way to inject a spring bean in a camel Routebuilder
class when this class is instantiated by camel through spring
<camelContext><package> ?

ex :

        <camelContext trace="true" 
xmlns="http://camel.apache.org/schema/spring";>
            <package>com.fusesource.camel.exercises.jms.transaction</package>

public class TransactionalJMSMessageProcessor extends RouteBuilder {
        
        private static final Logger logger =
LoggerFactory.getLogger(TransactionalJMSMessageProcessor.class);
        
        @EndpointInject(ref="queueIncoming")
        private Endpoint sourceUri;
        
        @EndpointInject(ref="queueOutgoing")
        private Endpoint targetUri;
        
        private JdbcTemplate jdbcTemplate;

        // Field to be setted by Spring with DataSource
        public void setDataSource(DataSource dataSource) {
                this.dataSource = dataSource;
                jdbcTemplate = new JdbcTemplate(dataSource);
        }

Using @Autowired ?

KR,

Charles Moulliard

Senior Enterprise Architect (J2EE, .NET, SOA)
Apache Camel/ServiceMix Committer

*******************************************************************
- Blog : http://cmoulliard.blogspot.com
- Twitter : http://twitter.com/cmoulliard
- Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Reply via email to