For example, I have created 'test-meri-service' objects in my spring configuration and each object has the data I
Which is related to an inappropriate test scenario. Currently I'm manually editing Spring Config Every time, when I want to run a new scenario, or a list of scenarios. Is there a way, I can add a prefix for a bean name, and then with that prefix (or suffix) can I load all the list in the list or array? Something like this ....
& lt; Bean name = "env1-test1" /> & Lt; Bean name = "env2-test1" />
This is the code that I wrote, I was not able to start the Binfiner object from the example, which I previously accepted:
string [] BeanNames = context.getBeanNamesForType (Inputs.class); (String Beename: Beename) {If the name is (stars.wrightness ("NYV") {System.out.println ("found a bean of type + Inputs.class.getName ()); input bean = (input) Context.getBean (beanName); doTest (bean);}}
You can use the ListableBeanFactory
interface to load all the names, and then load the ones you are interested in:
Private @ Owned Listable BeanFactory beanFactory; Public Nothing doStuff () (for string beanName: beanFactory.getBeanDefinitionNames ()) {if (beanName.startsWith ("env")} {// or whatever you want to do, you object Bean = BeanFactor .getBean (beanName) / / Do something with it}}}
Alternatively, if the target beans are all of the same type, you can ask them for all types, instead of the name ListableBeanFactory.getBeansOfType ()
or ListableBeanFactory.getBeanNamesForType ()
.
Injection ListableBeanFactory
will be "current" application reference.
Comments
Post a Comment