Example usage for org.springframework.batch.core.scope.context JobSynchronizationManager getContext

List of usage examples for org.springframework.batch.core.scope.context JobSynchronizationManager getContext

Introduction

In this page you can find the example usage for org.springframework.batch.core.scope.context JobSynchronizationManager getContext.

Prototype

@Nullable
public static JobContext getContext() 

Source Link

Document

Getter for the current context if there is one, otherwise returns null .

Usage

From source file:org.springframework.batch.core.scope.JobScope.java

/**
 * Get an attribute accessor in the form of a {@link JobContext} that can
 * be used to store scoped bean instances.
 *
 * @return the current job context which we can use as a scope storage
 *         medium//w ww .  j a  v a 2 s  .c  o m
 */
private JobContext getContext() {
    JobContext context = JobSynchronizationManager.getContext();
    if (context == null) {
        throw new IllegalStateException("No context holder available for job scope");
    }
    return context;
}