Example usage for org.springframework.batch.item ReaderNotOpenException ReaderNotOpenException

List of usage examples for org.springframework.batch.item ReaderNotOpenException ReaderNotOpenException

Introduction

In this page you can find the example usage for org.springframework.batch.item ReaderNotOpenException ReaderNotOpenException.

Prototype

public ReaderNotOpenException(String message) 

Source Link

Document

Create a new ReaderNotOpenException based on a message.

Usage

From source file:org.springframework.batch.sample.common.StagingItemReader.java

@Override
public ProcessIndicatorItemWrapper<T> read() {
    if (!initialized) {
        throw new ReaderNotOpenException("Reader must be open before it can be used.");
    }/*from  w  ww.  java 2  s  .  c o  m*/

    Long id = null;
    synchronized (lock) {
        if (keys.hasNext()) {
            id = keys.next();
        }
    }
    logger.debug("Retrieved key from list: " + id);

    if (id == null) {
        return null;
    }
    @SuppressWarnings("unchecked")
    T result = (T) jdbcTemplate.queryForObject("SELECT VALUE FROM BATCH_STAGING WHERE ID=?",
            new RowMapper<Object>() {
                @Override
                public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                    byte[] blob = rs.getBytes(1);
                    return SerializationUtils.deserialize(blob);
                }
            }, id);

    return new ProcessIndicatorItemWrapper<T>(id, result);
}