本文整理汇总了Java中org.springframework.batch.item.ItemStreamException类的典型用法代码示例。如果您正苦于以下问题:Java ItemStreamException类的具体用法?Java ItemStreamException怎么用?Java ItemStreamException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemStreamException类属于org.springframework.batch.item包,在下文中一共展示了ItemStreamException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Override
public void open(ExecutionContext executionContext) throws
ItemStreamException {
if (executionContext == null) {
throw new IllegalArgumentException();
}
if (executionContext.containsKey(IDS_NUMBER)) {
number = executionContext.getInt(IDS_NUMBER);
count = executionContext.getInt(CURRENT_ID_COUNT);
ids = new String[number];
for (int i = 0; i < number; i++) {
ids[i] = executionContext.getString(LIST_ID + i);
}
} else {
ids = loadListIds();
number = ids.length;
count = 0;
}
}
开发者ID:hosuaby,项目名称:signature-processing,代码行数:22,代码来源:ListIdsItemReader.java
示例2: update
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Override
public void update(ExecutionContext executionContext) throws
ItemStreamException {
/* Clear context */
for (Entry<String, Object> entry : executionContext.entrySet()) {
String key = entry.getKey();
executionContext.remove(key);
}
executionContext.putInt(IDS_NUMBER, number);
executionContext.putInt(CURRENT_ID_COUNT, count);
for (int i = 0; i < number; i++) {
executionContext.putString(LIST_ID + i, ids[i]);
}
}
开发者ID:hosuaby,项目名称:signature-processing,代码行数:18,代码来源:ListIdsItemReader.java
示例3: update
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Override
public void update(ExecutionContext executionContext) {
if (state == null) {
throw new ItemStreamException(
"ItemStream not open or already closed.");
}
Assert.notNull(executionContext, "ExecutionContext must not be null");
if (saveState) {
try {
executionContext.putLong(
getExecutionContextKey(RESTART_DATA_NAME),
state.position());
} catch (IOException e) {
throw new ItemStreamException(
"ItemStream does not return current position properly",
e);
}
executionContext.putLong(
getExecutionContextKey(WRITTEN_STATISTICS_NAME),
state.jsonObjectsWritten);
}
}
开发者ID:SoatGroup,项目名称:json-file-itemwriter,代码行数:23,代码来源:JsonFlatFileItemWriter.java
示例4: getOutputState
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
private OutputState getOutputState() {
if (state == null) {
File file;
try {
file = resource.getFile();
} catch (IOException e) {
throw new ItemStreamException(
"Could not convert resource to file: [" + resource
+ "]", e);
}
Assert.state(!file.exists() || file.canWrite(),
"Resource is not writable: [" + resource + "]");
state = new OutputState();
state.setDeleteIfExists(shouldDeleteIfExists);
state.setAppendAllowed(append);
state.setEncoding(encoding);
}
return state;
}
开发者ID:SoatGroup,项目名称:json-file-itemwriter,代码行数:20,代码来源:JsonFlatFileItemWriter.java
示例5: close
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* Close the open resource and reset counters.
*/
public void close() {
initialized = false;
restarted = false;
try {
if (outputBufferedWriter != null) {
outputBufferedWriter.close();
}
} catch (IOException ioe) {
throw new ItemStreamException(
"Unable to close the the ItemWriter", ioe);
} finally {
if (!transactional) {
closeStream();
}
}
}
开发者ID:SoatGroup,项目名称:json-file-itemwriter,代码行数:21,代码来源:JsonFlatFileItemWriter.java
示例6: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
ResponseEntity<String> response= restTemplate.getForEntity(uri,String.class);
if (!response.getStatusCode().equals(HttpStatus.OK)) {
throw new ItemStreamException(response.getStatusCode() + " HTTP response is returned");
};
MediaType type = response.getHeaders().getContentType();
if (MediaType.APPLICATION_JSON.equals(type)) {
jsonString = response.getBody();
Boolean isJson = isStringValidJSON(jsonString);
if (isJson){
// create an ObjectMapper instance.
ObjectMapper mapper = new ObjectMapper();
// use the ObjectMapper to read the json string and create a tree
try {
nodeElements = mapper.readTree(jsonString);
iterator = nodeElements.fieldNames();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:26,代码来源:HttpJsonItemReader.java
示例7: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
ResponseEntity<String> response = restTemplate.getForEntity(uri, String.class);
if (!response.getStatusCode().equals(HttpStatus.OK)) {
throw new ItemStreamException(response.getStatusCode() + " HTTP response is returned");
}
;
MediaType type = response.getHeaders().getContentType();
if (MediaType.APPLICATION_XML.equals(type) ||
MediaType.APPLICATION_ATOM_XML.equals(type) ||
MediaType.APPLICATION_XHTML_XML.equals(type) ||
MediaType.APPLICATION_RSS_XML.equals(type) ||
"text/xml".equals(type.toString())) {
SAXBuilder jdomBuilder = new SAXBuilder();
try {
Document document = jdomBuilder.build(new StringReader(response.getBody()));
ElementFilter ef = new ElementFilter(aggregateRecordElement);
aggregateRecordElementItr = document.getRootElement().getDescendants(ef);
} catch (Exception ex) {
throw new ItemStreamException(ex);
}
}
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:24,代码来源:HttpXmlItemReader.java
示例8: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
if (isDataMovementSdk) {
dataMovementManager = client.newDataMovementManager();
batcher = dataMovementManager.newWriteBatcher();
batcher
.withBatchSize(getBatchSize())
.withThreadCount(getThreadCount());
if (serverTransform != null) {
batcher.withTransform(serverTransform);
}
if (this.writeBatchlistener != null) {
batcher.onBatchSuccess(this.writeBatchlistener);
}
if (this.writeFailureListener != null) {
batcher.onBatchFailure(writeFailureListener);
}
} else {
batchWriter = new RestBatchWriter(client);
if (serverTransform != null) {
batchWriter.setServerTransform(serverTransform);
batchWriter.setContentFormat(contentFormat == null ? Format.XML : contentFormat);
}
batchWriter.initialize();
}
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:27,代码来源:MarkLogicItemWriter.java
示例9: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Override
public void open(ExecutionContext sExecutionContext) throws ItemStreamException {
String aFullPath = null;
try {
baseURI = new URI(getAlfrescoService().getWebappAddress()).resolve(WEBDAV_PATH);
aFullPath = getWebDavDirectoryURI(baseURI.getPath() + path).getPath();
} catch (URISyntaxException e) {
throw new ItemStreamException(e);
}
currentDirPath = sExecutionContext.getString(CONTEXT_KEY_CURRENTPATH, aFullPath);
Object aCurrentIndexes = sExecutionContext.get(CONTEXT_KEY_CURRENTINDEXES);
if (aCurrentIndexes == null) {
currentIndexes = new ArrayDeque<Integer>();
currentIndexes.addFirst(0);
} else {
Integer[] aArray = (Integer[]) aCurrentIndexes;
currentIndexes = new ArrayDeque<Integer>(Arrays.asList(aArray));
}
sardine = getAlfrescoService().startWebDavSession();
}
开发者ID:acxio,项目名称:AGIA,代码行数:25,代码来源:AlfrescoNodeReader.java
示例10: testReadNotExistsStrict
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Test
public void testReadNotExistsStrict() throws Exception {
exception.expect(ItemStreamException.class);
IdentityResourceAwareItemReaderItemStream aReader = new IdentityResourceAwareItemReaderItemStream();
aReader.setName("testReader");
aReader.setStrict(true);
Resource aResource = mock(Resource.class);
when(aResource.getFilename()).thenReturn("file1");
when(aResource.getDescription()).thenReturn("file1");
when(aResource.exists()).thenReturn(false);
aReader.setResource(aResource);
aReader.open(new ExecutionContext());
assertNull(aReader.read());
aReader.close();
}
开发者ID:acxio,项目名称:AGIA,代码行数:19,代码来源:IdentityResourceAwareItemReaderItemStreamTest.java
示例11: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* Figure out which resource to start with in case of restart, open the delegate and restore
* delegate's position in the resource.
*/
@SuppressWarnings("unchecked")
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
super.open(executionContext);
this.currentCount = 0;
this.entityIterator = ENTITIES.iterator();
if (executionContext.containsKey(getExecutionContextKey(ENTITY_KEY))) {
String entityClassName = executionContext.getString(getExecutionContextKey(ENTITY_KEY));
while (this.entityIterator.hasNext()) {
Class<?> entityClass = this.entityIterator.next();
if (entityClassName.equals(entityClass.getName())) {
this.currentEntityClass = (Class<Object>) entityClass;
break;
}
}
}
if (this.currentEntityClass == null) {
this.entityIterator = ENTITIES.iterator();
this.currentEntityClass = (Class<Object>) this.entityIterator.next();
}
this.reader = createNextEntityReader();
}
开发者ID:trein,项目名称:gtfs-java,代码行数:30,代码来源:GtfsItemReader.java
示例12: update
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* state의 상태를 갱신하고 다음에 쓰여질 position을 지정
* @see ItemStream#update(ExecutionContext)
*/
public void update(ExecutionContext executionContext) {
if (state == null) {
throw new ItemStreamException(
"ItemStream not open or already closed.");
}
Assert.notNull(executionContext, "ExecutionContext must not be null");
if (saveState) {
try {
executionContext.putLong(getKey(RESTART_DATA_NAME),
state.position());
} catch (IOException e) {
throw new ItemStreamException(
"ItemStream does not return current position properly",
e);
}
executionContext.putLong(getKey(WRITTEN_STATISTICS_NAME),
state.linesWritten);
}
}
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:29,代码来源:EgovPartitionFlatFileItemWriter.java
示例13: getOutputState
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* 파일을 쓰기 위한 OutputState 의 상태를 설정하여 를 넘겨줌
* @return
*/
private OutputState getOutputState() {
if (state == null) {
File file;
try {
file = resource.getFile();
} catch (IOException e) {
throw new ItemStreamException(
"Could not convert resource to file: [" + resource
+ "]", e);
}
Assert.state(!file.exists() || file.canWrite(),
"Resource is not writable: [" + resource + "]");
state = new OutputState();
state.setDeleteIfExists(shouldDeleteIfExists);
state.setAppendAllowed(append);
state.setEncoding(encoding);
}
return (OutputState) state;
}
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:24,代码来源:EgovPartitionFlatFileItemWriter.java
示例14: close
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* outputBufferedWriter를 닫는다
*
*/
public void close() {
initialized = false;
restarted = false;
try {
if (outputBufferedWriter != null) {
outputBufferedWriter.close();
}
} catch (IOException ioe) {
throw new ItemStreamException(
"Unable to close the the ItemWriter", ioe);
} finally {
if (!transactional) {
closeStream();
}
}
}
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:23,代码来源:EgovPartitionFlatFileItemWriter.java
示例15: getBufferedWriter
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* BufferedWriter를 가져 온다.
*/
private Writer getBufferedWriter(FileChannel fileChannel,
String encoding) {
try {
Writer writer = Channels.newWriter(fileChannel, encoding);
if (transactional) {
return new TransactionAwareBufferedWriter(writer,
new Runnable() {
public void run() {
closeStream();
}
});
} else {
return new BufferedWriter(writer);
}
} catch (UnsupportedCharsetException ucse) {
throw new ItemStreamException(
"Bad encoding configuration for output file "
+ fileChannel, ucse);
}
}
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:24,代码来源:EgovPartitionFlatFileItemWriter.java
示例16: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* Initialize the reader. This method may be called multiple times before
* close is called.
*
* @see ItemStream#open(ExecutionContext)
*/
@Override
public void open(ExecutionContext executionContext)
throws ItemStreamException {
Assert.notNull(resource, "The resource must be set");
if (!getOutputState().isInitialized()) {
this.doOpen(executionContext);
}
}
开发者ID:SoatGroup,项目名称:json-file-itemwriter,代码行数:15,代码来源:JsonFlatFileItemWriter.java
示例17: doOpen
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* Apply the @DEFAULT_ITEM_SEPARATOR delimiter after the writing of the header.
* This changes from the default implementation where the @itemSeparator would have been applied per default.
*
* @param executionContext
* @throws ItemStreamException
*/
private void doOpen(ExecutionContext executionContext)
throws ItemStreamException {
OutputState outputState = getOutputState();
if (executionContext
.containsKey(getExecutionContextKey(RESTART_DATA_NAME))) {
outputState.restoreFrom(executionContext);
}
try {
outputState.initializeBufferedWriter();
} catch (IOException ioe) {
throw new ItemStreamException("Failed to initialize writer", ioe);
}
if (outputState.lastMarkedByteOffsetPosition == 0
&& !outputState.appending) {
if (headerFooterCallback != null) {
try {
headerFooterCallback
.writeHeader(outputState.outputBufferedWriter);
outputState.write(DEFAULT_ITEM_SEPARATOR);
} catch (IOException e) {
throw new ItemStreamException(
"Could not write headers. The file may be corrupt.",
e);
}
}
}
}
开发者ID:SoatGroup,项目名称:json-file-itemwriter,代码行数:35,代码来源:JsonFlatFileItemWriter.java
示例18: checkFileSize
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* Checks (on setState) to make sure that the current output file's size
* is not smaller than the last saved commit point. If it is, then the
* file has been damaged in some way and whole task must be started over
* again from the beginning.
*
* @throws IOException
* if there is an IO problem
*/
private void checkFileSize() throws IOException {
long size = -1;
outputBufferedWriter.flush();
size = fileChannel.size();
if (size < lastMarkedByteOffsetPosition) {
throw new ItemStreamException(
"Current file size is smaller than size at last commit");
}
}
开发者ID:SoatGroup,项目名称:json-file-itemwriter,代码行数:21,代码来源:JsonFlatFileItemWriter.java
示例19: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
/**
* Open the output source.
* @param newExecutionContext Set the execution context
* @see org.springframework.batch.item.ItemStream#open(ExecutionContext)
*/
public final void open(final ExecutionContext newExecutionContext) {
Assert.notNull(resource, "The resource must be set");
long startAtPosition = 0;
boolean restarted = false;
// if restart data is provided, restart from provided offset
// otherwise start from beginning
if (newExecutionContext.containsKey(getKey(RESTART_DATA_NAME))) {
startAtPosition = newExecutionContext
.getLong(getKey(RESTART_DATA_NAME));
restarted = true;
}
open(startAtPosition, restarted);
if (startAtPosition == 0) {
try {
if (headerCallback != null) {
headerCallback.write(delegateEventWriter);
}
} catch (IOException e) {
throw new ItemStreamException("Failed to write headerItems", e);
}
}
}
开发者ID:RBGKew,项目名称:eMonocot,代码行数:34,代码来源:StaxEventItemWriter.java
示例20: open
import org.springframework.batch.item.ItemStreamException; //导入依赖的package包/类
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
File directory = new File(directoryName);
if(directory.isDirectory()) {
this.files = directory.listFiles((FileFilter) FileFilterUtils.fileFileFilter());
if(files.length > 1) {
Arrays.sort(files, new NameFileComparator());
}
} else {
throw new IllegalArgumentException(directoryName + " is not a directory");
}
currentCount = executionContext.getInt(key, 0);
}
开发者ID:RBGKew,项目名称:eMonocot,代码行数:14,代码来源:DirectoryReader.java
注:本文中的org.springframework.batch.item.ItemStreamException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论