Codota Logo
ResourceAwareItemWriterItemStream
Code IndexAdd Codota to your IDE (free)

How to use
ResourceAwareItemWriterItemStream
in
org.springframework.batch.item.file

Best Java code snippets using org.springframework.batch.item.file.ResourceAwareItemWriterItemStream (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-batch

@Override
public void write(List<? extends T> items) throws Exception {
  if (!opened) {
    File file = setResourceToDelegate();
    // create only if write is called
    file.createNewFile();
    Assert.state(file.canWrite(), "Output resource " + file.getAbsolutePath() + " must be writable");
    delegate.open(new ExecutionContext());
    opened = true;
  }
  delegate.write(items);
  currentResourceItemCount += items.size();
  if (currentResourceItemCount >= itemCountLimitPerResource) {
    delegate.close();
    resourceIndex++;
    currentResourceItemCount = 0;
    setResourceToDelegate();
    opened = false;
  }
}
origin: spring-projects/spring-batch

  /**
   * Create output resource (if necessary) and point the delegate to it.
   */
  private File setResourceToDelegate() throws IOException {
    String path = resource.getFile().getAbsolutePath() + suffixCreator.getSuffix(resourceIndex);
    File file = new File(path);
    delegate.setResource(new FileSystemResource(file));
    return file;
  }
}
origin: spring-projects/spring-batch

@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
  super.update(executionContext);
  if (saveState) {
    if (opened) {
      delegate.update(executionContext);
    }
    executionContext.putInt(getExecutionContextKey(CURRENT_RESOURCE_ITEM_COUNT), currentResourceItemCount);
    executionContext.putInt(getExecutionContextKey(RESOURCE_INDEX_KEY), resourceIndex);
  }
}
origin: com.github.almex/raildelays-batch

  delegate.open(executionContext);
  opened = true;
delegate.write(items);
    delegate.close();
    delegate.update(executionContext);
    opened = false;
origin: com.github.almex/raildelays-batch

@Override
public void write(List<? extends ExcelRow> items) throws Exception {
  if (!initialized && items.size() > 0) {
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
    String suffix = format.format(items.get(0).getDate());
    File file = ExcelFileUtils.getFile(new File(directoryPath), fileName, suffix, fileExtension);
    delegate.setResource(new FileSystemResource(file));
    delegate.open(executionContext);
    initialized = true;
  }
  delegate.write(items);
}
origin: com.github.almex/raildelays-batch

@Override
protected void doOpen() throws Exception {
  if (executionContext.containsKey(getExecutionContextKey(RESOURCE_KEY))) {
    resource = new FileSystemResource(executionContext.getString(getExecutionContextKey(RESOURCE_KEY), ""));
    // It's a restart
    delegate.open(executionContext);
    delegate.setResource(resource);
    // We don't have to create the resource
    opened = true;
    LOGGER.trace("Stream is opened");
  } else {
    opened = false;
    LOGGER.trace("Stream is not opened yet");
  }
}
origin: spring-projects/spring-batch

@Override
public void close() throws ItemStreamException {
  super.close();
  resourceIndex = 1;
  currentResourceItemCount = 0;
  if (opened) {
    delegate.close();
  }
}
origin: spring-projects/spring-batch

@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
  super.open(executionContext);
  resourceIndex = executionContext.getInt(getExecutionContextKey(RESOURCE_INDEX_KEY), 1);
  currentResourceItemCount = executionContext.getInt(getExecutionContextKey(CURRENT_RESOURCE_ITEM_COUNT), 0);
  try {
    setResourceToDelegate();
  }
  catch (IOException e) {
    throw new ItemStreamException("Couldn't assign resource", e);
  }
  if (executionContext.containsKey(getExecutionContextKey(CURRENT_RESOURCE_ITEM_COUNT))) {
    // It's a restart
    delegate.open(executionContext);
    opened = true;
  }
  else {
    opened = false;
  }
}
origin: com.github.almex/raildelays-batch

@Override
public void close() throws ItemStreamException {
  delegate.close();
  initialized = false;
}
origin: apache/servicemix-bundles

