Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
add archive name to the URL path.
Browse files Browse the repository at this point in the history
Otherwise the default URL#equals will not be able to
distinguish resources with same name (e.g. META-INF/beans.xml)
in different classpath locations.
  • Loading branch information
struberg committed Jun 20, 2012
1 parent 3a6f159 commit 306451a
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -82,11 +82,11 @@ private void scanArchive(Archive<?> archive)
{
Map<ArchivePath, Node> beansXmls;
beansXmls = archive.getContent(Filters.include("/WEB-INF/beans.xml"));
beansXmlPresent |= parseBeansXmls(beansXmls);
beansXmlPresent |= parseBeansXmls(archive.getName(), beansXmls);

// people might also add the marker file to WEB-INF/classes directly
beansXmls = archive.getContent(Filters.include("/WEB-INF/classes/META-INF/beans.xml"));
beansXmlPresent |= parseBeansXmls(beansXmls);
beansXmlPresent |= parseBeansXmls(archive.getName(), beansXmls);

if (beansXmlPresent)
{
Expand All @@ -108,7 +108,7 @@ else if (archive instanceof JavaArchive)
{
Map<ArchivePath, Node> beansXmls;
beansXmls = archive.getContent(Filters.include("/META-INF/beans.xml"));
beansXmlPresent = parseBeansXmls(beansXmls);
beansXmlPresent = parseBeansXmls(archive.getName(), beansXmls);
if (beansXmlPresent)
{
scanArchiveClasses(archive);
Expand Down Expand Up @@ -139,18 +139,21 @@ private void scanArchiveClasses(Archive<?> archive)
/**
* Take all given archives and add the bean.xml files to the
* ScannerService.
* @param archiveName is needed if multiple archives are used, e.g. in a WebArchive
* @param beansXmls
* @return <code>true</code> if at least one beans.xml has been parsed.
*/
private boolean parseBeansXmls(Map<ArchivePath, Node> beansXmls)
private boolean parseBeansXmls(String archiveName, Map<ArchivePath, Node> beansXmls)
{
boolean beansXmlPresent = false ;
for (final Map.Entry<ArchivePath, Node> entry : beansXmls.entrySet())
{
try
{
String urlLocation = "archive://" + archiveName + entry.getKey().get();

addWebBeansXmlLocation(
new URL(null, "archive:/" + entry.getKey().get(), new URLStreamHandler()
new URL(null, urlLocation, new URLStreamHandler()
{
@Override
protected URLConnection openConnection(URL u) throws IOException
Expand Down

0 comments on commit 306451a

Please sign in to comment.