X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fspring%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fspring%2FSpringComponent.java;h=0e4c62eb1fe26ae2ccb858342053d818e9af0749;hb=0d8d8f24656e585ee75558cfd6a4c661f8f14985;hp=88746a5ecc4a94f50a0af17653a49a05bce7f51d;hpb=da48a523c81e59fe0eac34e43d12937396161f25;p=utils diff --git a/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java b/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java index 88746a5e..0e4c62eb 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java @@ -46,11 +46,11 @@ public class SpringComponent extends AbstractComponent { static final ThreadLocal THIS = new ThreadLocal(); static final ThreadLocal SCOPE = new ThreadLocal(); - private Properties _properties; - private String[] _configFiles; - private Map _provided; - private Map _required; - private Map _propertyObjects; + private Properties properties; + private String[] configFiles; + private Map provided; + private Map required; + private Map propertyObjects; /** * Constructs a spring system. @@ -73,11 +73,11 @@ public class SpringComponent extends AbstractComponent { Map aRequired) { super(aName, aProvided.values().toArray(new ProvidedInterface[0]), aRequired.keySet().toArray(new RequiredInterface[0])); - _properties = new Properties(); - _configFiles = aConfigFiles; - _provided = aProvided; - _required = aRequired; - _propertyObjects = new HashMap(); + properties = new Properties(); + configFiles = aConfigFiles; + provided = aProvided; + required = aRequired; + propertyObjects = new HashMap(); } @@ -90,7 +90,7 @@ public class SpringComponent extends AbstractComponent { * Property value. */ public void setProperty(String aKey, String aValue) { - _properties.put(aKey, aValue); + properties.put(aKey, aValue); } public void addProperties(Properties aProperties) { @@ -100,11 +100,11 @@ public class SpringComponent extends AbstractComponent { } public void addProperties(String aBeanname, Properties aProperties) { - _propertyObjects.put(aBeanname, aProperties); + propertyObjects.put(aBeanname, aProperties); } public Properties getProperties(String aBeanname) { - return _propertyObjects.get(aBeanname); + return propertyObjects.get(aBeanname); } @Override @@ -128,7 +128,7 @@ public class SpringComponent extends AbstractComponent { AbstractApplicationContext context = parseConfigFiles(parentContext); context - .addBeanFactoryPostProcessor(new PropertySetter(_properties)); + .addBeanFactoryPostProcessor(new PropertySetter(properties)); context.refresh(); exposeProvidedServices(context, aExternalScope); @@ -147,31 +147,31 @@ public class SpringComponent extends AbstractComponent { private void exposeProvidedServices(AbstractApplicationContext aContext, Scope aScope) { // Call addService for each provided service. - for (String name : _provided.keySet()) { + for (String name : provided.keySet()) { Object svc = aContext.getBean(name); if (svc == null) { throw new IllegalArgumentException(getQualifiedName() + ": service '" + name + "' is null"); } - addInterface(_provided.get(name), svc, aScope); - System.out.println("addService " + _provided.get(name) + " " + svc); + addInterface(provided.get(name), svc, aScope); + System.out.println("addService " + provided.get(name) + " " + svc); } } private AbstractApplicationContext parseConfigFiles(GenericApplicationContext aParentContext) { // Parse spring config files - return new ClassPathXmlApplicationContext((String[]) _configFiles, + return new ClassPathXmlApplicationContext((String[]) configFiles, false, aParentContext); } private void registerRequiredServices(GenericApplicationContext aParentContext) { // Register required services in a parent context - for (RequiredInterface required: getRequiredInterfaces()) { - String beanName = _required.get(required); + for (RequiredInterface requiredIntf: getRequiredInterfaces()) { + String beanName = required.get(requiredIntf); if ( beanName != null && beanName.length() > 0) { ConstructorArgumentValues cargs = new ConstructorArgumentValues(); - cargs.addGenericArgumentValue(required.getName()); + cargs.addGenericArgumentValue(requiredIntf.getName()); BeanDefinition definition = new RootBeanDefinition( RequiredServiceBean.class, cargs, new MutablePropertyValues()); @@ -183,9 +183,9 @@ public class SpringComponent extends AbstractComponent { } private void registerPropertyObjects(GenericApplicationContext aParentContext) { - for (String beanName: _propertyObjects.keySet()) { + for (String beanName: propertyObjects.keySet()) { ConstructorArgumentValues cargs = new ConstructorArgumentValues(); - cargs.addGenericArgumentValue(PropertySetter.createPropertyFile(_propertyObjects.get(beanName))); + cargs.addGenericArgumentValue(PropertySetter.createPropertyFile(propertyObjects.get(beanName))); BeanDefinition definition = new RootBeanDefinition( ConfiguredProperties.class, cargs, new MutablePropertyValues());