public void execute(Operation operation, List<String> configurations, String jobName, List<String> parameters)
      throws Exception {

    // get sources of configuration
    Class<?>[] configurationClasses = new Class[configurations.size()];
    for (int i = 0; i < configurations.size(); i++) {

      configurationClasses[i] = Class.forName(configurations.get(i));
    }

    SpringApplication app = new SpringApplication(configurationClasses);

    // no (web) server needed
    app.setWebEnvironment(false);

    // start the application
    ConfigurableApplicationContext ctx = app.run(new String[0]);

    switch (operation) {
      case START:
        startBatch(ctx, jobName, parameters);
        break;
      case STOP:
        stopBatch(ctx, jobName);
        break;
      default:
        throw new RuntimeException("Unknown operation: " + operation);
    }

  }
public void execute ( Operation operation , List < String > configurations , String jobName , List < String > parameters ) throws Exception { Class < ? > [ ] configurationClasses = new Class [ configurations . size ( ) ] ; for ( int i = 0 ; i < configurations . size ( ) ; i ++ ) { configurationClasses [ i ] = Class . forName ( configurations . get ( i ) ) ; } SpringApplication app = new SpringApplication ( configurationClasses ) ; app . setWebEnvironment ( false ) ; ConfigurableApplicationContext ctx = app . run ( new String [ 0 ] ) ; switch ( operation ) { case START : startBatch ( ctx , jobName , parameters ) ; break ; case STOP : stopBatch ( ctx , jobName ) ; break ; default : throw new RuntimeException ( "Unknown operation: " + operation ) ; } }
Initialize the application context and execute the operation.
<p>
The application context is closed after the operation has finished.

@param operation The operation to start.
@param configurations The sources of bean configurations (either JavaConfig classes or XML files).
@param jobName The name of the job to launch/stop.
@param parameters The parameters (key=value).
@throws Exception