I am going to start a new project using Spring framework. As I dont have much experience in Spring I need your help to sort out few confusions.
Lets look at use case
My application uses Spring integration framework. The core functionality of my app is,
- I need to poll multiple directories from file system,
- read the files(csv mostly),
- process some operations on them and insert them to database.
Currently I have set up spring integration flow for it. Which has inbound-chaneell-adapter
for polling and then file traverse through the channels and at the end inserted into database.
My concerns are
-
Number of directories application supposed to poll will be decided at runtime. Hence I need to create
inbound-chanell-adapter
at runtime (as one chanell adapter can poll only one directory at once) and cant define them statically in my spring context xml (As I dont know the how many I need). -
Each directory has certain properties which should be applied to the file while processing.(While going through the integration flow)
-
So right now what I am doing is I am loading
new ClassPathXmlApplicationContext("/applicationContext.xml");
for each directory. And cache the required properties in that newly created context. And use them at the time of processing (in<int:service-activator>
).
Drawbacks of current design
- Separate context is created for each directory.
- Unnecessary beans are duplicated. (Database session factories and like)
So is there any way to design the application in such a way that context will not be duplicated. And still I can use properties of each directory throughout the integration flow at the same time???
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire