当前位置: 首页>>代码示例>>Java>>正文


Java ItemStreamException类代码示例

本文整理汇总了Java中org.springframework.batch.item.ItemStreamException的典型用法代码示例。如果您正苦于以下问题:Java ItemStreamException类的具体用法?Java ItemStreamException怎么用?Java ItemStreamException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ItemStreamException类属于org.springframework.batch.item包,在下文中一共展示了ItemStreamException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.springframework.batch.item.ItemStreamException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。