Skip to content

Commit

Permalink
Fixed #48 Removed versioned dir in compile.path.
Browse files Browse the repository at this point in the history
  • Loading branch information
subchen committed Dec 13, 2013
1 parent 9b5db7d commit 7ec5d22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/main/java/jetbrick/template/JetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class JetConfig extends ConfigSupport<JetConfig> {

public JetConfig() {
// default config
String defaultCompilePath = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
String defaultCompilePath = new File(System.getProperty("java.io.tmpdir"), "jetx").getAbsolutePath();

Properties config = new Properties();
config.setProperty(IMPORT_AUTOSCAN, "false");
Expand Down Expand Up @@ -107,9 +107,9 @@ public JetConfig build() {
if (log.isInfoEnabled()) {
log.info("Load template from \"" + templatePath + "\" by " + templateLoader + ".");
if (templateReloadable) {
log.info("autoload on: template will automatically reload.");
log.info("Auto loading on: template will automatically reload.");
} else {
log.info("autoload off: template will NOT automatically reload.");
log.info("Auto loading off: template will NOT automatically reload.");
}
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.io.File;
import java.net.*;
import jetbrick.template.JetEngine;
import jetbrick.template.parser.support.ClassUtils;
import jetbrick.template.utils.ExceptionUtils;
import jetbrick.template.utils.PathUtils;
Expand All @@ -36,7 +35,7 @@ public class JetTemplateClassLoader {
private final boolean reloadable;

public JetTemplateClassLoader(String classpath, boolean reloadable) {
this.classpath = getVersionClasspath(classpath);
this.classpath = getCanonicalClasspath(classpath);
this.urls = new URL[] { toURL(this.classpath) };
this.classloader = createClassLoader();
this.reloadable = reloadable;
Expand All @@ -62,9 +61,8 @@ private ClassLoader createClassLoader() {
return new URLClassLoader(urls, ClassUtils.getContextClassLoader());
}

// 根据不同的 Version 生成不同的 classpath
private static String getVersionClasspath(String classpath) {
File dir = new File(classpath, "jetx_" + JetEngine.VERSION.replace('.', '_'));
private static String getCanonicalClasspath(String classpath) {
File dir = new File(classpath);
// 必须先建立目录,否则 URLClassLoader 会失败
if (!dir.mkdirs() && !dir.exists()) {
throw new IllegalStateException("Can't create a directory in " + dir.getAbsolutePath());
Expand Down

0 comments on commit 7ec5d22

Please sign in to comment.