+/*\r
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
package org.argeo.slc.core.execution;\r
\r
import java.beans.PropertyDescriptor;\r
import org.springframework.util.ObjectUtils;\r
import org.springframework.util.StringUtils;\r
\r
+/**\r
+ * Spring post processor which ensures that execution parameters are properly\r
+ * set. It is used at two levels: first during instantiation for instantiation\r
+ * parameters which allow to implement templates, then at runtime in order to\r
+ * interpret @{} placeholders when object of scope execution are instantiated.\r
+ */\r
public class ExecutionParameterPostProcessor extends\r
InstantiationAwareBeanPostProcessorAdapter {\r
\r
placeholder).toString();\r
\r
else {// execution\r
- // next call fail if no execution context available\r
+ // next call fail if no execution context available\r
Object obj = executionContext.getVariable(placeholder);\r
if (obj != null) {\r
return obj.toString();\r
return convertedValue.equals(originalValue) ? value\r
: convertedValue;\r
} else if (value instanceof ManagedMap) {\r
- Map mapVal = (Map) value;\r
+ Map<?, ?> mapVal = (Map<?, ?>) value;\r
\r
- Map newContent = new ManagedMap();\r
+ Map<Object, Object> newContent = new ManagedMap();\r
boolean entriesModified = false;\r
- for (Iterator it = mapVal.entrySet().iterator(); it.hasNext();) {\r
- Map.Entry entry = (Map.Entry) it.next();\r
+ for (Iterator<?> it = mapVal.entrySet().iterator(); it.hasNext();) {\r
+ Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();\r
Object key = entry.getKey();\r
int keyHash = (key != null ? key.hashCode() : 0);\r
Object newKey = resolveValue(beanName, bean, key);\r
\r
return entriesModified ? newContent : value;\r
} else if (value instanceof ManagedList) {\r
- List listVal = (List) value;\r
- List newContent = new ManagedList();\r
+ List<?> listVal = (List<?>) value;\r
+ List<Object> newContent = new ManagedList();\r
boolean valueModified = false;\r
\r
for (int i = 0; i < listVal.size(); i++) {\r
}\r
return valueModified ? newContent : value;\r
} else if (value instanceof ManagedSet) {\r
- Set setVal = (Set) value;\r
- Set newContent = new ManagedSet();\r
+ Set<?> setVal = (Set<?>) value;\r
+ Set<Object> newContent = new ManagedSet();\r
boolean entriesModified = false;\r
- for (Iterator it = setVal.iterator(); it.hasNext();) {\r
+ for (Iterator<?> it = setVal.iterator(); it.hasNext();) {\r
Object elem = it.next();\r
int elemHash = (elem != null ? elem.hashCode() : 0);\r
Object newVal = resolveValue(beanName, bean, elem);\r
// previously resolved placeholder value.\r
propVal = parseStringValue(bean, propVal,\r
visitedPlaceholders);\r
- buf.replace(startIndex, endIndex\r
- + placeholderSuffix.length(), propVal);\r
+ buf.replace(startIndex,\r
+ endIndex + placeholderSuffix.length(), propVal);\r
if (log.isTraceEnabled()) {\r
log.trace("Resolved placeholder '" + placeholder + "'");\r
}\r