本文整理汇总了Java中javax.batch.operations.JobOperator.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java JobOperator.getParameters方法的具体用法?Java JobOperator.getParameters怎么用?Java JobOperator.getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.batch.operations.JobOperator
的用法示例。
在下文中一共展示了JobOperator.getParameters方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public void open(Serializable prevCheckpointInfo) throws Exception {
JobOperator jobOperator = getJobOperator();
Properties jobParameters = jobOperator.getParameters(jobContext.getExecutionId());
String resourceName = (String) jobParameters.get(INPUT_DATA_FILE_NAME);
InputStream inputStream = new FileInputStream(resourceName);
br = new BufferedReader(new InputStreamReader(inputStream));
Stream<String> lines = br.lines();
if (prevCheckpointInfo != null)
recordNumber = (Integer) prevCheckpointInfo;
else
recordNumber = 0;
stringLines = lines.toArray();
logger.info("[SimpleItemReader] Opened Payroll file for reading from record number: " + recordNumber);
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:17,代码来源:PayrollItemReader.java
示例2: startProcess
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void startProcess() throws Exception {
logger.info("starting process test");
CountDownLatch latch = new CountDownLatch(1);
JobOperator jobOperator = getJobOperator();
Properties props = new Properties();
props.setProperty(INPUT_DATA_FILE_NAME, INPUT_PROPERTIES);
long executionId = jobOperator.start(JOB_NAME, props);
latch.await(10, SECONDS);
List<Long> runningExecutions = jobOperator.getRunningExecutions(JOB_NAME);
assertEquals("running executions. The process is end", 0, runningExecutions.size());
Set<String> jobNames = jobOperator.getJobNames();
assertTrue("one or three jobs", jobNames.size() >= 1 && jobNames.size() <= 3);
String strJobNames = "";
for (String jobName : jobNames)
strJobNames += jobName;
assertTrue("one only job called", strJobNames.contains(JOB_NAME));
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
assertEquals("no step executions", 1, stepExecutions.size());
stepExecutions(stepExecutions.get(0));
Properties properties = jobOperator.getParameters(executionId);
assertEquals("one property found", 1, properties.size());
assertEquals("MY_NEW_PROPERTY found", INPUT_PROPERTIES, properties.get(INPUT_DATA_FILE_NAME));
JobInstance jobInstance = jobInstance(jobOperator.getJobInstance(executionId), JOB_NAME);
jobExecutions(jobOperator.getJobExecutions(jobInstance));
assertNotNull("executionId not empty", executionId);
assertTrue("Created file from writer 1", new File(PAYROLL_TEMP_FILE + "1.tmp").exists());
assertTrue("Created file from writer 2", new File(PAYROLL_TEMP_FILE + "2.tmp").exists());
assertTrue("Created file from writer 3", new File(PAYROLL_TEMP_FILE + "3.tmp").exists());
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:31,代码来源:SimpleJobTestCase.java
示例3: startProcess
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void startProcess() throws Exception {
logger.info("starting mail process test");
CountDownLatch latch = new CountDownLatch(1);
long executionId = 0;
JobOperator jobOperator = getJobOperator();
Properties p = new Properties();
p.setProperty("source", INPUT_PROPERTIES);
p.setProperty("destination", "target/output.properties");
p.setProperty("filesystem", "target");
executionId = jobOperator.start(JOB_NAME, p);
latch.await(2, SECONDS);
List<Long> runningExecutions = jobOperator.getRunningExecutions(JOB_NAME);
assertEquals("running executions. The process is end", 0, runningExecutions.size());
Set<String> jobNames = jobOperator.getJobNames();
assertTrue("one or two job", jobNames.size() >= 1 && jobNames.size() <= 3);
String strJobNames = "";
for (String jobName : jobNames)
strJobNames += jobName;
assertTrue("one only job called", strJobNames.contains(JOB_NAME));
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
assertEquals("no step executions", 2, stepExecutions.size());
stepExecutions(stepExecutions.get(0), false);
stepExecutions(stepExecutions.get(1), true);
Properties properties = jobOperator.getParameters(executionId);
assertEquals("one property found", 3, properties.size());
assertEquals("MY_NEW_PROPERTY found", INPUT_PROPERTIES, properties.get("source"));
JobInstance jobInstance = jobInstance(jobOperator.getJobInstance(executionId));
jobExecutions(jobOperator.getJobExecutions(jobInstance));
assertNotNull("executionId not empty", executionId);
assertTrue("the destination file is created", new File(properties.get("destination") + "").exists());
assertTrue("message received",
myFactory.getBody().contains("Job Execution id " + executionId + " warned disk space getting low!"));
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:36,代码来源:MailJobTestCase.java
示例4: init
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@PostConstruct
public void init() {
JobOperator operator = BatchRuntime.getJobOperator();
Properties jobProperties = operator.getParameters(jobContext.getExecutionId());
type = LegType.valueOf(jobProperties.getProperty((BatchConstants.PATH_TYPE)));
isIVRoute = Boolean.valueOf(jobProperties.getProperty((BatchConstants.IVROUTE)));
isCartesian = Boolean.valueOf(jobProperties.getProperty((BatchConstants.CARTESIAN)));
updateLegProcessor = provider.getUpdateLegProcessor();
routerClient = provider.getIVRouterClient();
databaseWorker = initWorker(type);
}
示例5: open
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public void open(Serializable checkpoint) throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Properties jobParameters = jobOperator.getParameters(jobContext
.getExecutionId());
String resourceName = (String) jobParameters.get("csvDatasFileName");
System.out
.println("[DatasATPReader] resourceName : " + resourceName);
InputStream inputStream = this.getClass().getClassLoader()
.getResourceAsStream(resourceName);
reader = new BufferedReader(new InputStreamReader(inputStream));
if (checkpoint != null){
recordNumber = (Integer) checkpoint;
System.out
.println("[DatasATPReader]checkpoint :" +checkpoint);
}
else
recordNumber = 0;
for (int i = 1; i < recordNumber; i++) { // Skip upto recordNumber
reader.readLine();
}
System.out
.println("[DatasATPReader] Opened csv file for reading from record number: "
+ recordNumber);
}
示例6: testNullAndEmptyJobParameters
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testNullAndEmptyJobParameters() throws Exception {
JobOperator jo = BatchRuntime.getJobOperator();
long exec1Id = jo.start("alwaysFails1", null);
Properties exec1Props = jo.getParameters(exec1Id);
assertNull("Expecting null parameters", exec1Props);
Properties emptyProps = new Properties();
long exec2Id = jo.start("alwaysFails1", emptyProps);
Properties exec2Props = jo.getParameters(exec2Id);
assertEquals("Expecting empty parameters", 0, exec2Props.entrySet().size());
}
示例7: open
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public void open(Serializable ckpt) throws Exception {
/* Get the parameters for this partition */
JobOperator jobOperator = BatchRuntime.getJobOperator();
long execID = jobCtx.getExecutionId();
partParams = jobOperator.getParameters(execID);
/* Get the range of items to work on in this partition */
long firstItem0 = ((Long) partParams.get("firstItem")).longValue();
long numItems0 = ((Long) partParams.get("numItems")).longValue();
if (ckpt == null) {
/* Create a checkpoint object for this partition */
checkpoint = new ItemNumberCheckpoint();
checkpoint.setItemNumber(firstItem0);
checkpoint.setNumItems(numItems0);
} else
checkpoint = (ItemNumberCheckpoint) ckpt;
/* Adjust range for this partition from the checkpoint */
long firstItem = checkpoint.getItemNumber();
long numItems = numItems0 - (firstItem - firstItem0);
/* Obtain an iterator for the bills in this partition */
String query = "SELECT b FROM PhoneBill b ORDER BY b.phoneNumber";
Query q = em.createQuery(query)
.setFirstResult((int)firstItem).setMaxResults((int)numItems);
iterator = q.getResultList().iterator();
}
示例8: getParameters
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
private Properties getParameters() {
JobOperator operator = getJobOperator();
return operator.getParameters(jobContext.getExecutionId());
}
示例9: processBatch
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public BatchStatus processBatch() throws Exception {
logBatchStart();
long jobId = jobContext.getExecutionId();
JobOperator operator = BatchRuntime.getJobOperator();
Properties props = operator.getParameters(jobId);
Double maxWalk = Double.parseDouble(props.getProperty(Constants.BatchConstants.MAX_WALK));
int startPos = Integer.valueOf(start);
int endPos = Integer.valueOf(end);
List<RasterPoint> points = batchManager.getRasterSublist(jobId, startPos, endPos);
// find all sharing stations within walking distance of raster point!
for (RasterPoint point : points) {
if (hasStations(point)) {
continue;
}
CarAndBikeStations cb = stationRepository.findAllStationsInRadius(point.getX(), point.getY(), maxWalk);
List<BikeStationTuple> nearestBs = cb.getBikeStations()
.stream()
.map(station -> new BikeStationTuple(null, station))
.collect(Collectors.toList());
List<CarStationTuple> nearestCs = cb.getCarStations()
.stream()
.map(station -> new CarStationTuple(null, station))
.collect(Collectors.toList());
// update raster point in db
point.setNearestBikeStations(nearestBs);
point.setNearestCarStations(nearestCs);
rasterManager.updateRasterPointStations(point);
if (shouldStop) {
logBatchStop();
return BatchStatus.STOPPING;
}
}
logBatchFinish();
return BatchStatus.COMPLETED;
}