Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring beans based on properties

Tags:

java

spring

I am wondering if the below is possible in Spring

  1. Read a property file using spring - this file has a list of jms queue names
  2. Make spring loop on the above list and define beans that define Apache camel routes from that queue to a file

I could just create the routes using java code on the apache camel context, but wondering if it is possible through spring.

like image 623
Hari Avatar asked Dec 06 '25 02:12

Hari


1 Answers

Reading a property file in a Spring XML wiring file is easy; e.g. using a PropertiesFactoryBean. However, the second part of the problem cannot (I believe) be solved without writing a significant amount of Java code.

I suggest that you read Section 3.8.3 of the Spring Reference that describes how to write your own FactoryBean classes. Another possibility is to create a custom Java configuration bean as described in Section 3.11. There may be other possibilities too.

Warning: none of this stuff is particularly straight-forward if you are coming at it for the first time.

like image 164
Stephen C Avatar answered Dec 08 '25 16:12

Stephen C