use of lucee.loader.TP in project Lucee by lucee.
the class VersionInfo method init.
private static void init() {
if (version != null)
return;
String content = "9000000:" + System.currentTimeMillis();
try {
content = getContentAsString(new TP().getClass().getClassLoader().getResourceAsStream("lucee/version"), "UTF-8");
} catch (final IOException e) {
}
final int index = content.indexOf(':');
version = CFMLEngineFactorySupport.toVersion(content.substring(0, index), CFMLEngineFactory.VERSION_ZERO);
final String d = content.substring(index + 1);
try {
created = Long.parseLong(d);
} catch (final NumberFormatException nfe) {
try {
created = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z").parse(d).getTime();
} catch (final ParseException pe) {
pe.printStackTrace();
created = 0;
}
}
}
use of lucee.loader.TP 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