Package org.jberet.runtime

Examples of org.jberet.runtime.JobInstanceImpl


    @Override
    public long start(String jobXMLName, Properties jobParameters) throws JobStartException, JobSecurityException {
        ClassLoader classLoader = BatchUtil.getBatchApplicationClassLoader();
        Job jobDefined = ArchiveXmlLoader.loadJobXml(jobXMLName, Job.class, classLoader);
        repository.addJob(jobDefined);
        JobInstanceImpl jobInstance = repository.createJobInstance(jobDefined, getApplicationName(), classLoader);
        return startJobExecution(jobInstance, jobParameters, null);
    }
View Full Code Here


                previousStatus == BatchStatus.STOPPING) {
            throw LOGGER.jobRestartException(executionId, previousStatus);
        }
        if (previousStatus == BatchStatus.FAILED ||
                previousStatus == BatchStatus.STOPPED) {
            JobInstanceImpl jobInstance = (JobInstanceImpl) getJobInstance(executionId);
            List<JobExecution> executions = jobInstance.getJobExecutions();
            JobExecution mostRecentExecution = executions.get(executions.size() - 1);
            if (executionId != mostRecentExecution.getExecutionId()) {
                throw LOGGER.jobExecutionNotMostRecentException(executionId, jobInstance.getInstanceId());
            }
            try {
                newExecutionId = startJobExecution(jobInstance, restartParameters, originalToRestart);
            } catch (Exception e) {
                throw new JobRestartException(e);
View Full Code Here

    @Override
    public long start(final String jobXMLName, final Properties jobParameters) throws JobStartException, JobSecurityException {
        final ClassLoader classLoader = batchEnvironment.getClassLoader();
        final Job jobDefined = ArchiveXmlLoader.loadJobXml(jobXMLName, Job.class, classLoader);
        repository.addJob(jobDefined);
        final JobInstanceImpl jobInstance = repository.createJobInstance(jobDefined, getApplicationName(), classLoader);
        return startJobExecution(jobInstance, jobParameters, null);
    }
View Full Code Here

                previousStatus == BatchStatus.STOPPING) {
            throw LOGGER.jobRestartException(executionId, previousStatus);
        }
        if (previousStatus == BatchStatus.FAILED ||
                previousStatus == BatchStatus.STOPPED) {
            final JobInstanceImpl jobInstance = (JobInstanceImpl) getJobInstance(executionId);
            final List<JobExecution> executions = jobInstance.getJobExecutions();
            final JobExecution mostRecentExecution = executions.get(executions.size() - 1);
            if (executionId != mostRecentExecution.getExecutionId()) {
                throw LOGGER.jobExecutionNotMostRecentException(executionId, jobInstance.getInstanceId());
            }
            try {
                newExecutionId = startJobExecution(jobInstance, restartParameters, originalToRestart);
            } catch (Exception e) {
                throw new JobRestartException(e);
View Full Code Here

    }

    @Override
    public JobInstanceImpl createJobInstance(final Job job, final String applicationName, final ClassLoader classLoader) {
        final ApplicationAndJobName appJobNames = new ApplicationAndJobName(applicationName, job.getId());
        final JobInstanceImpl jobInstance = new JobInstanceImpl(job, appJobNames);
        insertJobInstance(jobInstance);
        final JobInstance jobInstanceExisting = jobInstances.put(jobInstance.getInstanceId(), jobInstance);
        if (jobInstanceExisting != null) {
            throw BatchLogger.LOGGER.jobInstanceAlreadyExists(jobInstance.getInstanceId());
        }
        return jobInstance;
    }
View Full Code Here

    }

    @Override
    public JobInstanceImpl createJobInstance(Job job, String applicationName, ClassLoader classLoader) {
        ApplicationAndJobName appJobNames = new ApplicationAndJobName(applicationName, job.getId());
        JobInstanceImpl jobInstance = new JobInstanceImpl(job, appJobNames);
        insertJobInstance(jobInstance);
        jobInstance.setApplicationMetaData(getApplicationMetaData(appJobNames, classLoader));
        jobInstances.add(jobInstance);
        return jobInstance;
    }
View Full Code Here

    @Override
    public JobExecution getJobExecution(long jobExecutionId) {
        synchronized (jobInstances) {
            for (JobInstance e : jobInstances) {
                JobInstanceImpl in = (JobInstanceImpl) e;
                for (JobExecution j : in.getJobExecutions()) {
                    if (j.getExecutionId() == jobExecutionId) {
                        return j;
                    }
                }
            }
View Full Code Here

    @Override
    public List<JobExecution> getJobExecutions() {
        List<JobExecution> result = new ArrayList<JobExecution>();
        synchronized (jobInstances) {
            for (JobInstance e : jobInstances) {
                JobInstanceImpl in = (JobInstanceImpl) e;
                result.addAll(in.getJobExecutions());
            }
        }
        return result;
    }
View Full Code Here

                preparedStatement.setString(1, jobName);
            }
            final ResultSet rs = preparedStatement.executeQuery();
            while (rs.next()) {
                final long i = rs.getLong(TableColumn.JOBINSTANCEID);
                JobInstanceImpl jobInstance1 = (JobInstanceImpl) jobInstances.get(i);
                if (jobInstance1 == null) {
                    final String appName = rs.getString(TableColumn.APPLICATIONNAME);
                    if (jobName == null) {
                        final String goodJobName = rs.getString(TableColumn.JOBNAME);
                        jobInstance1 = new JobInstanceImpl(getJob(goodJobName), new ApplicationAndJobName(appName, goodJobName));
                    } else {
                        jobInstance1 = new JobInstanceImpl(getJob(jobName), new ApplicationAndJobName(appName, jobName));
                    }
                    jobInstance1.setId(i);
                    jobInstances.put(i, jobInstance1);
                }
                //this job instance is already in the cache, so get it from the cache
                result.add(jobInstance1);
            }
View Full Code Here

            while (rs.next()) {
                result = jobInstances.get(jobInstanceId);
                if (result == null) {
                    final String appName = rs.getString(TableColumn.APPLICATIONNAME);
                    final String goodJobName = rs.getString(TableColumn.JOBNAME);
                    result = new JobInstanceImpl(getJob(goodJobName), new ApplicationAndJobName(appName, goodJobName));
                    ((JobInstanceImpl) result).setId(jobInstanceId);
                    jobInstances.put(jobInstanceId, result);
                }
                break;
            }
View Full Code Here

TOP

Related Classes of org.jberet.runtime.JobInstanceImpl

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.