final Collection<BeanContext> toStart = new ArrayList<BeanContext>();
// deploy
for (final BeanContext deployment : allDeployments) {
try {
final Container container = deployment.getContainer();
if (container.getBeanContext(deployment.getDeploymentID()) == null) {
container.deploy(deployment);
if (!((String) deployment.getDeploymentID()).endsWith(".Comp")
&& !deployment.isHidden()) {
logger.info("createApplication.createdEjb", deployment.getDeploymentID(), deployment.getEjbName(), container.getContainerID());
}
if (logger.isDebugEnabled()) {
for (final Map.Entry<Object, Object> entry : deployment.getProperties().entrySet()) {
logger.info("createApplication.createdEjb.property", deployment.getEjbName(), entry.getKey(), entry.getValue());
}
}
toStart.add(deployment);
}
} catch (final Throwable t) {
throw new OpenEJBException("Error deploying '" + deployment.getEjbName() + "'. Exception: " + t.getClass() + ": " + t.getMessage(), t);
}
}
// start
for (final BeanContext deployment : toStart) {
try {
final Container container = deployment.getContainer();
container.start(deployment);
if (!((String) deployment.getDeploymentID()).endsWith(".Comp")
&& !deployment.isHidden()) {
logger.info("createApplication.startedEjb", deployment.getDeploymentID(), deployment.getEjbName(), container.getContainerID());
}
} catch (final Throwable t) {
throw new OpenEJBException("Error starting '" + deployment.getEjbName() + "'. Exception: " + t.getClass() + ": " + t.getMessage(), t);
}
}