*/
package org.wamblee.system.spring;
+import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
private String[] _configFiles;
private Map<String, ProvidedInterface> _provided;
private Map<RequiredInterface, String> _required;
+ private Map<String, Properties> _propertyObjects;
/**
* Constructs a spring system.
_configFiles = aConfigFiles;
_provided = aProvided;
_required = aRequired;
+ _propertyObjects = new HashMap<String, Properties>();
+
}
/**
setProperty((String) key, aProperties.getProperty((String) key));
}
}
+
+ public void addProperties(String aBeanname, Properties aProperties) {
+ _propertyObjects.put(aBeanname, aProperties);
+ }
+
+ public Properties getProperties(String aBeanname) {
+ return _propertyObjects.get(aBeanname);
+ }
@Override
protected Scope doStart(Scope aExternalScope) {
GenericApplicationContext parentContext = new GenericApplicationContext();
registerRequiredServices(parentContext);
+ registerPropertyObjects(parentContext);
parentContext.refresh();
return scope;
} catch (Exception e) {
throw new SystemAssemblyException(
- "Failed to assemble spring system", e);
+ "Failed to assemble spring system " + getName(), e);
} finally {
THIS.set(old);
SCOPE.set(oldScope);
aParentContext.registerBeanDefinition(beanName, definition);
}
}
+
+ private void registerPropertyObjects(GenericApplicationContext aParentContext) {
+ for (String beanName: _propertyObjects.keySet()) {
+ ConstructorArgumentValues cargs = new ConstructorArgumentValues();
+ cargs.addGenericArgumentValue(PropertySetter.createPropertyFile(_propertyObjects.get(beanName)));
+ BeanDefinition definition = new RootBeanDefinition(
+ ConfiguredProperties.class, cargs,
+ new MutablePropertyValues());
+ aParentContext.registerBeanDefinition(beanName, definition);
+ }
+ }
+
@Override
protected void doStop(Scope aRuntime) {