OPEN - BATCH-659: unused classes deprecation/removal
removed obsolete classes from xml package
This commit is contained in:
@@ -1,98 +0,0 @@
|
||||
package org.springframework.batch.item.xml.stax;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Class used to wrap XMLEventReader. Events from wrapped reader are stored in
|
||||
* {@link EventSequence} to support transactions.
|
||||
*
|
||||
* @deprecated no longer used, to be removed in 2.0
|
||||
*
|
||||
* @author Tomas Slanina
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class DefaultTransactionalEventReader extends AbstractEventReaderWrapper implements TransactionalEventReader, InitializingBean {
|
||||
|
||||
private EventSequence recorder = new EventSequence();
|
||||
|
||||
|
||||
/**
|
||||
* Creates instance of this class and wraps XMLEventReader.
|
||||
*
|
||||
* @param wrappedReader event reader to be wrapped.
|
||||
*/
|
||||
public DefaultTransactionalEventReader(XMLEventReader wrappedReader) {
|
||||
super(wrappedReader);
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(wrappedEventReader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback on transaction rollback.
|
||||
*/
|
||||
public void onRollback() {
|
||||
recorder.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback on transacion commit.
|
||||
*
|
||||
*/
|
||||
public void onCommit() {
|
||||
recorder.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if there are more events. Returns true if there are more events and
|
||||
* false otherwise.
|
||||
*
|
||||
* @return true if the event reader has more events, false otherwise
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return recorder.hasNext() || wrappedEventReader.hasNext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next XMLEvent
|
||||
*
|
||||
* @see XMLEvent
|
||||
* @throws XMLStreamException if there is an error with the underlying XML.
|
||||
* @throws NoSuchElementException iteration has no more elements.
|
||||
*/
|
||||
public XMLEvent nextEvent() throws XMLStreamException {
|
||||
if (!recorder.hasNext()) {
|
||||
recorder.addEvent(wrappedEventReader.nextEvent());
|
||||
}
|
||||
return recorder.nextEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the next XMLEvent without reading it from the stream. Returns null
|
||||
* if the stream is at EOF or has no more XMLEvents. A call to peek() will
|
||||
* be equal to the next return of next().
|
||||
*
|
||||
* @see XMLEvent
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public XMLEvent peek() throws XMLStreamException {
|
||||
return (recorder.hasNext()) ? recorder.peek() : wrappedEventReader.peek();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* In this implementation throws UnsupportedOperationException.
|
||||
*/
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package org.springframework.batch.item.xml.stax;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
/**
|
||||
* Holds a list of XML events, typically corresponding to a single record.
|
||||
*
|
||||
* @deprecated no longer used, to be removed in 2.0
|
||||
*
|
||||
* @author tomas.slanina
|
||||
*/
|
||||
class EventSequence {
|
||||
|
||||
private static final int BEFORE_BEGINNING = -1;
|
||||
|
||||
private List<XMLEvent> events;
|
||||
|
||||
private int currentIndex;
|
||||
|
||||
/**
|
||||
* Creates instance of this class.
|
||||
*
|
||||
*/
|
||||
public EventSequence() {
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds event to the list of stored events.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void addEvent(XMLEvent event) {
|
||||
events.add(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets next XMLEvent from cache and moves cursor to next event.
|
||||
* If cache contains no more events, null is returned.
|
||||
*/
|
||||
public XMLEvent nextEvent() {
|
||||
return (hasNext()) ? events.get(++currentIndex) :null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets next XMLEvent from cache but cursor remains on the same position.
|
||||
* If cache contains no more events, null is returned.
|
||||
*/
|
||||
public XMLEvent peek() {
|
||||
return (hasNext()) ? events.get(currentIndex+1) :null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes events from the internal cache.
|
||||
*
|
||||
*/
|
||||
public void clear() {
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets cursor to the cache start.
|
||||
*
|
||||
*/
|
||||
public void reset() {
|
||||
currentIndex = BEFORE_BEGINNING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are more events. Returns true if there are more events and
|
||||
* false otherwise.
|
||||
*
|
||||
* @return true if the event reader has more events, false otherwise
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return currentIndex + 1 < events.size();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
events = (events != null) ? new ArrayList<XMLEvent>(events.size())
|
||||
: new ArrayList<XMLEvent>(1000);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.springframework.batch.item.xml.stax;
|
||||
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
|
||||
/**
|
||||
* XMLEventReader with transactional capabilities (ability to rollback to last commit point).
|
||||
*
|
||||
* @deprecated no longer used, to be removed in 2.0
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public interface TransactionalEventReader extends XMLEventReader{
|
||||
|
||||
/**
|
||||
* Callback on transaction rollback.
|
||||
*/
|
||||
public void onRollback();
|
||||
|
||||
/**
|
||||
* Callback on transaction commit.
|
||||
*/
|
||||
public void onCommit();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user