protected function getEngine()
	{
		if($this->dwoo) {
			return $this->dwoo;
		}

		if(!class_exists('Dwoo')) {
			if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) {
				// file was dropped with the entire dwoo package
				require dirname(__FILE__).'/../../../dwooAutoload.php';
			} else {
				// assume the dwoo package is in the include path
				require 'dwooAutoload.php';
			}
		}

		$parentMode = fileperms(AgaviConfig::get('core.cache_dir'));

		$compileDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR;
		AgaviToolkit::mkdir($compileDir, $parentMode, true);

		$cacheDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::CACHE_DIR;
		AgaviToolkit::mkdir($cacheDir, $parentMode, true);

		$this->dwoo = new Dwoo($compileDir, $cacheDir);

		if (!empty($this->plugin_dir)) {
			$this->dwoo->getLoader()->addDirectory($this->plugin_dir);
		}

		$this->dwoo->setDefaultCompilerFactory('file', array($this, 'compilerFactory'));

		return $this->dwoo;
	}