本文整理汇总了Java中org.springframework.batch.core.StepContribution.incrementWriteCount方法的典型用法代码示例。如果您正苦于以下问题:Java StepContribution.incrementWriteCount方法的具体用法?Java StepContribution.incrementWriteCount怎么用?Java StepContribution.incrementWriteCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.batch.core.StepContribution
的用法示例。
在下文中一共展示了StepContribution.incrementWriteCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: zipResource
import org.springframework.batch.core.StepContribution; //导入方法依赖的package包/类
protected void zipResource(Resource sSourceResource, ZipArchiveOutputStream sZipArchiveOutputStream, StepContribution sContribution, ChunkContext sChunkContext) throws IOException, ZipFilesException {
// TODO : use a queue to reduce the callstack overhead
if (sSourceResource.exists()) {
File aSourceFile = sSourceResource.getFile();
String aSourcePath = aSourceFile.getCanonicalPath();
if (!aSourcePath.startsWith(sourceBaseDirectoryPath)) {
throw new ZipFilesException("Source file " + aSourcePath + " does not match base directory " + sourceBaseDirectoryPath);
}
if (sContribution != null) {
sContribution.incrementReadCount();
}
String aZipEntryName = aSourcePath.substring(sourceBaseDirectoryPath.length() + 1);
sZipArchiveOutputStream.putArchiveEntry(new ZipArchiveEntry(aZipEntryName));
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Zipping {} to {}", sSourceResource.getFile().getCanonicalPath(), aZipEntryName);
}
if (aSourceFile.isFile()) {
InputStream aInputStream = sSourceResource.getInputStream();
IOUtils.copy(aInputStream, sZipArchiveOutputStream);
aInputStream.close();
sZipArchiveOutputStream.closeArchiveEntry();
} else {
sZipArchiveOutputStream.closeArchiveEntry();
for(File aFile : aSourceFile.listFiles((FileFilter)(recursive ? TrueFileFilter.TRUE : FileFileFilter.FILE))) {
zipResource(new FileSystemResource(aFile), sZipArchiveOutputStream, sContribution, sChunkContext);
}
}
if (sContribution != null) {
sContribution.incrementWriteCount(1);
}
} else if (LOGGER.isInfoEnabled()) {
LOGGER.info("{} does not exist", sSourceResource.getFilename());
}
}
示例2: execute
import org.springframework.batch.core.StepContribution; //导入方法依赖的package包/类
@Override
public RepeatStatus execute(StepContribution sContribution, ChunkContext sChunkContext) throws Exception {
Map<String, Object> aSourceParams = new HashMap<String, Object>();
aSourceParams.put(ResourceFactoryConstants.PARAM_STEP_EXEC, ((sChunkContext != null) && (sChunkContext.getStepContext() != null)) ? sChunkContext
.getStepContext().getStepExecution() : null);
Resource[] aSourceResources = sourceFactory.getResources(aSourceParams);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("{} file(s) to split", aSourceResources.length);
}
for (Resource aSourceResource : aSourceResources) {
if (sContribution != null) {
sContribution.incrementReadCount();
}
File aOriginFile = aSourceResource.getFile();
if (aOriginFile.exists()) {
int aOutputCount = splitFile(aSourceResource, sChunkContext);
if (sContribution != null) {
sContribution.incrementWriteCount(aOutputCount);
}
} else {
throw new SplitPDFException("File not found: " + aOriginFile);
}
}
return RepeatStatus.FINISHED;
}
示例3: execute
import org.springframework.batch.core.StepContribution; //导入方法依赖的package包/类
public RepeatStatus execute(StepContribution sContribution, ChunkContext sChunkContext) throws ResourceCreationException, IOException, FileCopyException {
File aOriginFile = origin.getFile();
if (aOriginFile.exists() && aOriginFile.isFile()) {
if (!ignoreEmptyFile || (aOriginFile.length() > 0)) {
if (sContribution != null) {
sContribution.incrementReadCount();
}
if (destinationFactory != null) {
Map<String, Object> aDestinationParams = new HashMap<String, Object>();
aDestinationParams.put(ResourceFactoryConstants.PARAM_SOURCE, origin);
aDestinationParams.put(ResourceFactoryConstants.PARAM_STEP_EXEC,
((sChunkContext != null) && (sChunkContext.getStepContext() != null)) ? sChunkContext.getStepContext().getStepExecution() : null);
destination = destinationFactory.getResource(aDestinationParams);
}
File aDestinationFile = destination.getFile();
if (aDestinationFile.exists()) {
if (forceReplace && aDestinationFile.isFile()) {
if (!aDestinationFile.delete()) {
throw new FileCopyException("Cannot remove: " + destination);
}
} else {
throw new FileCopyException("Cannot replace: " + destination);
}
}
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Copying : {} => {}", aOriginFile.getAbsolutePath(), aDestinationFile.getAbsolutePath());
}
FileUtils.copyFile(aOriginFile, aDestinationFile);
if ((emptyOrigin || deleteOrigin) && !aOriginFile.delete()) {
throw new FileCopyException("Cannot delete: " + origin);
}
if (emptyOrigin && !aOriginFile.createNewFile()) {
throw new FileCopyException("Cannot create: " + origin);
}
if (sContribution != null) {
sContribution.incrementWriteCount(1);
}
} else if (LOGGER.isInfoEnabled()) {
LOGGER.info("Ignoring empty file : {}", aOriginFile.getAbsolutePath());
}
} else {
throw new FileCopyException("File not found: " + origin);
}
return RepeatStatus.FINISHED;
}
示例4: execute
import org.springframework.batch.core.StepContribution; //导入方法依赖的package包/类
@Override
public RepeatStatus execute(StepContribution sContribution, ChunkContext sChunkContext) throws Exception {
FTPClient aClient = ftpClientFactory.getFtpClient();
RegexFilenameFilter aFilter = new RegexFilenameFilter();
aFilter.setRegex(regexFilename);
try {
File aLocalDir = new File(localBaseDir);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Listing : {} ({}) for upload to [{}]", localBaseDir, regexFilename, aClient.getRemoteAddress().toString());
}
File[] aLocalFiles = aLocalDir.listFiles(aFilter);
if (LOGGER.isInfoEnabled()) {
LOGGER.info(" {} file(s) found", aLocalFiles.length);
}
for (File aLocalFile : aLocalFiles) {
if (sContribution != null) {
sContribution.incrementReadCount();
}
URI aRemoteFile = new URI(remoteBaseDir).resolve(aLocalFile.getName());
InputStream aInputStream;
aInputStream = new FileInputStream(aLocalFile);
try {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(" Uploading : {} => {}", aLocalFile.getAbsolutePath(), aRemoteFile.toASCIIString());
}
aClient.storeFile(aRemoteFile.toASCIIString(), aInputStream);
if (sContribution != null) {
sContribution.incrementWriteCount(1);
}
} finally {
aInputStream.close();
}
}
} finally {
aClient.logout();
aClient.disconnect();
}
return RepeatStatus.FINISHED;
}
示例5: execute
import org.springframework.batch.core.StepContribution; //导入方法依赖的package包/类
@Override
public RepeatStatus execute(StepContribution sContribution, ChunkContext sChunkContext) throws Exception {
FTPClient aClient = ftpClientFactory.getFtpClient();
RegexFilenameFilter aFilter = new RegexFilenameFilter();
aFilter.setRegex(regexFilename);
try {
URI aRemoteBaseURI = new URI(remoteBaseDir);
URI aRemoteBasePath = new URI(aRemoteBaseURI.toASCIIString() + SEPARATOR);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Listing : [{}] {} ({})", aClient.getRemoteAddress().toString(), aRemoteBaseURI.toASCIIString(), regexFilename);
}
FTPFile[] aRemoteFiles = aClient.listFiles(aRemoteBaseURI.toASCIIString(), aFilter);
if (LOGGER.isInfoEnabled()) {
LOGGER.info(" {} file(s) found", aRemoteFiles.length);
}
for (FTPFile aRemoteFile : aRemoteFiles) {
if (sContribution != null) {
sContribution.incrementReadCount();
}
File aLocalFile = new File(localBaseDir, aRemoteFile.getName());
URI aRemoteTFile = aRemoteBasePath.resolve(aRemoteFile.getName());
FileOutputStream aOutputStream = new FileOutputStream(aLocalFile);
try {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(" Downloading : {} => {}", aRemoteTFile.toASCIIString(), aLocalFile.getAbsolutePath());
}
aClient.retrieveFile(aRemoteTFile.toASCIIString(), aOutputStream);
if (removeRemote) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(" Deleting : {}", aRemoteTFile.toASCIIString());
}
aClient.deleteFile(aRemoteTFile.toASCIIString());
}
if (sContribution != null) {
sContribution.incrementWriteCount(1);
}
} finally {
aOutputStream.close();
}
}
} finally {
aClient.logout();
aClient.disconnect();
}
return RepeatStatus.FINISHED;
}
示例6: doOperation
import org.springframework.batch.core.StepContribution; //导入方法依赖的package包/类
protected List<String> doOperation(Resource aSourceResource, Map<String, Object> aDestinationParams, StepContribution sContribution, StepExecution sStepExecution)
throws IOException, ResourceCreationException, FileOperationException {
List<String> aDestinationFilesList = new ArrayList<String>();
File aOriginFile = aSourceResource.getFile();
if (aOriginFile.exists()) {
if (sContribution != null) {
sContribution.incrementReadCount();
}
if (operation == Operation.REMOVE) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Deleting : {}", aOriginFile.getAbsolutePath());
}
removeFile(aSourceResource);
} else {
Resource aDestination = getDefaultDestination();
if (destinationFactory != null) {
aDestinationParams.put(ResourceFactoryConstants.PARAM_SOURCE, aSourceResource);
aDestinationParams.put(ResourceFactoryConstants.PARAM_STEP_EXEC, sStepExecution);
aDestination = destinationFactory.getResource(aDestinationParams);
}
if ((aDestination != null) && (aDestination.getFile() != null)) {
File aDestinationFile = aDestination.getFile();
if (operation == Operation.COPY) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Copying : {} => {}", aOriginFile.getAbsolutePath(), aDestinationFile.getAbsolutePath());
}
copyFile(aSourceResource, aDestination);
} else if (operation == Operation.MOVE) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Moving : {} => {}", aOriginFile.getAbsolutePath(), aDestinationFile.getAbsolutePath());
}
moveFile(aSourceResource, aDestination);
} else {
throw new FileOperationException("Unknown operation");
}
} else {
throw new FileOperationException("No destination specified");
}
aDestinationFilesList.add(aDestination.getFile().getCanonicalPath());
}
if (sContribution != null) {
sContribution.incrementWriteCount(1);
}
} else {
throw new FileOperationException("File not found: " + aOriginFile);
}
return aDestinationFilesList;
}