in src/main/java/org/apache/sling/maven/slingstart/run/StartMojo.java [163:230]
protected void doExecute() throws MojoExecutionException, MojoFailureException {
// delete properties
if ( systemPropertiesFile != null && systemPropertiesFile.exists() ) {
FileUtils.deleteQuietly(this.systemPropertiesFile);
}
// get configurations
final Collection<ServerConfiguration> configurations = getLaunchpadConfigurations();
// create the common environment
final LaunchpadEnvironment env = new LaunchpadEnvironment(this.findLaunchpadJar(),
this.cleanWorkingDirectory,
!this.keepLaunchpadRunning,
this.launchpadReadyTimeOutSec,
this.debug);
// create callables
final Collection<LauncherCallable> tasks = new LinkedList<LauncherCallable>();
for (final ServerConfiguration launchpadConfiguration : configurations) {
validateConfiguration(launchpadConfiguration);
tasks.add(createTask(launchpadConfiguration, env));
}
// create the launchpad runner properties
this.createLaunchpadRunnerProperties(configurations);
if (parallelExecution) {
// ExecutorService for starting launchpad instances in parallel
final ExecutorService executor = Executors.newCachedThreadPool();
try {
final List<Future<ProcessDescription>> resultsCollector = executor.invokeAll(tasks);
for (final Future<ProcessDescription> future : resultsCollector) {
try {
if (null == future.get()) {
throw new MojoExecutionException("Cannot start all the instances");
}
} catch (final ExecutionException e) {
throw new MojoExecutionException(e.getLocalizedMessage(), e);
}
}
} catch ( final InterruptedException e) {
throw new MojoExecutionException(e.getLocalizedMessage(), e);
}
} else {
for (final LauncherCallable task : tasks) {
try {
if (null == task.call()) {
throw new MojoExecutionException("Cannot start all the instances");
}
} catch (final Exception e) {
throw new MojoExecutionException(e.getLocalizedMessage(), e);
}
}
}
if (this.keepLaunchpadRunning) {
getLog().info("Press CTRL-C to stop launchpad instance(s)...");
while ( true && this.isRunning(tasks)) {
try {
Thread.sleep(5000);
} catch (final InterruptedException ie) {
break;
}
}
}
blockIfNecessary();
}