Search in sources :

Example 1 with TP

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;
        }
    }
}
Also used : IOException(java.io.IOException) ParseException(java.text.ParseException) TP(lucee.loader.TP) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with TP

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();
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) InvocationTargetException(java.lang.reflect.InvocationTargetException) ServletException(javax.servlet.ServletException) BundleException(org.osgi.framework.BundleException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ServletException(javax.servlet.ServletException) Version(org.osgi.framework.Version) ExtensionFilter(lucee.loader.util.ExtensionFilter) FileOutputStream(java.io.FileOutputStream) TP(lucee.loader.TP) JarFile(java.util.jar.JarFile) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Aggregations

IOException (java.io.IOException)2 TP (lucee.loader.TP)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 UnknownHostException (java.net.UnknownHostException)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 JarFile (java.util.jar.JarFile)1 ZipInputStream (java.util.zip.ZipInputStream)1 ServletException (javax.servlet.ServletException)1 ExtensionFilter (lucee.loader.util.ExtensionFilter)1