/** * Get a copy of the map keyed with ids. * * @param mergeParents * true to merge with the map from parent context, false not to. * @param includesRoot * true to include the map from the root context, false not to. * If the current is already root context, set to false will * result in empty map being returned. * @return the map copy. */ public Map<String, Object> getIdMap(boolean mergeParents, boolean includesRoot) { if (mergeParents) { Map<String, Object> map = new HashMap<String, Object>(); if (parent != null && (includesRoot || parent != root)) { map.putAll(parent.getIdMap(mergeParents, includesRoot)); } if (includesRoot || !isRoot()) { map.putAll(idConstsMap); } return map; } else { if (includesRoot || !isRoot()) { return new LinkedHashMap<String, Object>(idConstsMap); } else { return new LinkedHashMap<String, Object>(0); } } }
/** * Get a copy of the map keyed with ids. * * @param mergeParents * true to merge with the map from parent context, false not to. * @param includesRoot * true to include the map from the root context, false not to. * If the current is already root context, set to false will * result in empty map being returned. * @return the map copy. */ public Map<String, Object> getIdMap(boolean mergeParents, boolean includesRoot) { if (mergeParents) { Map<String, Object> map = new LinkedHashMap<String, Object>(); if (parent != null && (includesRoot || parent != root)) { map.putAll(parent.getIdMap(mergeParents, includesRoot)); } if (includesRoot || !isRoot()) { map.putAll(idConstsMap); } return map; } else { if (includesRoot || !isRoot()) { return new LinkedHashMap<String, Object>(idConstsMap); } else { return new LinkedHashMap<String, Object>(0); } } }
Map<String, Object> map = excludesParentContext ? context.getIdConstsMap() : context.getIdMap( mergeWithParentContext, true); if (inheritance) {
Map<String, Object> map = excludesParentContext ? context.getIdConstsMap() : context.getIdMap(mergeWithParentContext, true); if (inheritance) { Class clazz = Class.forName(className);
private void finishUpLaunchModel(Context context) { LaunchModel model = getLaunchModel(context); // put the global properties Properties globalProps = model.getGlobalSettings().getProperties(); final Set<String> propIds = context.getPropertyConstIds(false); for (Map.Entry<String, Object> entry : context.getIdMap(false, true).entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value == null || key == null || !propIds.contains(key)) { continue; } globalProps.put(key, value); } globalProps.remove(LaunchModel.class); System.getProperties().remove(LaunchModel.class); // merge local factors with global ones if needed final Map<String, Factor> globalFactors = model.getGlobalSettings().getFactors(); for (Group group : model.getGroups().values()) { for (Factor factor : group.getSettings().getFactors().values()) { if (factor.isMergeGlobal()) { Factor globalFactor = globalFactors.get(factor.getName()); if (globalFactor != null) { factor.getValues().addAll(globalFactor.getValues()); } } } } }
private void finishUpLaunchModel(Context context) { LaunchModel model = getLaunchModel(context); Integer concurrency = context.getConst(CONCURRENCY_CONST, true, Integer.class); model.setConcurrency(concurrency == null ? 0 : concurrency); // put the global properties Properties globalProps = model.getGlobalSettings().getProperties(); final Set<String> propIds = context.getPropertyConstIds(false); for (Map.Entry<String, Object> entry : context.getIdMap(false, true).entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value == null || key == null || !propIds.contains(key)) { continue; } globalProps.put(key, value); } globalProps.remove(LaunchModel.class); System.getProperties().remove(LaunchModel.class); // merge local factors with global ones if needed final Map<String, Factor> globalFactors = model.getGlobalSettings().getFactors(); for (Group group : model.getGroups().values()) { for (Factor factor : group.getSettings().getFactors().values()) { if (factor.isMergeGlobal()) { Factor globalFactor = globalFactors.get(factor.getName()); if (globalFactor != null) { factor.getValues().addAll(globalFactor.getValues()); } } } } }
@Override protected Object doInvoke(Context context) throws Exception { Binding binding = new Binding(); // inject all context variables into groovy for (Map.Entry<String, Object> entry : context.getIdMap(true, true).entrySet()) { binding.setVariable(entry.getKey(), entry.getValue()); } // set the util functions for (ITagLibrary tagLib : context.getPaxml().getParser().getTagLibraries()) { for (String util : tagLib.getUtilFunctionsFactoryNames()) { Class<? extends IUtilFunctionsFactory> clazz = (Class<? extends IUtilFunctionsFactory>) tagLib .getUtilFunctionsFactory(util); if (clazz != null) { Object utilObj = ReflectUtils.createObject(clazz).getUtilFunctions(context); if (utilObj != null) { binding.setVariable(util, utilObj); } } } } GroovyShell shell = new GroovyShell(binding); Object value = getValue(); Object result = shell.evaluate(String.valueOf(value)); return result; }
@Override protected Object doInvoke(Context context) throws Exception { Binding binding = new Binding(); // inject all context variables into groovy for (Map.Entry<String, Object> entry : context.getIdMap(true, true).entrySet()) { binding.setVariable(entry.getKey(), entry.getValue()); } // set the util functions for (ITagLibrary tagLib : context.getPaxml().getParser().getTagLibraries()) { for (String util : tagLib.getUtilFunctionsFactoryNames()) { Class<? extends IUtilFunctionsFactory> clazz = (Class<? extends IUtilFunctionsFactory>) tagLib .getUtilFunctionsFactory(util); if (clazz != null) { Object utilObj = ReflectUtils.createObject(clazz).getUtilFunctions(context); if (utilObj != null) { binding.setVariable(util, utilObj); } } } } GroovyShell shell = new GroovyShell(binding); Object value = getValue(); Object result = shell.evaluate(String.valueOf(value)); return result; }
Map<String, Object> map = context.getIdMap(true, true); for (Map.Entry<String, Object> entry : map.entrySet()) { final String key = entry.getKey();
Map<String, Object> map = context.getIdMap(true, true); for (Map.Entry<String, Object> entry : map.entrySet()) { final String key = entry.getKey();