public void execute() throws MojoExecutionException, MojoFailureException {
MavenLogStreamFactory.setLogger(getLog());
final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(createClassLoader(oldCl));
EJBContainer container = null;
try {
container = EJBContainer.createEJBContainer(map());
if (await) {
final CountDownLatch latch = new CountDownLatch(1);
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
latch.countDown();
}
}));
try {
latch.await();
} catch (InterruptedException e) {
// ignored
}
}
} finally {
if (container != null) {
container.close();
}
Thread.currentThread().setContextClassLoader(oldCl);
}
}