Search in sources :

Example 1 with JobInstance

use of javax.batch.runtime.JobInstance in project wildfly by wildfly.

the class JobOperatorService method restart.

@Override
public long restart(final long executionId, final Properties restartParameters) throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException {
    checkState(null, "restart");
    final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
        final JobInstance instance = super.getJobInstance(executionId);
        validateJob(instance.getJobName());
        return super.restart(executionId, restartParameters, getBatchEnvironment().getCurrentUserName());
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
    }
}
Also used : JobInstance(javax.batch.runtime.JobInstance)

Example 2 with JobInstance

use of javax.batch.runtime.JobInstance in project wildfly by wildfly.

the class JobOperatorService method getJobExecution.

@Override
public JobExecution getJobExecution(final long executionId) throws NoSuchJobExecutionException, JobSecurityException {
    checkState();
    final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
        final JobInstance instance = getJobInstance(executionId);
        validateJob(instance.getJobName());
        return super.getJobExecution(executionId);
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
    }
}
Also used : JobInstance(javax.batch.runtime.JobInstance)

Example 3 with JobInstance

use of javax.batch.runtime.JobInstance in project wildfly by wildfly.

the class JobOperatorService method getStepExecutions.

@Override
public List<StepExecution> getStepExecutions(final long jobExecutionId) throws NoSuchJobExecutionException, JobSecurityException {
    checkState();
    final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
        final JobInstance instance = super.getJobInstance(jobExecutionId);
        validateJob(instance.getJobName());
        return super.getStepExecutions(jobExecutionId);
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
    }
}
Also used : JobInstance(javax.batch.runtime.JobInstance)

Example 4 with JobInstance

use of javax.batch.runtime.JobInstance in project wildfly by wildfly.

the class JobOperatorService method abandon.

@Override
public void abandon(final long executionId) throws NoSuchJobExecutionException, JobExecutionIsRunningException, JobSecurityException {
    checkState(null, "abandon");
    final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
        final JobInstance instance = super.getJobInstance(executionId);
        validateJob(instance.getJobName());
        super.abandon(executionId);
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
    }
}
Also used : JobInstance(javax.batch.runtime.JobInstance)

Example 5 with JobInstance

use of javax.batch.runtime.JobInstance in project wildfly by wildfly.

the class BatchJobExecutionResource method refreshChildren.

/**
     * Note the access to the {@link #children} is <strong>not</strong> guarded here and needs to be externally
     * guarded.
     */
private void refreshChildren() {
    final List<JobExecution> executions = new ArrayList<>();
    // Casting to (Supplier<List<JobInstance>>) is done here on purpose as a workaround for a bug in 1.8.0_45
    final List<JobInstance> instances = jobOperator.allowMissingJob((Supplier<List<JobInstance>>) () -> jobOperator.getJobInstances(jobName, 0, jobOperator.getJobInstanceCount(jobName)), Collections.emptyList());
    for (JobInstance instance : instances) {
        executions.addAll(jobOperator.getJobExecutions(instance));
    }
    for (JobExecution execution : executions) {
        final String name = Long.toString(execution.getExecutionId());
        if (!children.contains(name)) {
            children.add(name);
        }
    }
}
Also used : JobExecution(javax.batch.runtime.JobExecution) JobInstance(javax.batch.runtime.JobInstance) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

JobInstance (javax.batch.runtime.JobInstance)8 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JobExecution (javax.batch.runtime.JobExecution)1