RESOLVED - BATCH-635: samples review

added javadoc to dao interfaces
This commit is contained in:
robokaso
2008-06-03 10:27:30 +00:00
parent ca4fc0dbb4
commit 79d6f35ece
5 changed files with 51 additions and 40 deletions

View File

@@ -18,7 +18,12 @@ package org.springframework.batch.sample.dao;
import org.springframework.batch.sample.domain.CustomerDebit;
/**
* Interface for writing {@link CustomerDebitDao} object to arbitrary output.
*
* @author Robert.Kasanicky
*/
public interface CustomerDebitDao {
void write(CustomerDebit customerDebit);
}

View File

@@ -2,6 +2,9 @@ package org.springframework.batch.sample.dao;
import org.springframework.batch.sample.domain.Player;
/**
* Interface for writing {@link Player} objects to arbitrary output.
*/
public interface PlayerDao {
void savePlayer(Player player);

View File

@@ -18,18 +18,16 @@ package org.springframework.batch.sample.dao;
import org.springframework.batch.sample.domain.Trade;
/**
* Simple interface for writing a Trade object
* to an arbitraty output
*
* Interface for writing a Trade object to an arbitrary output.
*
* @author Robert Kasanicky
*/
public interface TradeDao {
/**
* Write a trade object to some kind of output,
* different implementations can write to file, database etc.
*/
void writeTrade(Trade trade);
/**
* Write a trade object to some kind of output, different implementations
* can write to file, database etc.
*/
void writeTrade(Trade trade);
}

View File

@@ -17,18 +17,19 @@
package org.springframework.batch.sample.item.writer;
import org.springframework.batch.item.AbstractItemWriter;
import org.springframework.batch.sample.dao.CustomerDebitDao;
import org.springframework.batch.sample.dao.JdbcCustomerDebitDao;
import org.springframework.batch.sample.domain.CustomerDebit;
import org.springframework.batch.sample.domain.Trade;
/**
* Transforms Trade to a CustomerDebit and asks dao object to write the result.
* Transforms Trade to a CustomerDebit and asks DAO delegate to write the result.
*
* @author Robert Kasanicky
*/
public class CustomerUpdateWriter extends AbstractItemWriter {
private JdbcCustomerDebitDao dao;
private CustomerDebitDao dao;
public void write(Object data) {
Trade trade = (Trade) data;

View File

@@ -22,44 +22,48 @@ import org.springframework.batch.item.AbstractItemWriter;
import org.springframework.batch.sample.dao.TradeDao;
import org.springframework.batch.sample.domain.Trade;
/**
* Delegates the actual writing to custom DAO delegate. Allows configurable
* exception raising for testing skip and restart.
*/
public class TradeWriter extends AbstractItemWriter {
private static Log log = LogFactory.getLog(TradeWriter.class);
private TradeDao dao;
private int failure = -1;
private int index = 0;
/**
private static Log log = LogFactory.getLog(TradeWriter.class);
private TradeDao dao;
private int failure = -1;
private int index = 0;
/**
* Public setter for the the index on which failure should occur.
*
*
* @param failure the failure to set
*/
public void setFailure(int failure) {
this.failure = failure;
}
public void write(Object data) {
if (!(data instanceof Trade)) {
log.warn("TradeProcessor can process only Trade objects, skipping record");
public void write(Object data) {
if (!(data instanceof Trade)) {
log.warn("TradeProcessor can process only Trade objects, skipping record");
return;
}
return;
}
Trade trade = (Trade) data;
log.debug(data);
Trade trade = (Trade) data;
log.debug(data);
//TODO put some processing of the trade object here
dao.writeTrade(trade);
if(index++ == failure) {
throw new RuntimeException("Something unexpected happened!");
}
}
// TODO put some processing of the trade object here
dao.writeTrade(trade);
public void setDao(TradeDao dao) {
this.dao = dao;
}
if (index++ == failure) {
throw new RuntimeException("Something unexpected happened!");
}
}
public void setDao(TradeDao dao) {
this.dao = dao;
}
}