本文整理汇总了Java中org.springframework.batch.core.annotation.BeforeStep类的典型用法代码示例。如果您正苦于以下问题:Java BeforeStep类的具体用法?Java BeforeStep怎么用?Java BeforeStep使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BeforeStep类属于org.springframework.batch.core.annotation包,在下文中一共展示了BeforeStep类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: step2
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@Bean
@JobScope
public Step step2(StepBuilderFactory stepBuilderFactory) {
ItemReader<String> reader = new ItemReader<String>() {
int i = 0;
@Override
public String read() throws Exception {
i++;
return i == 1 ? "hello" : null;
}
};
ItemWriter<String> writer = new ItemWriter<String>() {
String someString;
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
JobExecution jobExecution = stepExecution.getJobExecution();
ExecutionContext jobContext = jobExecution.getExecutionContext();
this.someString = jobContext.getString("someKey");
}
@Override
public void write(List<? extends String> items) throws Exception {
logger.info("Step 2: " + someString);
for (String item : items) {
logger.info("step2: " + item);
}
}
};
return stepBuilderFactory.get("step2")
.<String, String>chunk(10)
.reader(reader)
.writer(writer)
.listener(writer)
.build();
}
示例2: connect
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
/**
*
* @param stepExecution the step execution
*/
@BeforeStep
public void connect(StepExecution stepExecution)
{
this.skipCommand.connect();
if(this.beforeCommand != null)
this.beforeCommand.connect();
}
示例3: open
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@BeforeStep
public void open()
throws IOException
{
this.excel = Excel.getExcel(this.filePath);
if(this.sheetName != null && this.sheetName.length() > 0)
this.sheet = this.excel.retrieveSheet(this.sheetName);
else
this.sheet = this.excel.retrieveSheet(this.sheetNumber);
this.rowCount = this.sheet.getRowCount();
index = 1;
}
示例4: beforeStep
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@Override
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
totalItemCount = employeeService.getEmployeeCount().intValue();
jobStartParams = new JobStartParamsMapper().map(stepExecution.getJobParameters());
stepName = stepExecution.getStepName();
currentItemCount = new AtomicLong();
lastPercentageComplete = new AtomicInteger();
eventBus.post(new JobProgressEvent(jobStartParams, stepName, 0));
}
示例5: createOutputNameFromInput
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
/**
* stepExecutionContext에 inputKeyName 을 이용하여 outputKeyName을 put 함
*
* @param stepExecution
*/
@BeforeStep
public void createOutputNameFromInput(StepExecution stepExecution) {
ExecutionContext executionContext = stepExecution.getExecutionContext();
String inputName = stepExecution.getStepName().replace(":", "-");
if (executionContext.containsKey(inputKeyName)) {
inputName = executionContext.getString(inputKeyName);
}
if (!executionContext.containsKey(outputKeyName)) {
executionContext.putString(outputKeyName,
path + FilenameUtils.getBaseName(inputName) + ".csv");
}
}
示例6: beforeStep
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@BeforeStep
public void beforeStep(final StepExecution stepExecution) {
try {
InMemoryCompiler javac = new InMemoryCompiler();
String javaCode = InMemoryCompiler.getTheSourceCode(getExpression(), getScriptFile());
final Class<?> clazz ;
if( CODE2CLASS.containsKey(javaCode))
{
if(LOG.isWarnEnabled()) LOG.warn("Code already compiled");
clazz = CODE2CLASS.get(javaCode);
}
else
{
final String className = "FunctionImpl"+ rand.nextInt()+ System.currentTimeMillis();
if(LOG.isInfoEnabled()) LOG.info("Compiling\n" + InMemoryCompiler.beautifyCode(javaCode));
clazz = javac.compileClass(className,
javaCode.replace("__CLASS__", className));
CODE2CLASS.put(javaCode, clazz);
}
final Constructor<?> ctor = clazz.getConstructor();
final Object instance = ctor.newInstance();
if(!(instance instanceof Function)) {
throw new JvarkitException.ScriptingError("Not an instance of Function");
}
this.transformer = (Function)instance;
}
catch(final Exception err)
{
throw new RuntimeException(err);
}
}
示例7: beforeAnyRead
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@BeforeStep
@SuppressWarnings({"unused", "unchecked"})
private void beforeAnyRead(StepExecution stepExecution) {
JobExecution jobExecution = stepExecution.getJobExecution();
ExecutionContext executionContext = jobExecution.getExecutionContext();
contextMap = (Map<String, Map<String, String>>) executionContext.get("mapContext");
urls = jenkinsReader.buildURLs();
}
示例8: beforeStep
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
LOG.info("Starting step: {}", stepExecution.getStepName());
}
示例9: beforeStep
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@Override
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
log.info("$$$ before step {}",stepExecution.getStepName());
}
示例10: saveStepExecution
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@BeforeStep
public void saveStepExecution(StepExecution sStepExecution) {
stepExecution = sStepExecution;
}
示例11: beforeStep
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@Override
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
jobStartParams = new JobStartParamsMapper().map(stepExecution.getJobParameters());
stepName = stepExecution.getStepName();
}
示例12: beforeStep
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
jobExecution = stepExecution.getJobExecution();
}
示例13: beforeStep
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
log.info("스텝 실행 전에 호출되는 리스너의 메소드입니다.");
}
示例14: retrieveInterstepData
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
/**
* retrieveInterstepData.
*
* @param stepExecution
* to set
*/
@BeforeStep
public void retrieveInterstepData(StepExecution stepExecution) {
this.stepExecution = stepExecution;
}
示例15: retrieveInterstepData
import org.springframework.batch.core.annotation.BeforeStep; //导入依赖的package包/类
/**
* retrieveInterstepData.
*
* @param stepExecution
* to set
*/
@BeforeStep
public void retrieveInterstepData(StepExecution stepExecution) {
StatusJobs.getMonitor("One job", "element", stepExecution)
.beginTask("insert", "insert element", NB_ITEM.get());
}