@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
  super.open(executionContext);
  resourceIndex = executionContext.getInt(getExecutionContextKey(RESOURCE_INDEX_KEY), 1);
  currentResourceItemCount = executionContext.getInt(getExecutionContextKey(CURRENT_RESOURCE_ITEM_COUNT), 0);
  try {
    setResourceToDelegate();
  }
  catch (IOException e) {
    throw new ItemStreamException("Couldn't assign resource", e);
  }
  if (executionContext.containsKey(getExecutionContextKey(CURRENT_RESOURCE_ITEM_COUNT))) {
    // It's a restart
    delegate.open(executionContext);
    opened = true;
  }
  else {
    opened = false;
  }
}
origin: com.github.almex/raildelays-batch

private void writeAll(List<? extends T> items) throws Exception {
  try {
    writer.open(executionContext);
    writer.write(items);
    LOGGER.debug("Written {} items", items.size());
  } finally {
    writer.close();
  }
}
origin: com.github.almex/raildelays-batch

@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
  delegate.update(executionContext);
}
origin: apache/servicemix-bundles

@Override
public void close() throws ItemStreamException {
  super.close();
  resourceIndex = 1;
  currentResourceItemCount = 0;
  if (opened) {
    delegate.close();
  }
}
origin: com.github.almex/raildelays-batch

private void initializeStreams() throws Exception {
  if (createBackupFile) {
    outputResource = new FileSystemResource(File.createTempFile(resource.getFilename(), ".tmp", resource.getFile().getParentFile()));
  } else {
    outputResource = resource;
  }
  reader.setResource(resource);
  writer.setResource(outputResource);
}
origin: apache/servicemix-bundles

@Override
public void write(List<? extends T> items) throws Exception {
  if (!opened) {
    File file = setResourceToDelegate();
    // create only if write is called
    file.createNewFile();
    Assert.state(file.canWrite(), "Output resource " + file.getAbsolutePath() + " must be writable");
    delegate.open(new ExecutionContext());
    opened = true;
  }
  delegate.write(items);
  currentResourceItemCount += items.size();
  if (currentResourceItemCount >= itemCountLimitPerResource) {
    delegate.close();
    resourceIndex++;
    currentResourceItemCount = 0;
    setResourceToDelegate();
    opened = false;
  }
}
origin: com.github.almex/raildelays-batch

@Override
public void update(ExecutionContext executionContext) {
  if (isSaveState()) {
    if (opened) {
      delegate.update(executionContext);
    }
    try {
      if (resource != null) {
        executionContext.putString(getExecutionContextKey(RESOURCE_KEY), resource.getFile().getAbsolutePath());
        LOGGER.trace("We store the resource={} into the execution context", resource.getFile().getAbsolutePath());
      }
    } catch (IOException e) {
      throw new ItemStreamException("Cannot get resource's absolute path", e);
    }
  }
}
origin: com.github.almex/raildelays-batch

@Override
protected void doClose() throws Exception {
  resource = null;
  setCurrentItemIndex(0);
  if (opened) {
    delegate.close();
    opened = false;
    LOGGER.trace("Stream is closed");
  }
}
origin: com.github.almex/raildelays-batch

/**
 * Create output resource (if necessary) and point the delegate to it.
 */
private File setResourceToDelegate() throws IOException {
  resource = resourceLocator.getResource(executionContext);
  delegate.setResource(resource);
  LOGGER.debug("Setting resource={} to delegate", resource != null ? resource.getFile().getAbsolutePath() : "null");
  return resource.getFile();
}
origin: apache/servicemix-bundles

@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
  super.update(executionContext);
  if (saveState) {
    if (opened) {
      delegate.update(executionContext);
    }
    executionContext.putInt(getExecutionContextKey(CURRENT_RESOURCE_ITEM_COUNT), currentResourceItemCount);
    executionContext.putInt(getExecutionContextKey(RESOURCE_INDEX_KEY), resourceIndex);
  }
}
origin: apache/servicemix-bundles

  /**
   * Create output resource (if necessary) and point the delegate to it.
   */
  private File setResourceToDelegate() throws IOException {
    String path = resource.getFile().getAbsolutePath() + suffixCreator.getSuffix(resourceIndex);
    File file = new File(path);
    delegate.setResource(new FileSystemResource(file));
    return file;
  }
}
org.springframework.batch.item.fileResourceAwareItemWriterItemStream

Javadoc

Interface for ItemWriters that implement ItemStream and write output to Resource.

Most used methods

  • close
  • open
  • setResource
  • update
  • write

Popular in Java

  • Running tasks concurrently on multiple threads
  • putExtra (Intent)
  • notifyDataSetChanged (ArrayAdapter)
  • runOnUiThread (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • String (java.lang)
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JButton (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now