Java Code Examples for org.springframework.batch.item.ExecutionContext#putString()
The following examples show how to use
org.springframework.batch.item.ExecutionContext#putString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomMultiResourcePartitioner.java From tutorials with MIT License | 6 votes |
/** * Assign the filename of each of the injected resources to an * {@link ExecutionContext}. * * @see Partitioner#partition(int) */ @Override public Map<String, ExecutionContext> partition(int gridSize) { Map<String, ExecutionContext> map = new HashMap<String, ExecutionContext>(gridSize); int i = 0, k = 1; for (Resource resource : resources) { ExecutionContext context = new ExecutionContext(); Assert.state(resource.exists(), "Resource does not exist: " + resource); context.putString(keyName, resource.getFilename()); context.putString("opFileName", "output" + k++ + ".xml"); map.put(PARTITION_KEY + i, context); i++; } return map; }
Example 2
Source File: ExecutionContextDeserializer.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Override public ExecutionContext deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); final ExecutionContext executionContext = new ExecutionContext(); final boolean dirty = node.get("dirty").asBoolean(); for (JsonNode valueNode : node.get("values")) { final JsonNode nodeValue = valueNode.fields().next().getValue(); final String nodeKey = valueNode.fields().next().getKey(); if (nodeValue.isNumber() && !nodeValue.isFloatingPointNumber() && nodeValue.canConvertToInt()) { executionContext.putInt(nodeKey, nodeValue.asInt()); } else if (nodeValue.isNumber() && !nodeValue.isFloatingPointNumber() && nodeValue.canConvertToLong()) { executionContext.putLong(nodeKey, nodeValue.asLong()); } else if (nodeValue.isFloatingPointNumber()) { executionContext.putDouble(nodeKey, nodeValue.asDouble()); } else if (nodeValue.isBoolean()) { executionContext.putString(nodeKey, String.valueOf(nodeValue.asBoolean())); } else if (nodeValue.isTextual()) { executionContext.putString(nodeKey, nodeValue.asText()); } else { executionContext.put(nodeKey, nodeValue.toString()); } } if (!dirty && executionContext.isDirty()) { executionContext.clearDirtyFlag(); } return executionContext; }
Example 3
Source File: StepExecutionJacksonMixInTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private StepExecution getStepExecution() { JobExecution jobExecution = new JobExecution(1L, null, "hi"); final StepExecution stepExecution = new StepExecution("step1", jobExecution); jobExecution.createStepExecution("step1"); final ExecutionContext executionContext = stepExecution.getExecutionContext(); executionContext.putInt("counter", 1234); executionContext.putDouble("myDouble", 1.123456d); executionContext.putLong("Josh", 4444444444L); executionContext.putString("awesomeString", "Yep"); executionContext.put("hello", "world"); executionContext.put("counter2", 9999); return stepExecution; }