[jboss-dev-forums] [Design the new POJO MicroContainer] - Multiple matching files by name in parsing deployer

alesj do-not-reply at jboss.com
Wed Nov 19 17:38:29 EST 2008


While doing webbeans mocking, I came up with the following issue.

As current WarStructure adds all of WEB-INF/lib jars's META-INF
as meta data location:

  |                   archives = webinfLib.getChildren(webInfLibFilter);
  |                   // Add the jars' META-INF for metadata
  |                   for (VirtualFile jar : archives)
  |                   {
  |                      // either same as plain lib filter, null or accepts the jar
  |                      if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
  |                         metaDataLocations.add("WEB-INF/lib/" + jar.getName() + "/META-INF");
  |                   }
  | 
one could silently end up with wrong metadata.

e.g. JPA PersistenceParsingDeployer::setName("persistence.xml")
and then some lib jar accidentally has some persistence.xml leftover in its META-INF.
There is a chance this is gonna be picked up,
since we return on first found/matching file:

  |    protected VirtualFile searchMetaDataLocations(String name)
  |    {
  |       VirtualFile result = null;
  |       for(VirtualFile location : getMetaDataLocations())
  |       {
  |          try
  |          {
  |             result = location.getChild(name);
  |             if (result != null)
  |             {
  |                if (log.isTraceEnabled())
  |                   log.trace("Found " + name + " in " + location.getName());
  |                deployed();
  |                break;
  |             }
  |          }
  |          catch (IOException e)
  |          {
  |             log.debug("Search exception invocation for metafile " + name + " in " + location.getName() + ", reason: " + e);
  |          }
  |       }
  |       return result;
  |    }
  | 

What would be a proper way to handle this?
This is current behavior when you call VFSDeploymentUnit::getMetaDataFile(String name).

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4190658#4190658

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4190658



More information about the jboss-dev-forums mailing list