本文整理汇总了Java中org.springframework.batch.item.NonTransientResourceException类的典型用法代码示例。如果您正苦于以下问题:Java NonTransientResourceException类的具体用法?Java NonTransientResourceException怎么用?Java NonTransientResourceException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NonTransientResourceException类属于org.springframework.batch.item包,在下文中一共展示了NonTransientResourceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public MyObject read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
// TODO: Reader business.
final MyObject item = new MyObject("id " + counter, "Name " + counter);
counter++;
if(item.getId().contains("3")){
throw new CustomSkipableException();
}
// The step ends when the reader returns null.
if(counter > 10){
return null;
}
return item;
}
示例2: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
/**
*
*/
@Override
public String read()
throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException
{
if(i == null)
{
Collection<String> emails = email.shouldRemoveEmails();
if(emails == null)
return null;
this.i = emails.iterator();
}
if(i.hasNext())
return i.next();
return null;
}
示例3: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
/**
* @return the current row (convert if conversion was provided)
* @see org.springframework.batch.item.ItemReader#read()
*/
@SuppressWarnings("unchecked")
@Override
public T read() throws Exception, UnexpectedInputException, ParseException,
NonTransientResourceException
{
//read
if(index > this.rowCount -1)
return null; //end of the sheet
if(this.conversion != null)
return this.conversion.convert(sheet.getRow(this.index++));
return (T)sheet.getRow(this.index++);
}
示例4: read_twoCoursesList
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Test
public void read_twoCoursesList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
when(daoManagerMock.chekImportedData()).thenReturn(true);
List<Long> CreatedSapCourcesIds = new ArrayList<Long>();
CreatedSapCourcesIds.add(100L);
CreatedSapCourcesIds.add(200L);
when(daoManagerMock.getAllCreatedSapCourcesIds()).thenReturn(CreatedSapCourcesIds);
CampusCourseImportTO courseMock1 = mock(CampusCourseImportTO.class);
CampusCourseImportTO courseMock2 = mock(CampusCourseImportTO.class);
when(daoManagerMock.getSapCampusCourse(100L)).thenReturn(courseMock1);
when(daoManagerMock.getSapCampusCourse(200L)).thenReturn(courseMock2);
synchronizationReaderTestObject.init();
// The first read delivers the first course
assertNotNull(synchronizationReaderTestObject.read());
// The second read delivers the second course
assertNotNull(synchronizationReaderTestObject.read());
// The third read delivers null
assertNull(synchronizationReaderTestObject.read());
}
示例5: read_twoStudentsList
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Test
public void read_twoStudentsList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
List<Student> twoStudentsList = new ArrayList<Student>();
Student studentMock1 = mock(Student.class);
Student studentMock2 = mock(Student.class);
twoStudentsList.add(studentMock1);
twoStudentsList.add(studentMock2);
when(daoManagerMock.getAllStudents()).thenReturn(twoStudentsList);
studentMappingReaderTestObject.init();
// The first read delivers the first student
assertNotNull(studentMappingReaderTestObject.read());
// The second read delivers the second student
assertNotNull(studentMappingReaderTestObject.read());
// The third read delivers null
assertNull(studentMappingReaderTestObject.read());
}
示例6: read_twoLecturersList
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Test
public void read_twoLecturersList() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
List<Lecturer> twoLecturersList = new ArrayList<Lecturer>();
Lecturer lecturerMock1 = mock(Lecturer.class);
Lecturer lecturerMock2 = mock(Lecturer.class);
twoLecturersList.add(lecturerMock1);
twoLecturersList.add(lecturerMock2);
when(daoManagerMock.getAllLecturers()).thenReturn(twoLecturersList);
lecturerMappingReaderTestObject.init();
// The first read delivers the first lecturer
assertNotNull(lecturerMappingReaderTestObject.read());
// The second read delivers the second lecturer
assertNotNull(lecturerMappingReaderTestObject.read());
// The third read delivers null
assertNull(lecturerMappingReaderTestObject.read());
}
示例7: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public QueryResult read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
QueryResult aResult = null;
if (unreadObjects.hasNext()) {
aResult = unreadObjects.next();
if (aResult != null) {
lastTimestamp = CONVERTER_TIMESTAMP.convert((Calendar) aResult.getPropertyByQueryName("cmis:creationDate").getFirstValue()).get(0);
} else {
executeQuery();
aResult = read();
}
} else if (currentQueryResult.getHasMoreItems()) {
executeQuery();
aResult = read();
}
return aResult;
}
示例8: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public JudgmentIndexingData read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
JudgmentIndexingItem judgmentIndexingItem = judgmentIndexingItems.poll();
if (judgmentIndexingItem == null) {
return null;
}
Judgment judgment = judgmentEnrichmentService.findOneAndEnrich(judgmentIndexingItem.getJudgmentId());
if (judgment == null) {
return null;
}
JudgmentIndexingData judgmentIndexingData = new JudgmentIndexingData();
judgmentIndexingData.setJudgment(judgment);
judgmentIndexingData.setReferencingCount(judgmentIndexingItem.getReferencingCount());
return judgmentIndexingData;
}
示例9: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public Item read() throws Exception, UnexpectedInputException, ParseException,
NonTransientResourceException {
if (readerTransactional){
businessMetrics.increment(MetricNames.READ_COUNT.getName());
businessMetrics.submit(MetricNames.READ_GAUGE.getName(), 5);
} else {
businessMetrics.incrementNonTransactional(MetricNames.READ_COUNT.getName());
businessMetrics.submitNonTransactional(MetricNames.READ_GAUGE.getName(), 5);
}
Item item = delegate.read();
if (item != null && item.getActions().contains(Action.FAIL_ON_READ)){
throw new MetricsTestException(Action.FAIL_ON_READ);
}
log.debug("Read item: "+item);
return item;
}
示例10: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public Page<Artifact, Artifact> read()
throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception {
MDC.remove(PATIENT);
Page<Artifact, Artifact> page = super.read();
while (page != null) {
Artifact patient = page.getKey().get();
if (patient.getFile() == null) {
LOGGER.info("Skip {} as it is not fetched", patient);
page = super.read();
continue;
}
if (!patient.getExtension().equals("jar")) {
LOGGER.info("Skip {} as it is not packaged as jar", patient);
page = super.read();
continue;
}
if (patient.isSnapshot()) {
LOGGER.info("Skip {} as it is snapshot", patient);
page = super.read();
continue;
}
LOGGER.info("Processing {}...", patient);
MDC.put(PATIENT, patient.toString());
return page;
}
return null;
}
示例11: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public I read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
if (this.limit <= 0) {
return null;
}
this.limit = this.limit - 1;
return super.read();
}
示例12: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public I read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
@SuppressWarnings("unchecked")
I request = (I) this.jmsTemplate.receiveAndConvert(this.destination);
if (request == null) {
return null;
}
return request;
}
示例13: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public String read() throws Exception, UnexpectedInputException,
ParseException, NonTransientResourceException {
if (count < number) {
return ids[count++];
}
return null;
}
示例14: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@Override
public String read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
String str = !strs.isEmpty() ? strs.remove(0) : null;
log.info("+++ reader {}", str);
return str;
}
示例15: read
import org.springframework.batch.item.NonTransientResourceException; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public T read() throws Exception, UnexpectedInputException, ParseException,
NonTransientResourceException {
T item;
//TODO Separate two steps and refactor
if(currentDelegate == null || (item = currentDelegate.read()) == null) {
logger.debug("Loading new item reader");
try {
if(currentDelegate != null && ItemStream.class.isAssignableFrom(currentDelegate.getClass())) {
((ItemStream) currentDelegate).close();
}
currentDelegate = delegates.remove(0);
logger.info("The current ItemReader is now " + currentDelegate);
if(currentDelegate != null && ItemStream.class.isAssignableFrom(currentDelegate.getClass())) {
((ItemStream) currentDelegate).open(new ExecutionContext());
}
} catch (IndexOutOfBoundsException e) {
//if there are no more delegates
logger.info("No more readers, returning null");
return null;
}
item = read();
}
//If targetType is null use the first delegate to define the expected type
if (targetType == null) {
targetType = (Class) item.getClass();
} else {
if(!targetType.isInstance(item)) {
logger.debug("Attempting to cast " + item + " to " + targetType);
item = (T) conversionService.convert(item, targetType);
}
}
logger.debug("Returning " + item);
return item;
}