Sure, all I'm doing is creating a Generic app context and using an XmlBeanDefinitionReader to load a set of Resources. Here's my util method that takes a bean registry and loads it up with a set of confgs. I'll note that the Resource objects passed in as an argument are not Spring's org.springframework.core.io.Resource objects but are very similar.
Code:
public static void populateRegistry(BeanDefinitionRegistry beanRegistry, List<Resource> configurationResources)
throws ResourceException {
XmlBeanDefinitionReader configReader = new XmlBeanDefinitionReader(beanRegistry);
configReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
configReader.setDocumentLoader(new SpringDocumentLoader());
int numOfResources = configurationResources.size();
org.springframework.core.io.Resource[] configSources = new org.springframework.core.io.Resource[numOfResources];
for (int i = 0; i < numOfResources; i++) {
configSources[i] = new InputStreamResource(configurationResources.get(i).getInputStream());
}
try {
configReader.loadBeanDefinitions(configSources);
} catch (BeanDefinitionStoreException e) {
throw new ResourceException("Unable to load Spring bean registry with configuration resources", e);
}
}
And my code that calls the above method is just:
Code:
GenericApplicationContext gContext = new GenericApplicationContext();
SpringConfigurationUtils.populateRegistry(gContext, configs);
And the Spring config for my configuration bean is (I explicitly set the lazy-init method simply to be sure that the documented default wasn't incorrect):
HTML Code:
<!-- Spring configuration file that boostraps OpenSAML -->
<bean id="shibboleth.OpensamlConfig" class="edu.internet2.middleware.shibboleth.common.config.OpensamlConfigBean" lazy-init="false">
<constructor-arg>
<list>
<!-- snip... List o' config strings -->
</list>
</constructor-arg>
</bean>