Esempio n. 1
0
  @Override
  public boolean write(Object object) throws DataException {

    if (closed) {
      throw new IllegalStateException("Writer closed.");
    }

    while (writers.size() > 0) {

      DataWriter currentWriter = writers.get(0);

      boolean keep = currentWriter.write(object);

      if (keep) {
        if (logger.isTraceEnabled()) {
          logger.trace("Current writer [" + currentWriter + "] requires more data.");
        }

        return true;
      } else {
        if (logger.isTraceEnabled()) {
          logger.trace("Current writer [" + currentWriter + "] complete.");
        }

        currentWriter.close();
        writers.remove(0);
      }
    }

    return false;
  }
Esempio n. 2
0
  @Override
  public void close() throws DataException {

    for (DataWriter currentWriter : writers) {

      logger.trace("Closing [" + currentWriter + "]");
      currentWriter.close();
    }

    writers.clear();
    closed = true;
  }