ignore-dirs patch contributed by Barbara Ondrisek:

appname.ignore = dir1,dir2 prevents Prototypes to be created for the given directories.
This commit is contained in:
hns 2005-06-10 12:28:27 +00:00
parent f9ce4c8c07
commit 96a8d6f95e
3 changed files with 44 additions and 4 deletions

View file

@ -291,11 +291,22 @@ public final class Application implements IPathElement, Runnable {
public synchronized void init()
throws DatabaseException, IllegalAccessException,
InstantiationException, ClassNotFoundException {
init(null);
}
/**
* Get the application ready to run, initializing the evaluators and type manager.
*
* @param ignoreDirs comma separated list of directory names to ignore
*/
public synchronized void init(String ignoreDirs)
throws DatabaseException, IllegalAccessException,
InstantiationException, ClassNotFoundException {
running = true;
// create and init type mananger
typemgr = new TypeManager(this);
typemgr = new TypeManager(this, ignoreDirs);
try {
typemgr.createPrototypes();
} catch (Exception x) {

View file

@ -19,6 +19,7 @@ package helma.framework.core;
import helma.objectmodel.db.DbMapping;
import helma.framework.repository.Resource;
import helma.framework.repository.Repository;
import helma.util.StringUtils;
import java.io.*;
import java.net.URL;
@ -43,6 +44,9 @@ public final class TypeManager {
// set of Java archives
private HashSet jarfiles;
// set of directory names to ignore
private HashSet ignoreDirs;
private long lastCheck = 0;
private long lastCodeUpdate;
private long[] lastRepoScan;
@ -57,10 +61,17 @@ public final class TypeManager {
*
* @throws RuntimeException ...
*/
public TypeManager(Application app) {
public TypeManager(Application app, String ignore) {
this.app = app;
prototypes = new HashMap();
jarfiles = new HashSet();
ignoreDirs = new HashSet();
// split ignore dirs list and add to hash set
if (ignore != null) {
String[] arr = StringUtils.split(ignore, ",");
for (int i=0; i<arr.length; i++)
ignoreDirs.add(arr[i].trim());
}
URL helmajar = TypeManager.class.getResource("/");
@ -116,6 +127,16 @@ public final class TypeManager {
private void checkRepository(Repository repository) throws IOException {
Repository[] list = repository.getRepositories();
for (int i = 0; i < list.length; i++) {
// ignore dir name found - compare to shortname (= Prototype name)
if (ignoreDirs.contains(list[i].getShortName())) {
// jump this repository
if (app.debug) {
app.logEvent("Repository " + list[i].getName() + " ignored");
}
continue;
}
if (list[i].isScriptRoot()) {
// this is an embedded top-level script repository
if (app.addRepository(list[i])) {

View file

@ -288,6 +288,11 @@ public class ApplicationManager implements XmlRpcHandler {
boolean encode;
Repository[] repositories;
/**
* extend apps.properties, add [appname].ignore
*/
String ignoreDirs;
/**
* Creates an AppDescriptor from the properties.
*/
@ -321,6 +326,9 @@ public class ApplicationManager implements XmlRpcHandler {
String dbDirName = props.getProperty(name + ".dbdir");
dbDir = (dbDirName == null) ? null : new File(dbDirName);
// got ignore dirs
ignoreDirs = props.getProperty(name + ".ignore");
// read and configure app repositories
ArrayList repositoryList = new ArrayList();
for (int i = 0; true; i++) {
@ -348,7 +356,7 @@ public class ApplicationManager implements XmlRpcHandler {
.newInstance((Object[]) repositoryArgs);
repositoryList.add(newRepository);
} catch (Exception ex) {
System.out.println("Adding repository " + repositoryArgs + " failed. " +
System.out.println("Adding repository " + repositoryArgs[0] + " failed. " +
"Will not use that repository. Check your initArgs!");
}
} else {
@ -392,7 +400,7 @@ public class ApplicationManager implements XmlRpcHandler {
applications.put(appName, app);
// the application is started later in the register method, when it's bound
app.init();
app.init(ignoreDirs);
// set application URL prefix if it isn't set in app.properties
if (!app.hasExplicitBaseURI()) {