use of lucee.loader.util.ExtensionFilter in project Lucee by lucee.
the class CFMLEngineFactory method removeUpdate.
/**
* updates the engine when a update is available
*
* @return has updated
* @throws IOException
* @throws ServletException
*/
private boolean removeUpdate() throws IOException, ServletException {
final File patchDir = getPatchDirectory();
final File[] patches = patchDir.listFiles(new ExtensionFilter(new String[] { "rc", "rcs" }));
for (int i = 0; i < patches.length; i++) if (!patches[i].delete())
patches[i].deleteOnExit();
_restart();
return true;
}
use of lucee.loader.util.ExtensionFilter in project Lucee by lucee.
the class CFMLEngineFactory method initEngine.
/*private boolean dumpThreads() {
Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
Iterator<Entry<Thread, StackTraceElement[]>> it = map.entrySet().iterator();
Thread t;
System.err.println("-------- threads "+System.currentTimeMillis()+" ---------");
boolean has=false;
while(it.hasNext()) {
Entry<Thread, StackTraceElement[]> e = it.next();
if(e.getKey().getName().toLowerCase().indexOf("felixresolver")!=-1) {
System.err.println("- "+e.getKey().getName());
has=true;
}
}
return has;
}*/
private void initEngine() throws ServletException {
final Version coreVersion = VersionInfo.getIntVersion();
final long coreCreated = VersionInfo.getCreateTime();
// get newest lucee version as file
File patcheDir = null;
try {
patcheDir = getPatchDirectory();
log(Logger.LOG_DEBUG, "lucee-server-root:" + patcheDir.getParent());
} catch (final IOException e) {
throw new ServletException(e);
}
final File[] patches = PATCH_ENABLED ? patcheDir.listFiles(new ExtensionFilter(new String[] { ".lco" })) : null;
File lucee = null;
if (patches != null)
for (final File patche : patches) if (patche.getName().startsWith("tmp.lco"))
patche.delete();
else if (patche.lastModified() < coreCreated)
patche.delete();
else if (lucee == null || Util.isNewerThan(toVersion(patche.getName(), VERSION_ZERO), toVersion(lucee.getName(), VERSION_ZERO)))
lucee = patche;
if (lucee != null && Util.isNewerThan(coreVersion, toVersion(lucee.getName(), VERSION_ZERO)))
lucee = null;
// URL url=null;
try {
// Load core version when no patch available
if (lucee == null) {
log(Logger.LOG_DEBUG, "Load Build in Core");
//
final String coreExt = "lco";
// copy core
final File rc = new File(getTempDirectory(), "tmp_" + System.currentTimeMillis() + "." + coreExt);
InputStream is = null;
OutputStream os = null;
try {
is = new TP().getClass().getResourceAsStream("/core/core." + coreExt);
os = new BufferedOutputStream(new FileOutputStream(rc));
copy(is, os);
} finally {
closeEL(is);
closeEL(os);
}
lucee = new File(patcheDir, getVersion(rc) + "." + coreExt);
try {
is = new FileInputStream(rc);
os = new BufferedOutputStream(new FileOutputStream(lucee));
copy(is, os);
} finally {
closeEL(is);
closeEL(os);
rc.delete();
}
setEngine(_getCore(lucee));
/*if (PATCH_ENABLED) {
final InputStream bis = new TP().getClass()
.getResourceAsStream("/core/core." + coreExt);
final OutputStream bos = new BufferedOutputStream(
new FileOutputStream(lucee));
copy(bis, bos);
closeEL(bis);
closeEL(bos);
}*/
} else {
bundleCollection = BundleLoader.loadBundles(this, getFelixCacheDirectory(), getBundleDirectory(), lucee, bundleCollection);
// bundle=loadBundle(lucee);
log(Logger.LOG_DEBUG, "loaded bundle:" + bundleCollection.core.getSymbolicName());
setEngine(getEngine(bundleCollection));
log(Logger.LOG_DEBUG, "loaded engine:" + singelton);
}
version = singelton.getInfo().getVersion();
log(Logger.LOG_DEBUG, "Loaded Lucee Version " + singelton.getInfo().getVersion());
} catch (final InvocationTargetException e) {
e.getTargetException().printStackTrace();
throw new ServletException(e.getTargetException());
} catch (final Exception e) {
e.printStackTrace();
throw new ServletException(e);
}
// check updates
String updateType = singelton.getUpdateType();
if (updateType == null || updateType.length() == 0)
updateType = "manuell";
if (updateType.equalsIgnoreCase("auto"))
new UpdateChecker(this, null).start();
}
Aggregations