if (unit instanceof VFSDeploymentUnit)
{
URL expWarUrl;
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
VirtualFile root = vfsUnit.getRoot();
expWarUrl = getExplodedWarUrl(root);
// Map
String warPathName = root.getPathName();
if (warPathName.endsWith("/") == false)
warPathName += "/";
List<VirtualFile> classpathVFs = vfsUnit.getClassPath();
if (classpathVFs != null)
{
List<URL> classpath = new ArrayList<URL>();
for (VirtualFile vf : classpathVFs)
{
try
{
String path = vf.getPathName();
if (path.startsWith(warPathName))
{
path = path.substring(warPathName.length());
URL pathURL = new URL(expWarUrl, path);
classpath.add(pathURL);
}
else
{
log.debug("Ignoring path element: " + vf);
}
}
catch (Exception e)
{
log.debug("Ignoring path element: " + vf, e);
}
}
unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath);
}
// Indicate that an expanded URL exists
unit.addAttachment("org.jboss.web.expandedWarURL", expWarUrl, URL.class);
// Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file
String altDDPath = metaData.getAlternativeDD();
if (altDDPath != null)
{
// First see if this is already a war local dd
VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath);
if (altDD == null)
{
// Pass absolute paths through
File file = new File(altDDPath);
if (!file.exists() || !file.isAbsolute())
{
// Should be an relative to the top deployment
VFSDeploymentUnit topUnit = vfsUnit.getTopLevel();
if (topUnit == unit)
throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path");
altDD = topUnit.getFile(altDDPath);
if (altDD == null)
throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path");
VirtualFile altDDFile = root.getChild("WEB-INF/" + altDD.getName());
log.debug("Copying the altDD to: " + altDDFile);
VFSUtils.writeFile(altDDFile, altDD.openStream());
metaData.setAlternativeDD(altDDFile.getPathName());
}
}
}
}