Example usage for org.springframework.batch.sample.common ProcessIndicatorItemWrapper ProcessIndicatorItemWrapper

List of usage examples for org.springframework.batch.sample.common ProcessIndicatorItemWrapper ProcessIndicatorItemWrapper

Introduction

In this page you can find the example usage for org.springframework.batch.sample.common ProcessIndicatorItemWrapper ProcessIndicatorItemWrapper.

Prototype

public ProcessIndicatorItemWrapper(long id, T item) 

Source Link

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.");
    }//w  w  w .ja  v  a2 s  . co  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);
}