openejb = JaxbOpenejb.createOpenejb();
}
loadPropertiesDeclaredConfiguration(openejb);
sys = new OpenEjbConfiguration();
sys.containerSystem = new ContainerSystemInfo();
sys.facilities = new FacilitiesInfo();
for (final JndiProvider provider : openejb.getJndiProvider()) {
final JndiContextInfo info = configureService(provider, JndiContextInfo.class);
sys.facilities.remoteJndiContexts.add(info);
}
sys.facilities.securityService = configureService(openejb.getSecurityService(), SecurityServiceInfo.class);
sys.facilities.transactionService = configureService(openejb.getTransactionManager(), TransactionServiceInfo.class);
final List<ResourceInfo> resources = new ArrayList<ResourceInfo>();
for (final Resource resource : openejb.getResource()) {
final ResourceInfo resourceInfo = configureService(resource, ResourceInfo.class);
resources.add(resourceInfo);
}
Collections.sort(resources, new ResourceInfoComparator(resources));
sys.facilities.resources.addAll(resources);
// ConnectionManagerInfo service = configureService(openejb.getConnectionManager(), ConnectionManagerInfo.class);
// sys.facilities.connectionManagers.add(service);
if (openejb.getProxyFactory() != null) {
sys.facilities.intraVmServer = configureService(openejb.getProxyFactory(), ProxyFactoryInfo.class);
}
for (final Container declaration : openejb.getContainer()) {
final ContainerInfo info = createContainerInfo(declaration);
sys.containerSystem.containers.add(info);
}
final List<String> declaredApps = getDeclaredApps();
for (final String pathname : declaredApps) {
try {
try {
final File jarFile;
if (pathname.startsWith("file:/")) {
jarFile = new File(new URI(pathname));
} else {
jarFile = new File(pathname);
}
final AppInfo appInfo = configureApplication(jarFile);
sys.containerSystem.applications.add(appInfo);
} catch (URISyntaxException e) {
logger.error("Invalid declaredApp URI '" + pathname + "'", e);
}
} catch (OpenEJBException alreadyHandled) {
final DeploymentExceptionManager exceptionManager = SystemInstance.get().getComponent(DeploymentExceptionManager.class);
exceptionManager.pushDelpoymentException(alreadyHandled);
}
}
final boolean embedded = SystemInstance.get().hasProperty(EJBContainer.class.getName());
final Options options = SystemInstance.get().getOptions();
if (options.get("openejb.system.apps", false)) {
try {
final AppInfo appInfo = configureApplication(new AppModule(SystemApps.getSystemModule()));
sys.containerSystem.applications.add(appInfo);
} catch (OpenEJBException e) {
logger.error("Unable to load the system applications.", e);
}
} else if (options.get(DEPLOYMENTS_CLASSPATH_PROPERTY, !embedded)) {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ArrayList<File> jarFiles = getModulesFromClassPath(declaredApps, classLoader);
final String appId = "classpath.ear";
final boolean classpathAsEar = options.get(CLASSPATH_AS_EAR, true);
try {
if (classpathAsEar && !jarFiles.isEmpty()) {
final AppInfo appInfo = configureApplication(classLoader, appId, jarFiles);
sys.containerSystem.applications.add(appInfo);
} else for (final File jarFile : jarFiles) {
final AppInfo appInfo = configureApplication(jarFile);
sys.containerSystem.applications.add(appInfo);
}
if (jarFiles.size() == 0) {
logger.warning("config.noModulesFoundToDeploy");
}
} catch (OpenEJBException alreadyHandled) {
logger.debug("config.alreadyHandled");
}
}
if (!offline && !UpdateChecker.isSkipped()) {
try {
updateCheckerThreader.join(10000); // 10s is already a lot
} catch (InterruptedException ignored) {
// no-op
}
if (!UpdateChecker.usesLatest()) {
logger.warning(UpdateChecker.message());
}
}
final OpenEjbConfiguration finished = sys;
sys = null;
openejb = null;
return finished;
}