Load precompiled prolog rules from jar file
Looks in (site)/cache/rules for a jar file called: rules-(sha1 of rules.pl).jar Loads the precompiled prolog rules and uses them instead of consulting rules.pl. If the jar does not exist, consults rules.pl. If rules.pl does not exist, uses the default submit rules. Change-Id: Iae415de08dbe249eff26b753d258fd7f79a8771f
This commit is contained in:
committed by
Shawn O. Pearce
parent
76409cf7fa
commit
4efeb4fc64
@@ -60,6 +60,7 @@ public class ProjectState {
|
||||
|
||||
private final ProjectConfig config;
|
||||
private final Set<AccountGroup.UUID> localOwners;
|
||||
private final ClassLoader ruleLoader;
|
||||
|
||||
/** Last system time the configuration's revision was examined. */
|
||||
private transient long lastCheckTime;
|
||||
@@ -71,6 +72,7 @@ public class ProjectState {
|
||||
final ProjectControl.AssistedFactory projectControlFactory,
|
||||
final PrologEnvironment.Factory envFactory,
|
||||
final GitRepositoryManager gitMgr,
|
||||
final RulesCache rulesCache,
|
||||
@Assisted final ProjectConfig config) {
|
||||
this.projectCache = projectCache;
|
||||
this.isAllProjects = config.getProject().getNameKey().equals(allProjectsName);
|
||||
@@ -79,6 +81,11 @@ public class ProjectState {
|
||||
this.gitMgr = gitMgr;
|
||||
this.config = config;
|
||||
this.lastCheckTime = System.currentTimeMillis();
|
||||
if (rulesCache != null) {
|
||||
ruleLoader = rulesCache.getClassLoader(config.getRulesId());
|
||||
} else {
|
||||
ruleLoader = null;
|
||||
}
|
||||
|
||||
HashSet<AccountGroup.UUID> groups = new HashSet<AccountGroup.UUID>();
|
||||
AccessSection all = config.getAccessSection(AccessSection.ALL);
|
||||
@@ -126,7 +133,10 @@ public class ProjectState {
|
||||
|
||||
/** @return Construct a new PrologEnvironment for the calling thread. */
|
||||
public PrologEnvironment newPrologEnvironment() throws CompileException {
|
||||
// TODO Replace this with a per-project ClassLoader to isolate rules.
|
||||
if (ruleLoader != null) {
|
||||
return envFactory.create(ruleLoader);
|
||||
}
|
||||
|
||||
PrologEnvironment env = envFactory.create(getClass().getClassLoader());
|
||||
|
||||
//consult rules.pl at refs/meta/config branch for custom submit rules
|
||||
|
||||
Reference in New Issue
Block a user