This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

The values for constructing LDAPTemplate, well contextSource inside it for LDAP details gets fetched from a property file. Same applies for JDBCTemplate.

there can be multiple property files, or perhaps let's DB rows holding the configurations. We need to create one instance of Class A per property file found.

I would have deviated away from requiring to create Spring bean and have it used as domain objects but Spring's dependency on Jdbctemplate or ldapTemplate which subsequently uses InitializingBean makes me feel it's good if i can get them created from IoC Container.

Is there a way through JavaConfig where I can programatically create bean definitions for multiple instances of same Class. I am aware I can do something like this with BeanFactoryPostProcessor or BeanRegistryPostProcessor and using BeanDefinitonBuilder but to me doing it thru JavaConfig would look more elegant.

I want that every time I drop a property file that contains configuration for a new instance of Class A, automatically a new instance is created. All property files stay in a pre-known directory path which gets loaded by propertyplaceholderconfigured and gets injected into a class that's responsible for creating these dynamic beans.