/** * Initializes a new {@link ExecutionContext} with the contents of another * {@code ExecutionContext}. * * @param executionContext containing the entries to be copied to this current context. */ public ExecutionContext(ExecutionContext executionContext) { this(); if (executionContext == null) { return; } for (Entry<String, Object> entry : executionContext.entrySet()) { this.map.put(entry.getKey(), entry.getValue()); } }
/** * @return a map containing the items from the job {@link ExecutionContext} */ public Map<String, Object> getJobExecutionContext() { Map<String, Object> result = new HashMap<>(); for (Entry<String, Object> entry : jobExecution.getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
/** * @return a map containing the items from the step {@link ExecutionContext} */ public Map<String, Object> getStepExecutionContext() { Map<String, Object> result = new HashMap<>(); for (Entry<String, Object> entry : stepExecution.getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
/** * @return a map containing the items from the job {@link ExecutionContext} */ public Map<String, Object> getJobExecutionContext() { Map<String, Object> result = new HashMap<>(); for (Entry<String, Object> entry : stepExecution.getJobExecution().getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
private String serializeContext(ExecutionContext ctx) { Map<String, Object> m = new HashMap<>(); for (Entry<String, Object> me : ctx.entrySet()) { m.put(me.getKey(), me.getValue()); } ByteArrayOutputStream out = new ByteArrayOutputStream(); String results = ""; try { serializer.serialize(m, out); results = new String(out.toByteArray(), "ISO-8859-1"); } catch (IOException ioe) { throw new IllegalArgumentException("Could not serialize the execution context", ioe); } return results; }
@Override public void beforeJob(JobExecution jobExecution) { ExecutionContext jobContext = jobExecution.getExecutionContext(); for (Map.Entry<String, Object> entry : jobExecutionContext.entrySet()) { jobContext.put(entry.getKey(), entry.getValue()); } } } });
/** * If there is a cached peek, then retrieve the execution context state from * that point. If there is no peek cached, then call directly to the * delegate. * * @param executionContext the current context * @throws ItemStreamException if there is a problem * @see ItemStream#update(ExecutionContext) */ @Override public void update(ExecutionContext executionContext) throws ItemStreamException { if (next != null) { // Get the last state from the delegate instead of using // current value. for (Entry<String, Object> entry : this.executionContext.entrySet()) { executionContext.put(entry.getKey(), entry.getValue()); } return; } updateDelegate(executionContext); }
@Test public void testDefaultStreamContext() throws Exception { writer = new FlatFileItemWriter<>(); writer.setResource(new FileSystemResource(outputFile)); writer.setLineAggregator(new PassThroughLineAggregator<>()); writer.afterPropertiesSet(); writer.setSaveState(true); writer.open(executionContext); writer.update(executionContext); assertNotNull(executionContext); assertEquals(2, executionContext.entrySet().size()); assertEquals(0, executionContext.getLong(ClassUtils.getShortName(FlatFileItemWriter.class) + ".current.count")); }
@Override public Set<String> $keySet(ExecutionContext entity) { Set<String> result = entity.entrySet().stream().map(x -> x.getKey()).collect(Collectors.toSet()); return result; }
/** * @return a map containing the items from the step {@link ExecutionContext} */ public Map<String, Object> getStepExecutionContext() { Map<String, Object> result = new HashMap<String, Object>(); for (Entry<String, Object> entry : stepExecution.getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
/** * @return a map containing the items from the job {@link ExecutionContext} */ public Map<String, Object> getJobExecutionContext() { Map<String, Object> result = new HashMap<String, Object>(); for (Entry<String, Object> entry : jobExecution.getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
private String serializeContext(ExecutionContext ctx) { Map<String, Object> m = new HashMap<String, Object>(); for (Entry<String, Object> me : ctx.entrySet()) { m.put(me.getKey(), me.getValue()); } return serializer.serialize(m); }
/** * @return a map containing the items from the job {@link ExecutionContext} */ public Map<String, Object> getJobExecutionContext() { Map<String, Object> result = new HashMap<String, Object>(); for (Entry<String, Object> entry : jobExecution.getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
/** * @return a map containing the items from the step {@link ExecutionContext} */ public Map<String, Object> getStepExecutionContext() { Map<String, Object> result = new HashMap<String, Object>(); for (Entry<String, Object> entry : stepExecution.getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
/** * @return a map containing the items from the step {@link ExecutionContext} */ public Map<String, Object> getStepExecutionContext() { Map<String, Object> result = new HashMap<String, Object>(); for (Entry<String, Object> entry : stepExecution.getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
@Override public void setItems(Object entity, Iterator<?> items) { ExecutionContext ec = (ExecutionContext)entity; Set<String> keySet = ec.entrySet().stream().map(e -> e.getKey()).collect(Collectors.toSet()); keySet.forEach(key -> ec.remove(key)); items.forEachRemaining(i -> { Entry e = (Entry)i; ec.put((String)e.getKey(), e.getValue()); }); } }
/** * @return a map containing the items from the job {@link ExecutionContext} */ public Map<String, Object> getJobExecutionContext() { Map<String, Object> result = new HashMap<String, Object>(); for (Entry<String, Object> entry : stepExecution.getJobExecution().getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
/** * @return a map containing the items from the job {@link ExecutionContext} */ public Map<String, Object> getJobExecutionContext() { Map<String, Object> result = new HashMap<String, Object>(); for (Entry<String, Object> entry : stepExecution.getJobExecution().getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }
/** * @return a map containing the items from the job {@link ExecutionContext} */ public Map<String, Object> getJobExecutionContext() { Map<String, Object> result = new HashMap<String, Object>(); for (Entry<String, Object> entry : stepExecution.getJobExecution().getExecutionContext().entrySet()) { result.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(result); }