Skip to content

Commit

Permalink
Fix support for deployments with WEB-INF/beans.xml and no WEB-INF/cla…
Browse files Browse the repository at this point in the history
…sses
  • Loading branch information
jharting committed Dec 19, 2012
1 parent 1654fd8 commit 7f3cf91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
Expand Up @@ -166,8 +166,12 @@ private BeanDeploymentArchiveImpl createBeanDeploymentArchive(final Index index,
classNames.add(classInfo.name().toString());
}
}
return new BeanDeploymentArchiveImpl(classNames, beanArchiveMetadata.getBeansXml(), module, beanArchivePrefix
+ beanArchiveMetadata.getResourceRoot().getRoot().getPathName(), root);

String beanArchiveId = beanArchivePrefix;
if (beanArchiveMetadata.getResourceRoot() != null) {
beanArchiveId += beanArchiveMetadata.getResourceRoot().getRoot().getPathName();
}
return new BeanDeploymentArchiveImpl(classNames, beanArchiveMetadata.getBeansXml(), module, beanArchiveId, root);
}

@Override
Expand Down
Expand Up @@ -90,25 +90,25 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
}

if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
final VirtualFile rootBeansXml = deploymentRoot.getRoot().getChild(WEB_INF_BEANS_XML);
final boolean rootBeansXmlPresent = rootBeansXml.exists() && rootBeansXml.isFile();

VirtualFile beansXml = null;
if (classesRoot != null) {
// look for WEB-INF/beans.xml
final VirtualFile rootBeansXml = deploymentRoot.getRoot().getChild(WEB_INF_BEANS_XML);
final boolean rootBeansXmlPresent = rootBeansXml.exists() && rootBeansXml.isFile();
// look for beans.xml files in the wrong location
final VirtualFile beansXml = classesRoot.getRoot().getChild(META_INF_BEANS_XML);
final boolean beansXmlPresent = beansXml.exists() && beansXml.isFile();

if (rootBeansXmlPresent) {
if (beansXmlPresent) {
// warn that it is not portable to use both locations at the same time
WeldLogger.DEPLOYMENT_LOGGER.duplicateBeansXml();
}
WeldLogger.DEPLOYMENT_LOGGER.debugf("Found beans.xml: %s", rootBeansXml);
beanArchiveMetadata.add(new BeanArchiveMetadata(rootBeansXml, classesRoot, parseBeansXml(rootBeansXml, parser, deploymentUnit), true));
} else if (beansXmlPresent) {
WeldLogger.DEPLOYMENT_LOGGER.debugf("Found beans.xml: %s", beansXml);
beanArchiveMetadata.add(new BeanArchiveMetadata(beansXml, classesRoot, parseBeansXml(beansXml, parser, deploymentUnit), true));
beansXml = classesRoot.getRoot().getChild(META_INF_BEANS_XML);
}
final boolean beansXmlPresent = beansXml != null && beansXml.exists() && beansXml.isFile();

if (rootBeansXmlPresent) {
if (beansXmlPresent) {
// warn that it is not portable to use both locations at the same time
WeldLogger.DEPLOYMENT_LOGGER.duplicateBeansXml();
}
WeldLogger.DEPLOYMENT_LOGGER.debugf("Found beans.xml: %s", rootBeansXml);
beanArchiveMetadata.add(new BeanArchiveMetadata(rootBeansXml, classesRoot, parseBeansXml(rootBeansXml, parser, deploymentUnit), true));
} else if (beansXmlPresent) {
WeldLogger.DEPLOYMENT_LOGGER.debugf("Found beans.xml: %s", beansXml);
beanArchiveMetadata.add(new BeanArchiveMetadata(beansXml, classesRoot, parseBeansXml(beansXml, parser, deploymentUnit), true));
}
} else if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
final VirtualFile rootBeansXml = deploymentRoot.getRoot().getChild(META_INF_BEANS_XML);
Expand Down

0 comments on commit 7f3cf91

Please sign in to comment.