Search in sources :

Example 6 with ExtensionFilter

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;
}
Also used : ExtensionFilter(lucee.loader.util.ExtensionFilter) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 7 with ExtensionFilter

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();
}
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

File (java.io.File)7 ExtensionFilter (lucee.loader.util.ExtensionFilter)7 JarFile (java.util.jar.JarFile)4 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2 ZipFile (java.util.zip.ZipFile)2 IsZipFile (lucee.runtime.functions.system.IsZipFile)2 BundleFile (lucee.runtime.osgi.BundleFile)2 BundleException (org.osgi.framework.BundleException)2 Version (org.osgi.framework.Version)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1