Package javax.batch.operations

Examples of javax.batch.operations.JobOperator


    }

    private static JobOperator findJobOperator() {
        final Iterator<JobOperator> iterator = operators();
        while (iterator.hasNext()) {
            final JobOperator provider = iterator.next();
            if (provider != null) {
                return provider;
            }
        }
        return null;
View Full Code Here


        return true;
    }

    private List<JobExecution> findJobExecutions(long exeId) {
        List<JobExecution> jobExecutions = new ArrayList<>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        JobExecution jobExecution = jobOperator.getJobExecution(Long.valueOf(exeId));
        if (jobExecution != null)
            jobExecutions.add(jobExecution);

        return jobExecutions;
    }
View Full Code Here

        return jobExecutions;
    }

    private static List<JobExecution> getJobExecutionForInstance(long instId) {
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        JobInstance jobInstance = null;
        for (String jn : jobOperator.getJobNames()) {
            List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
            if (exe != null) {
                for (JobInstance ji : exe) {
                    if (ji.getInstanceId() == instId) {
                        jobInstance = ji;
                        break;
                    }
                }
            }
        }

        List<JobExecution> jeList = new ArrayList<JobExecution>();
        List<JobExecution> lst = BatchRuntime.getJobOperator().getJobExecutions(jobInstance);
        if (lst != null) {
            for (JobExecution je : lst) {
                jeList.add(jobOperator.getJobExecution(je.getExecutionId()));
            }
        }

        return jeList;
    }
View Full Code Here

        Map<String, Object> jobInfo = new HashMap<>();

        int jobParamIndex = -1;
        StringTokenizer st = new StringTokenizer("", "");
        String[] cfData = new String[getOutputHeaders().length];
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        for (int index = 0; index < getOutputHeaders().length; index++) {
            Object data = null;
            switch (getOutputHeaders()[index]) {
                case JOB_NAME:
                    data = jobOperator.getJobInstance(
                            je.getInstanceId() <= 0 ? Long.valueOf(instanceId) : je.getInstanceId()).getJobName();
                    break;
                case EXECUTION_ID:
                    data = "" + je.getExecutionId();
                    break;
                case BATCH_STATUS:
                    data = je.getBatchStatus();
                    break;
                case EXIT_STATUS:
                    data = je.getExitStatus();
                    break;
                case START_TIME:
                    data = je.getStartTime().getTime();
                    cfData[index] = je.getStartTime().toString();
                    break;
                case END_TIME:
                    data = je.getEndTime().getTime();
                    cfData[index] = je.getEndTime().toString();
                    break;
                case JOB_PARAMETERS:
                    data = je.getJobParameters() == null ? new Properties() : je.getJobParameters();
                    jobParamIndex = index;
                    ColumnFormatter cf = new ColumnFormatter(new String[]{"KEY", "VALUE"});
                    for (Map.Entry e : ((Properties) data).entrySet())
                        cf.addRow(new String[]{e.getKey().toString(), e.getValue().toString()});
                    st = new StringTokenizer(cf.toString(), "\n");
                    break;
                case STEP_COUNT:
                    long exeId = executionId == null ? je.getExecutionId() : Long.valueOf(executionId);
                    data = jobOperator.getStepExecutions(exeId) == null
                        ? 0 : jobOperator.getStepExecutions(exeId).size();
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
            }
            jobInfo.put(getOutputHeaders()[index], data);
View Full Code Here

        return getSupportedHeaders();
    }

    private List<StepExecution> findStepExecutions() {
        List<StepExecution> stepExecutions = new ArrayList<>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        List<StepExecution> jobExecution = jobOperator.getStepExecutions(Long.valueOf(executionId));
        if (jobExecution != null)
            stepExecutions.addAll(jobExecution);

        return stepExecutions;
    }
View Full Code Here

        return jobToInstanceCountMap;
    }

    private List<JobExecution> findJobExecutions() {
        List<JobExecution> jobExecutions = new ArrayList<>();
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        if (jobName != null) {
            List<JobInstance> exe = jobOperator.getJobInstances(jobName, 0, Integer.MAX_VALUE - 1);
            if (exe != null) {
                for (JobInstance ji : exe) {
                    jobExecutions.addAll(jobOperator.getExecutions(ji));
                }
            }
        } else {
            Set<String> jobNames = jobOperator.getJobNames();
            if (jobNames != null) {
                for (String jn : jobOperator.getJobNames()) {
                    List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
                    if (exe != null) {
                        for (JobInstance ji : exe) {
                            jobExecutions.addAll(jobOperator.getExecutions(ji));
                        }
                    }
                }
            }
        }
View Full Code Here

    private Map<String, Object> handleJob(JobExecution je, ColumnFormatter columnFormatter) {
        Map<String, Object> jobInfo = new HashMap<>();

        String[] cfData = new String[getOutputHeaders().length];
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        for (int index = 0; index < getOutputHeaders().length; index++) {
            Object data = null;
            switch (getOutputHeaders()[index]) {
                case JOB_NAME:
                    data = jobOperator.getJobInstance(je.getInstanceId()).getJobName();
                    break;
                case INSTANCE_COUNT:
                    data = jobOperator.getJobInstanceCount(jobOperator.getJobInstance(je.getInstanceId()).getJobName());
                    break;
                case INSTANCE_ID:
                    data = je.getInstanceId();
                    break;
                case EXECUTION_ID:
View Full Code Here

     *                   the CSV file (generated) and the resulting XML file.
     * @return Job execution identifier that can later be used to retrieve
     *         information on the job, restart it etc.
     */
    public long startJob(final String dataFolder) {
        JobOperator jobOperator = BatchRuntime.getJobOperator();

        /*
         Define job properties. These properties can be used in the job XML
        (see below) using EL (Expression Language).
         */
        Properties props = new Properties();
        props.setProperty("dataFolder", dataFolder);

        /*
         This points to the META-INF/batch-jobs/simple.job.xml
         */
        LOG.info("Starting job \'simple.job\'");
        final long executionId = jobOperator.start("simple.job", props);
        LOG.info("Done, execution ID is: " + executionId);
        return executionId;
    }
View Full Code Here

     * @param executionId Execution identifier as returned by
     *                    {@link #startJob(java.lang.String)}.
     * @return Record containing the details.
     */
    public JobExecution getJobExecutionDetails(long executionId) {
        JobOperator jobOperator = BatchRuntime.getJobOperator();
        JobExecution jobExecution = jobOperator.getJobExecution(executionId);
        return jobExecution;
    }
View Full Code Here

     * @param name Name of the job, basically the XML file name but without the .job.xml suffix.
     * @return Job execution identifier that can later be used to retrieve
     *         information on the job, restart it etc.
     */
    public long startJob(final String name) {
        JobOperator jobOperator = BatchRuntime.getJobOperator();

        /*
         Define job properties. These properties can be used in the job XML
         (see below) using EL (Expression Language).
         */
        Properties props = new Properties();

        /*
         This points to the META-INF/batch-jobs/justReadAndWrite.job.xml
         */
        LOG.info("Starting job " + name);
        final long executionId = jobOperator.start(name + ".job", props);
        LOG.info("Execution ID is: " + executionId);
        return executionId;
    }
View Full Code Here

TOP

Related Classes of javax.batch.operations.JobOperator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.