} else if (isEar) { // mainly for CDi TCKs
final FinderFactory.OpenEJBAnnotationFinder earLibFinder = new FinderFactory.OpenEJBAnnotationFinder(new SimpleWebappAggregatedArchive(earArchive, earMap));
appModule.setEarLibFinder(earLibFinder);
final EjbModule earCdiModule = new EjbModule(appModule.getClassLoader(), DeploymentLoader.EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar());
earCdiModule.setBeans(new Beans());
earCdiModule.setFinder(earLibFinder);
earCdiModule.setEjbJar(new EmptyEjbJar());
appModule.getEjbModules().add(earCdiModule);
for (final Map.Entry<ArchivePath, Node> node : archive.getContent(new IncludeRegExpPaths("/.*\\.war")).entrySet()) {
final Asset asset = node.getValue().getAsset();
if (ArchiveAsset.class.isInstance(asset)) {
final Archive<?> webArchive = ArchiveAsset.class.cast(asset).getArchive();
if (WebArchive.class.isInstance(webArchive)) {
/* TODO: libs
final Map<ArchivePath, Node> libs = archive.getContent(new IncludeRegExpPaths("/WEB-INF/lib/.*\\.jar"));
*/
final Map<String, Object> altDD = new HashMap<String, Object>();
final Node beansXml = findBeansXml(webArchive, new ArrayList<AssetSource>(), WEB_INF, altDD);
final SWClassLoader webLoader = new SWClassLoader(WEB_INF_CLASSES, parent, webArchive);
final FinderFactory.OpenEJBAnnotationFinder finder = new FinderFactory.OpenEJBAnnotationFinder(
finderArchive(beansXml, webArchive, webLoader, Collections.<URL>emptyList()));
final WebModule webModule = new WebModule(new WebApp(), contextRoot(webArchive.getName()), loader, "", appModule.getModuleId());
webModule.setUrls(Collections.<URL>emptyList());
webModule.setScannableUrls(Collections.<URL>emptyList());
webModule.setFinder(finder);
final EjbModule ejbModule = new EjbModule(webLoader, webModule.getModuleId(), null, new EjbJar(), new OpenejbJar());
ejbModule.getAltDDs().putAll(altDD);
ejbModule.setFinder(finder);
ejbModule.setClassLoader(webLoader);
ejbModule.setWebapp(true);
appModule.getEjbModules().add(ejbModule);
appModule.getWebModules().add(webModule);
addPersistenceXml(archive, WEB_INF, appModule);
addOpenEJbJarXml(archive, WEB_INF, ejbModule);
addValidationXml(archive, WEB_INF, new HashMap<String, Object>(), ejbModule);
addResourcesXml(archive, WEB_INF, ejbModule);
addEnvEntries(archive, WEB_INF, appModule, ejbModule);
}
}
}
}
if (isEar) { // adding the test class as lib class can break test if tested against the web part of the ear
return appModule;
}
// add the test as a managed bean to be able to inject into it easily
final Map<String, Object> testDD;
if (javaClass != null) {
final EjbJar ejbJar = new EjbJar();
final OpenejbJar openejbJar = new OpenejbJar();
final String ejbName = appModule.getModuleId() + "_" + javaClass.getName();
final ManagedBean bean = ejbJar.addEnterpriseBean(new ManagedBean(ejbName, javaClass.getName(), true));
bean.localBean();
bean.setTransactionType(TransactionType.BEAN);
final EjbDeployment ejbDeployment = openejbJar.addEjbDeployment(bean);
ejbDeployment.setDeploymentId(ejbName);
final EjbModule e = new EjbModule(ejbJar, openejbJar);
e.getProperties().setProperty("openejb.cdi.activated", "false");
e.setBeans(new Beans());
e.setClassLoader(tempClassLoader);
appModule.getEjbModules().add(e);
testDD = e.getAltDDs();
} else {
testDD = new HashMap<>(); // ignore