420944 Hot Deployment of WAR when Context XML exists doesn't trigger redeploy

This commit is contained in:
Jan Bartel 2015-01-09 13:22:39 +01:00 committed by Simone Bordet
parent 86c2d01e80
commit 0aa6f1b706
1 changed files with 148 additions and 7 deletions

View File

@ -111,12 +111,7 @@ public class WebAppProvider extends ScanningAppProvider
// else is it a war file
if (lowername.endsWith(".war"))
{
String base=name.substring(0,name.length()-4);
// ignore if it is a war for an existing xml file?
if (exists(base+".xml")||exists(base+".XML"))
return false;
// OK to deploy it then
//defer deployment decision to fileChanged()
return true;
}
@ -238,7 +233,8 @@ public class WebAppProvider extends ScanningAppProvider
{
_tempDirectory = directory;
}
/* ------------------------------------------------------------ */
/**
* Get the user supplied Work Directory.
*
@ -360,5 +356,150 @@ public class WebAppProvider extends ScanningAppProvider
}
return webAppContext;
}
/* ------------------------------------------------------------ */
@Override
protected void fileChanged(String filename) throws Exception
{
File file = new File(filename);
if (!file.exists())
return;
File parent = file.getParentFile();
//is the file that changed a directory?
if (file.isDirectory())
{
//is there a .xml file of the same name?
if (exists(file.getName()+".xml")||exists(file.getName()+".XML"))
return; //ignore it
//is there .war file of the same name?
if (exists(file.getName()+".war")||exists(file.getName()+".WAR"))
return; //ignore it
super.fileChanged(filename);
return;
}
String lowname = file.getName().toLowerCase(Locale.ENGLISH);
//is the file that changed a .war file?
if (lowname.endsWith(".war"))
{
String name = file.getName();
String base=name.substring(0,name.length()-4);
String xmlname = base+".xml";
if (exists(xmlname))
{
//if a .xml file exists for it, then redeploy that instead
File xml = new File (parent, xmlname);
super.fileChanged(xml.getCanonicalPath());
return;
}
xmlname = base+".XML";
if (exists(xmlname))
{
//if a .XML file exists for it, then redeploy that instead
File xml = new File(parent, xmlname);
super.fileChanged(xml.getCanonicalPath());
return;
}
//redeploy the changed war
super.fileChanged(filename);
return;
}
//is the file that changed a .xml file?
if (lowname.endsWith(".xml"))
super.fileChanged(filename);
}
/* ------------------------------------------------------------ */
@Override
protected void fileAdded(String filename) throws Exception
{
File file = new File(filename);
if (!file.exists())
return;
//is the file that was added a directory?
if (file.isDirectory())
{
//is there a .xml file of the same name?
if (exists(file.getName()+".xml")||exists(file.getName()+".XML"))
return; //assume we will get added events for the xml file
//is there .war file of the same name?
if (exists(file.getName()+".war")||exists(file.getName()+".WAR"))
return; //assume we will get added events for the war file
super.fileAdded(filename);
return;
}
//is the file that was added a .war file?
String lowname = file.getName().toLowerCase(Locale.ENGLISH);
if (lowname.endsWith(".war"))
{
String name = file.getName();
String base=name.substring(0,name.length()-4);
//is there a .xml file of the same name?
if (exists(base+".xml")||exists(base+".XML"))
return; //ignore it as we should get addition of the xml file
super.fileAdded(filename);
return;
}
//is the file that was added an .xml file?
if (lowname.endsWith(".xml"))
super.fileAdded(filename);
}
/* ------------------------------------------------------------ */
@Override
protected void fileRemoved(String filename) throws Exception
{
File file = new File(filename);
//is the file that was removed a directory?
if (file.isDirectory())
{
//is there a .xml file of the same name?
if (exists(file.getName()+".xml")||exists(file.getName()+".XML"))
return; //assume we will get removed events for the xml file
//is there .war file of the same name?
if (exists(file.getName()+".war")||exists(file.getName()+".WAR"))
return; //assume we will get removed events for the war file
super.fileRemoved(filename);
return;
}
//is the file that was removed a .war file?
String lowname = file.getName().toLowerCase(Locale.ENGLISH);
if (lowname.endsWith(".war"))
{
//is there a .xml file of the same name?
String name = file.getName();
String base=name.substring(0,name.length()-4);
if (exists(base+".xml")||exists(base+".XML"))
return; //ignore it as we should get removal of the xml file
super.fileRemoved(filename);
return;
}
//is the file that was removed an .xml file?
if (lowname.endsWith(".xml"))
super.fileRemoved(filename);
}
}