XMLGenerator gen = new XMLGenerator();
ByteArrayOutputStream baos = new ByteArrayOutputStream(allProps.size() * 10);
gen.convertProps2XML("beans", allProps.values(), baos);
// 1. Initialize the modern factory implementation
DefaultListableBeanFactory configBeanFactory = new DefaultListableBeanFactory();
// 2. Use a reader to load the XML definitions from your byte array
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(configBeanFactory);
reader.loadBeanDefinitions(new ByteArrayResource(baos.toByteArray()));
// 3. Modern replacement for your manual for-loop:
// This eagerly initializes all non-lazy singletons in the factory
configBeanFactory.preInstantiateSingletons();
// If you still need the loop for specific logging or side effects:
for (String string : configBeanFactory.getBeanDefinitionNames()) {
configBeanFactory.getBean(string);
System.out.println();
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)