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:
parent
f9ce4c8c07
commit
96a8d6f95e
3 changed files with 44 additions and 4 deletions
|
@ -291,11 +291,22 @@ public final class Application implements IPathElement, Runnable {
|
||||||
public synchronized void init()
|
public synchronized void init()
|
||||||
throws DatabaseException, IllegalAccessException,
|
throws DatabaseException, IllegalAccessException,
|
||||||
InstantiationException, ClassNotFoundException {
|
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;
|
running = true;
|
||||||
|
|
||||||
// create and init type mananger
|
// create and init type mananger
|
||||||
typemgr = new TypeManager(this);
|
typemgr = new TypeManager(this, ignoreDirs);
|
||||||
try {
|
try {
|
||||||
typemgr.createPrototypes();
|
typemgr.createPrototypes();
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package helma.framework.core;
|
||||||
import helma.objectmodel.db.DbMapping;
|
import helma.objectmodel.db.DbMapping;
|
||||||
import helma.framework.repository.Resource;
|
import helma.framework.repository.Resource;
|
||||||
import helma.framework.repository.Repository;
|
import helma.framework.repository.Repository;
|
||||||
|
import helma.util.StringUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -43,6 +44,9 @@ public final class TypeManager {
|
||||||
// set of Java archives
|
// set of Java archives
|
||||||
private HashSet jarfiles;
|
private HashSet jarfiles;
|
||||||
|
|
||||||
|
// set of directory names to ignore
|
||||||
|
private HashSet ignoreDirs;
|
||||||
|
|
||||||
private long lastCheck = 0;
|
private long lastCheck = 0;
|
||||||
private long lastCodeUpdate;
|
private long lastCodeUpdate;
|
||||||
private long[] lastRepoScan;
|
private long[] lastRepoScan;
|
||||||
|
@ -57,10 +61,17 @@ public final class TypeManager {
|
||||||
*
|
*
|
||||||
* @throws RuntimeException ...
|
* @throws RuntimeException ...
|
||||||
*/
|
*/
|
||||||
public TypeManager(Application app) {
|
public TypeManager(Application app, String ignore) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
prototypes = new HashMap();
|
prototypes = new HashMap();
|
||||||
jarfiles = new HashSet();
|
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("/");
|
URL helmajar = TypeManager.class.getResource("/");
|
||||||
|
|
||||||
|
@ -116,6 +127,16 @@ public final class TypeManager {
|
||||||
private void checkRepository(Repository repository) throws IOException {
|
private void checkRepository(Repository repository) throws IOException {
|
||||||
Repository[] list = repository.getRepositories();
|
Repository[] list = repository.getRepositories();
|
||||||
for (int i = 0; i < list.length; i++) {
|
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()) {
|
if (list[i].isScriptRoot()) {
|
||||||
// this is an embedded top-level script repository
|
// this is an embedded top-level script repository
|
||||||
if (app.addRepository(list[i])) {
|
if (app.addRepository(list[i])) {
|
||||||
|
|
|
@ -288,6 +288,11 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
boolean encode;
|
boolean encode;
|
||||||
Repository[] repositories;
|
Repository[] repositories;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* extend apps.properties, add [appname].ignore
|
||||||
|
*/
|
||||||
|
String ignoreDirs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an AppDescriptor from the properties.
|
* Creates an AppDescriptor from the properties.
|
||||||
*/
|
*/
|
||||||
|
@ -321,6 +326,9 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
String dbDirName = props.getProperty(name + ".dbdir");
|
String dbDirName = props.getProperty(name + ".dbdir");
|
||||||
dbDir = (dbDirName == null) ? null : new File(dbDirName);
|
dbDir = (dbDirName == null) ? null : new File(dbDirName);
|
||||||
|
|
||||||
|
// got ignore dirs
|
||||||
|
ignoreDirs = props.getProperty(name + ".ignore");
|
||||||
|
|
||||||
// read and configure app repositories
|
// read and configure app repositories
|
||||||
ArrayList repositoryList = new ArrayList();
|
ArrayList repositoryList = new ArrayList();
|
||||||
for (int i = 0; true; i++) {
|
for (int i = 0; true; i++) {
|
||||||
|
@ -348,7 +356,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
.newInstance((Object[]) repositoryArgs);
|
.newInstance((Object[]) repositoryArgs);
|
||||||
repositoryList.add(newRepository);
|
repositoryList.add(newRepository);
|
||||||
} catch (Exception ex) {
|
} 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!");
|
"Will not use that repository. Check your initArgs!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -392,7 +400,7 @@ public class ApplicationManager implements XmlRpcHandler {
|
||||||
applications.put(appName, app);
|
applications.put(appName, app);
|
||||||
|
|
||||||
// the application is started later in the register method, when it's bound
|
// 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
|
// set application URL prefix if it isn't set in app.properties
|
||||||
if (!app.hasExplicitBaseURI()) {
|
if (!app.hasExplicitBaseURI()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue