]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ExecutionParameterPostProcessor.java
Introduce a factory bean to use execution resources
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / execution / ExecutionParameterPostProcessor.java
index 175ef778c68ce5cc502dd576616d57567eb82d1d..1bdd4f29a6d46a984443be4b213e7100bffbfda6 100644 (file)
@@ -1,12 +1,8 @@
 package org.argeo.slc.core.execution;\r
 \r
 import java.beans.PropertyDescriptor;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.Iterator;\r
-import java.util.LinkedHashMap;\r
-import java.util.LinkedHashSet;\r
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.Properties;\r
@@ -40,8 +36,6 @@ public class ExecutionParameterPostProcessor extends
 \r
        private InstantiationManager instantiationManager;\r
        \r
-       private Map<String, PropertyValues> storedPvsMap = new HashMap<String, PropertyValues>();\r
-\r
        public InstantiationManager getInstantiationManager() {\r
                return instantiationManager;\r
        }\r
@@ -73,67 +67,23 @@ public class ExecutionParameterPostProcessor extends
                        throws BeansException {\r
 \r
                //TODO: resolve at execution only if scope is execution\r
-                       \r
-               // if \r
-               PropertyValues sourcePvs = pvs;\r
-               if(storedPvsMap.containsKey(beanName)) {\r
-                       sourcePvs = storedPvsMap.get(beanName);\r
-                       log.info("Use storedPvsMap for bean " + beanName);\r
-               }\r
-               \r
+               //TODO: deal with placeholders in RuntimeBeanReference and RuntimeBeanNameReference\r
+                                       \r
                MutablePropertyValues newPvs = new MutablePropertyValues();\r
                \r
                boolean changesOccured = false;\r
                                \r
                CustomPpc ppc = new CustomPpc(beanName);\r
                \r
-               for(int i=0; i<sourcePvs.getPropertyValues().length; i++) {\r
-                       \r
-                       PropertyValue pv = pvs.getPropertyValues()[i];\r
-                       \r
-                       if (pv.getValue() instanceof TypedStringValue) {\r
-                               TypedStringValue tsv = (TypedStringValue) pv.getValue();\r
-                               String originalValue = tsv.getValue();\r
-                               String convertedValue = ppc.resolveString(originalValue);\r
-                               // add a new Property value to newPvs, identical to pv\r
-                               // except for the value\r
-                               newPvs.addPropertyValue(new PropertyValue(pv, new TypedStringValue(convertedValue)));\r
-                               if (!convertedValue.equals(originalValue)) {\r
-                                       changesOccured = true;\r
-                               }\r
-                       }\r
-                       else if (pv.getValue() instanceof String) {\r
-                               String originalValue = pv.getValue().toString();                        \r
-                               String convertedValue = ppc.resolveString(originalValue);\r
-                               newPvs.addPropertyValue(new PropertyValue(pv, convertedValue));\r
-                               if (!convertedValue.equals(originalValue)) {\r
-                                       changesOccured = true;\r
-                               }\r
-                       }               \r
-                       else if ((pv.getValue() instanceof ManagedMap)\r
-                                       ||(pv.getValue() instanceof ManagedList)\r
-                                       ||(pv.getValue() instanceof ManagedSet)){\r
-\r
-                               Object convertedValue = ppc.resolveValue(pv.getValue());\r
-                               newPvs.addPropertyValue(new PropertyValue(pv, convertedValue));\r
-                               if(convertedValue != pv.getValue()) {\r
-                                       changesOccured = true;\r
-                               }\r
-                       }               \r
-                       else {\r
-                               newPvs.addPropertyValue(new PropertyValue(pv));\r
+               for(PropertyValue pv : pvs.getPropertyValues()) {\r
+                       Object convertedValue = ppc.resolveValue(pv.getValue());\r
+                       newPvs.addPropertyValue(new PropertyValue(pv, convertedValue));\r
+                       if(convertedValue != pv.getValue()) {\r
+                               changesOccured = true;\r
                        }\r
                }\r
                \r
-               if(changesOccured) {\r
-                       storedPvsMap.put(beanName, pvs);\r
-                       log.info("Add storedPvsMap for Bean " + beanName);\r
-                       return newPvs;\r
-               }\r
-               else {\r
-                       // no change, return pvs\r
-                       return pvs;\r
-               }\r
+               return changesOccured ? newPvs : pvs;\r
        }\r
 \r
        public void setPlaceholderPrefix(String placeholderPrefix) {\r
@@ -181,7 +131,7 @@ public class ExecutionParameterPostProcessor extends
                                String convertedValue = resolveString(originalValue);\r
                                return convertedValue.equals(originalValue) ? value : convertedValue;\r
                        }               \r
-                       else if (value instanceof Map) {\r
+                       else if (value instanceof ManagedMap) {\r
                                Map mapVal = (Map) value;\r
                                \r
                                Map newContent = new ManagedMap();\r
@@ -200,7 +150,7 @@ public class ExecutionParameterPostProcessor extends
                                \r
                                return entriesModified ? newContent : value;\r
                        }\r
-                       else if (value instanceof List) {\r
+                       else if (value instanceof ManagedList) {\r
                                List listVal = (List) value;\r
                                List newContent = new ManagedList();\r
                                boolean valueModified = false;\r
@@ -215,7 +165,7 @@ public class ExecutionParameterPostProcessor extends
                                }                       \r
                                return valueModified ? newContent : value;\r
                        }\r
-                       else if (value instanceof Set) {\r
+                       else if (value instanceof ManagedSet) {\r
                                Set setVal = (Set) value;\r
                                Set newContent = new ManagedSet();\r
                                boolean entriesModified = false;\r