Rewrite ConfigurationManager to wrap ConfigurationService. Removal of "dspace-config" and "dspace.configuration" system/servlet params

This commit is contained in:
Tim Donohue
2015-07-20 11:32:36 -05:00
parent 71cab949a2
commit 257248e362
22 changed files with 113 additions and 1122 deletions

View File

@@ -292,8 +292,8 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<systemPropertyVariables> <systemPropertyVariables>
<!-- Specify the dspace.cfg file to use for test environment --> <!-- Specify the dspace.dir to use for test environment -->
<dspace.configuration>${agnostic.build.dir}/testing/dspace/config/dspace.cfg</dspace.configuration> <dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
<!-- Turn off any DSpace logging --> <!-- Turn off any DSpace logging -->
<dspace.log.init.disable>true</dspace.log.init.disable> <dspace.log.init.disable>true</dspace.log.init.disable>
</systemPropertyVariables> </systemPropertyVariables>

View File

@@ -7,7 +7,6 @@
*/ */
package org.dspace.app.util; package org.dspace.app.util;
import org.dspace.core.ConfigurationManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.servlet.ServletContextListener; import javax.servlet.ServletContextListener;
@@ -28,12 +27,6 @@ public class DSpaceContextListener implements ServletContextListener
{ {
private static Logger log = Logger.getLogger(DSpaceContextListener.class); private static Logger log = Logger.getLogger(DSpaceContextListener.class);
/**
* Name of the context parameter giving the path to the DSpace configuration file.
*/
public static final String DSPACE_CONFIG_PARAMETER = "dspace-config";
/** /**
* Initialize any resources required by the application. * Initialize any resources required by the application.
* @param event * @param event
@@ -41,7 +34,6 @@ public class DSpaceContextListener implements ServletContextListener
@Override @Override
public void contextInitialized(ServletContextEvent event) public void contextInitialized(ServletContextEvent event)
{ {
// On Windows, URL caches can cause problems, particularly with undeployment // On Windows, URL caches can cause problems, particularly with undeployment
// So, here we attempt to disable them if we detect that we are running on Windows // So, here we attempt to disable them if we detect that we are running on Windows
try try
@@ -65,54 +57,6 @@ public class DSpaceContextListener implements ServletContextListener
{ {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
// Paths to the various config files
String dspaceConfig = null;
/**
* Stage 1
*
* Locate the dspace config
*/
// first check the local per webapp parameter, then check the global parameter.
dspaceConfig = event.getServletContext().getInitParameter(DSPACE_CONFIG_PARAMETER);
// Finally, if no config parameter found throw an error
if (dspaceConfig == null || "".equals(dspaceConfig))
{
throw new IllegalStateException(
"\n\nDSpace has failed to initialize. This has occurred because it was unable to determine \n" +
"where the dspace.cfg file is located. The path to the configuration file should be stored \n" +
"in a context variable, '"+DSPACE_CONFIG_PARAMETER+"', in the global context. \n" +
"No context variable was found in either location.\n\n");
}
/**
* Stage 2
*
* Load the dspace config. Also may load log4j configuration.
* (Please rely on ConfigurationManager or Log4j to configure logging)
*
*/
try
{
ConfigurationManager.loadConfig(dspaceConfig);
}
catch (RuntimeException e)
{
throw e;
}
catch (Exception e)
{
throw new IllegalStateException(
"\n\nDSpace has failed to initialize, during stage 2. Error while attempting to read the \n" +
"DSpace configuration file (Path: '"+dspaceConfig+"'). \n" +
"This has likely occurred because either the file does not exist, or it's permissions \n" +
"are set incorrectly, or the path to the configuration file is incorrect. The path to \n" +
"the DSpace configuration file is stored in a context variable, 'dspace-config', in \n" +
"either the local servlet or global context.\n\n",e);
}
} }
/** /**

View File

@@ -8,7 +8,6 @@
package org.dspace.browse; package org.dspace.browse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
/** /**
* Command-line executed class for initializing the Browse tables of the DSpace database. * Command-line executed class for initializing the Browse tables of the DSpace database.
@@ -31,7 +30,6 @@ public class InitializeBrowseDatabase
System.exit(1); System.exit(1);
} }
ConfigurationManager.loadConfig(null);
log.info("Initializing Browse Database"); log.info("Initializing Browse Database");
try try

View File

@@ -7,61 +7,37 @@
*/ */
package org.dspace.core; package org.dspace.core;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationConverter;
import org.apache.log4j.Category;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.helpers.OptionConverter; import org.dspace.utils.DSpace;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.LicenseService;
import org.dspace.core.service.NewsService;
/** /**
* Class for reading the DSpace system configuration. The main configuration is * Class for reading the DSpace system configuration. The main configuration is
* read in as properties from a standard properties file. * read in as properties from a standard properties file.
* <P> * <P>
* The main configuration is by default read from the <em>resource</em>
* <code>/dspace.cfg</code>.
* To specify a different configuration, the system property * To specify a different configuration, the system property
* <code>dspace.configuration</code> should be set to the <em>filename</em> * <code>dspace.dir</code> should be set to the DSpace installation directory.
* of the configuration file.
* <P> * <P>
* Other configuration files are read from the <code>config</code> directory * Other configuration files are read from the <code>config</code> directory
* of the DSpace installation directory (specified as the property * of the DSpace installation directory.
* <code>dspace.dir</code> in the main configuration file.)
* *
* *
* @author Robert Tansley * @author Robert Tansley
* @author Larry Stone - Interpolated values. * @author Larry Stone - Interpolated values.
* @author Mark Diggory - General Improvements to detection, logging and loading. * @author Mark Diggory - General Improvements to detection, logging and loading.
* @author Tim Donohue - Refactored to wrap ConfigurationService
* @version $Revision$ * @version $Revision$
* @deprecated Please use org.dspace.services.ConfigurationService. See examples below.
*/ */
public class ConfigurationManager public class ConfigurationManager
{ {
/** log4j category */ /** log4j category */
private static Logger log = Logger.getLogger(ConfigurationManager.class); private static Logger log = Logger.getLogger(ConfigurationManager.class);
/** The configuration properties */
private static Properties properties = null;
/** module configuration properties */
private static Map<String, Properties> moduleProps = new HashMap<String, Properties>();
// limit of recursive depth of property variable interpolation in
// configuration; anything greater than this is very likely to be a loop.
private static final int RECURSION_LIMIT = 9;
protected ConfigurationManager() protected ConfigurationManager()
{ {
@@ -73,40 +49,9 @@ public class ConfigurationManager
*/ */
public static boolean isConfigured() public static boolean isConfigured()
{ {
return properties != null; return new DSpace().getConfigurationService() != null;
} }
public static boolean isConfigured(String module)
{
return moduleProps.get(module) != null;
}
/**
* REMOVED - Flushing the properties could be dangerous in the current DSpace state
* Need to consider how it will affect in-flight processes
*
* Discard all current properties - will force a reload from disk when
* any properties are requested.
*/
// public static void flush()
// {
// properties = null;
// }
/**
* REMOVED - Flushing the properties could be dangerous in the current DSpace state
* Need to consider how it will affect in-flight processes
*
* Discard properties for a module - will force a reload from disk
* when any of module's properties are requested
*
* @param module the module name
*/
// public static void flush(String module)
// {
// moduleProps.remove(module);
// }
/** /**
* Returns all properties in main configuration * Returns all properties in main configuration
* *
@@ -114,18 +59,7 @@ public class ConfigurationManager
*/ */
public static Properties getProperties() public static Properties getProperties()
{ {
Properties props = getMutableProperties(); return new DSpace().getConfigurationService().getProperties();
return props == null ? null : (Properties)props.clone();
}
private static Properties getMutableProperties()
{
if (properties == null)
{
loadConfig(null);
}
return properties;
} }
/** /**
@@ -137,23 +71,11 @@ public class ConfigurationManager
*/ */
public static Properties getProperties(String module) public static Properties getProperties(String module)
{ {
Properties props = getMutableProperties(module); // Find subset of Configurations which have been prefixed with the module name
return props == null ? null : (Properties)props.clone(); Configuration subset = new DSpace().getConfigurationService().getConfiguration().subset(module);
}
private static Properties getMutableProperties(String module) // Convert to a Properties object and return it
{ return ConfigurationConverter.getProperties(subset);
if (module == null)
return properties;
Properties retProps = moduleProps.get(module);
if (retProps == null)
{
loadModuleConfig(module);
retProps = moduleProps.get(module);
}
return retProps;
} }
/** /**
@@ -167,9 +89,7 @@ public class ConfigurationManager
*/ */
public static String getProperty(String property) public static String getProperty(String property)
{ {
Properties props = getMutableProperties(); return new DSpace().getConfigurationService().getProperty(property);
String value = props == null ? null : props.getProperty(property);
return (value != null) ? value.trim() : null;
} }
/** /**
@@ -191,21 +111,8 @@ public class ConfigurationManager
return getProperty(property); return getProperty(property);
} }
String value = null; // Assume "module" properties are always prefixed with the module name
Properties modProps = getMutableProperties(module); return getProperty(module + "." + property);
if (modProps != null)
{
value = modProps.getProperty(property);
}
if (value == null)
{
// look in regular properties with module name prepended
value = getProperty(module + "." + property);
}
return (value != null) ? value.trim() : null;
} }
/** /**
@@ -220,7 +127,7 @@ public class ConfigurationManager
*/ */
public static int getIntProperty(String property) public static int getIntProperty(String property)
{ {
return getIntProperty(property, 0); return new DSpace().getConfigurationService().getIntProperty(property);
} }
/** /**
@@ -238,7 +145,13 @@ public class ConfigurationManager
*/ */
public static int getIntProperty(String module, String property) public static int getIntProperty(String module, String property)
{ {
return getIntProperty(module, property, 0); if (module == null)
{
return getIntProperty(property);
}
// Assume "module" properties are always prefixed with the module name
return getIntProperty(module + "." + property);
} }
/** /**
@@ -257,7 +170,7 @@ public class ConfigurationManager
*/ */
public static int getIntProperty(String property, int defaultValue) public static int getIntProperty(String property, int defaultValue)
{ {
return getIntProperty(null, property, defaultValue); return new DSpace().getConfigurationService().getIntProperty(property, defaultValue);
} }
/** /**
@@ -279,22 +192,13 @@ public class ConfigurationManager
*/ */
public static int getIntProperty(String module, String property, int defaultValue) public static int getIntProperty(String module, String property, int defaultValue)
{ {
String stringValue = getProperty(module, property); if (module == null)
int intValue = defaultValue; {
return getIntProperty(property, defaultValue);
if (stringValue != null)
{
try
{
intValue = Integer.parseInt(stringValue.trim());
}
catch (NumberFormatException e)
{
warn("Warning: Number format error in property: " + property);
}
} }
return intValue; // Assume "module" properties are always prefixed with the module name
return getIntProperty(module + "." + property, defaultValue);
} }
/** /**
@@ -309,7 +213,7 @@ public class ConfigurationManager
*/ */
public static long getLongProperty(String property) public static long getLongProperty(String property)
{ {
return getLongProperty(property, 0); return new DSpace().getConfigurationService().getLongProperty(property);
} }
/** /**
@@ -326,7 +230,13 @@ public class ConfigurationManager
*/ */
public static long getLongProperty(String module, String property) public static long getLongProperty(String module, String property)
{ {
return getLongProperty(module, property, 0); if (module == null)
{
return getLongProperty(property);
}
// Assume "module" properties are always prefixed with the module name
return getLongProperty(module + "." + property);
} }
/** /**
@@ -346,7 +256,7 @@ public class ConfigurationManager
*/ */
public static long getLongProperty(String property, int defaultValue) public static long getLongProperty(String property, int defaultValue)
{ {
return getLongProperty(null, property, defaultValue); return new DSpace().getConfigurationService().getLongProperty(property, defaultValue);
} }
/** /**
@@ -367,22 +277,13 @@ public class ConfigurationManager
*/ */
public static long getLongProperty(String module, String property, int defaultValue) public static long getLongProperty(String module, String property, int defaultValue)
{ {
String stringValue = getProperty(module, property); if (module == null)
long longValue = defaultValue;
if (stringValue != null)
{ {
try return getLongProperty(property, defaultValue);
{
longValue = Long.parseLong(stringValue.trim());
}
catch (NumberFormatException e)
{
warn("Warning: Number format error in property: " + property);
}
} }
return longValue; // Assume "module" properties are always prefixed with the module name
return getLongProperty(module + "." + property, defaultValue);
} }
/** /**
@@ -400,7 +301,7 @@ public class ConfigurationManager
*/ */
public static boolean getBooleanProperty(String property) public static boolean getBooleanProperty(String property)
{ {
return getBooleanProperty(property, false); return new DSpace().getConfigurationService().getBooleanProperty(property);
} }
/** /**
@@ -420,7 +321,13 @@ public class ConfigurationManager
*/ */
public static boolean getBooleanProperty(String module, String property) public static boolean getBooleanProperty(String module, String property)
{ {
return getBooleanProperty(module, property, false); if (module == null)
{
return getBooleanProperty(property);
}
// Assume "module" properties are always prefixed with the module name
return getBooleanProperty(module + "." + property);
} }
/** /**
@@ -442,7 +349,7 @@ public class ConfigurationManager
*/ */
public static boolean getBooleanProperty(String property, boolean defaultValue) public static boolean getBooleanProperty(String property, boolean defaultValue)
{ {
return getBooleanProperty(null, property, defaultValue); return new DSpace().getConfigurationService().getBooleanProperty(property, defaultValue);
} }
/** /**
@@ -466,18 +373,13 @@ public class ConfigurationManager
*/ */
public static boolean getBooleanProperty(String module, String property, boolean defaultValue) public static boolean getBooleanProperty(String module, String property, boolean defaultValue)
{ {
String stringValue = getProperty(module, property); if (module == null)
{
return getBooleanProperty(property, defaultValue);
}
if (stringValue != null) // Assume "module" properties are always prefixed with the module name
{ return getBooleanProperty(module + "." + property, defaultValue);
stringValue = stringValue.trim();
return stringValue.equalsIgnoreCase("true") ||
stringValue.equalsIgnoreCase("yes");
}
else
{
return defaultValue;
}
} }
/** /**
@@ -487,7 +389,8 @@ public class ConfigurationManager
*/ */
public static Enumeration<?> propertyNames() public static Enumeration<?> propertyNames()
{ {
return propertyNames(null); // Get a list of all property keys, and convert into an Enumeration
return java.util.Collections.enumeration(new DSpace().getConfigurationService().getPropertyKeys());
} }
/** /**
@@ -500,398 +403,8 @@ public class ConfigurationManager
*/ */
public static Enumeration<?> propertyNames(String module) public static Enumeration<?> propertyNames(String module)
{ {
Properties props = getProperties(module); // Get property keys beginning with this prefix, and convert into an Enumeration
return props == null ? null : props.propertyNames(); return java.util.Collections.enumeration(new DSpace().getConfigurationService().getPropertyKeys(module));
}
/** The configuration that was loaded. */
private static File loadedFile = null;
/**
* Return the file that configuration was actually loaded from.
*
* @deprecated Please remove all direct usage of the configuration file.
* @return File naming configuration data file.
*/
protected static File getConfigurationFile()
{
// in case it hasn't been done yet.
if (loadedFile == null)
{
loadConfig(null);
}
return loadedFile;
}
private static synchronized void loadModuleConfig(String module)
{
// try to find it in modules
File modFile = null;
try
{
modFile = new File(getProperty("dspace.dir") +
File.separator + "config" +
File.separator + "modules" +
File.separator + module + ".cfg");
if (modFile.exists())
{
Properties modProps = new Properties();
InputStream modIS = null;
InputStreamReader modIR = null;
try
{
modIS = new FileInputStream(modFile);
modIR = new InputStreamReader(modIS, "UTF-8");
modProps.load(modIR);
}
finally
{
if (modIR != null)
{
modIR.close();
}
if (modIS != null)
{
modIS.close();
}
}
for (Enumeration pe = modProps.propertyNames(); pe.hasMoreElements(); )
{
String key = (String)pe.nextElement();
String ival = interpolate(key, modProps.getProperty(key), 1);
if (ival != null)
{
modProps.setProperty(key, ival);
}
}
moduleProps.put(module, modProps);
}
else
{
// log invalid request
warn("Requested configuration module: " + module + " not found");
}
}
catch (IOException ioE)
{
fatal("Can't load configuration: " +
(modFile == null ? "<unknown>" : modFile.getAbsolutePath()), ioE);
}
}
/**
* Load the DSpace configuration properties. Only does anything if
* properties are not already loaded. Properties are loaded in from the
* specified file, or default locations.
*
* @param configFile
* The <code>dspace.cfg</code> configuration file to use, or
* <code>null</code> to try default locations
*/
public static synchronized void loadConfig(String configFile)
{
if (properties != null)
{
return;
}
URL url = null;
InputStream is = null;
InputStreamReader reader = null;
try
{
String configProperty = null;
try
{
configProperty = System.getProperty("dspace.configuration");
}
catch (SecurityException se)
{
// A security manager may stop us from accessing the system properties.
// This isn't really a fatal error though, so catch and ignore
log.warn("Unable to access system properties, ignoring.", se);
}
// should only occur after a flush()
if (loadedFile != null)
{
info("Reloading current config file: " + loadedFile.getAbsolutePath());
url = loadedFile.toURI().toURL();
}
else if (configFile != null)
{
info("Loading provided config file: " + configFile);
loadedFile = new File(configFile);
url = loadedFile.toURI().toURL();
}
// Has the default configuration location been overridden?
else if (configProperty != null)
{
info("Loading system provided config property (-Ddspace.configuration): " + configProperty);
// Load the overriding configuration
loadedFile = new File(configProperty);
url = loadedFile.toURI().toURL();
}
// Load configuration from default location
else
{
url = ConfigurationManager.class.getResource("/dspace.cfg");
if (url != null)
{
info("Loading from classloader: " + url);
loadedFile = new File(url.getPath());
}
}
if (url == null)
{
fatal("Cannot find dspace.cfg");
throw new IllegalStateException("Cannot find dspace.cfg");
}
else
{
properties = new Properties();
is = url.openStream();
reader = new InputStreamReader(is, "UTF-8");
properties.load(reader);
// walk values, interpolating any embedded references.
for (Enumeration<?> pe = properties.propertyNames(); pe.hasMoreElements(); )
{
String key = (String)pe.nextElement();
String value = interpolate(key, properties.getProperty(key), 1);
if (value != null)
{
properties.setProperty(key, value);
}
}
}
}
catch (IOException e)
{
fatal("Can't load configuration: " + url, e);
// FIXME: Maybe something more graceful here, but without a
// configuration we can't do anything.
throw new IllegalStateException("Cannot load configuration: " + url, e);
}
finally
{
if (reader != null)
{
try {
reader.close();
}
catch (IOException ioe)
{
}
}
if (is != null)
{
try
{
is.close();
}
catch (IOException ioe)
{
}
}
}
try
{
/*
* Initialize Logging once ConfigurationManager is initialized.
*
* This is controlled by a property in dspace.cfg. If the property
* is absent then nothing will be configured and the application
* will use the defaults provided by log4j.
*
* Property format is:
*
* log.init.config = ${dspace.dir}/config/log4j.properties
* or
* log.init.config = ${dspace.dir}/config/log4j.xml
*
* See default log4j initialization documentation here:
* http://logging.apache.org/log4j/docs/manual.html
*
* If there is a problem with the file referred to in
* "log.configuration", it needs to be sent to System.err
* so do not instantiate another Logging configuration.
*
*/
String dsLogConfiguration = ConfigurationManager.getProperty("log.init.config");
if (dsLogConfiguration == null || System.getProperty("dspace.log.init.disable") != null)
{
/*
* Do nothing if log config not set in dspace.cfg or "dspace.log.init.disable"
* system property set. Leave it upto log4j to properly init its logging
* via classpath or system properties.
*/
info("Using default log4j provided log configuration." +
" If unintended, check your dspace.cfg for (log.init.config)");
}
else
{
info("Using dspace provided log configuration (log.init.config)");
File logConfigFile = new File(dsLogConfiguration);
if(logConfigFile.exists())
{
info("Loading: " + dsLogConfiguration);
OptionConverter.selectAndConfigure(logConfigFile.toURI()
.toURL(), null, org.apache.log4j.LogManager
.getLoggerRepository());
}
else
{
info("File does not exist: " + dsLogConfiguration);
}
}
}
catch (MalformedURLException e)
{
fatal("Can't load dspace provided log4j configuration", e);
throw new IllegalStateException("Cannot load dspace provided log4j configuration",e);
}
}
/**
* Wrapper for {@link NewsService#getNewsFilePath()}.
* @deprecated since 4.0
*/
public static String getNewsFilePath()
{
return CoreServiceFactory.getInstance().getNewsService().getNewsFilePath();
}
/**
* Wrapper for {@link NewsService#readNewsFile(java.lang.String)}.
* @deprecated since 4.0
*/
public static String readNewsFile(String name)
{
return CoreServiceFactory.getInstance().getNewsService().readNewsFile(name);
}
/**
* Wrapper for {@link NewsService#writeNewsFile(java.lang.String, java.lang.String)}.
* @deprecated since 4.0
*/
public static String writeNewsFile(String file, String news)
{
return CoreServiceFactory.getInstance().getNewsService().writeNewsFile(file, news);
}
/**
* Wrapper for {@link LicenseService#getLicenseText(java.lang.String)}.
* @deprecated since 4.0
*/
public static String getLicenseText(String licenseFile)
{
return CoreServiceFactory.getInstance().getLicenseService().getLicenseText(licenseFile);
}
/**
* Wrapper for {@link LicenseService#getDefaultSubmissionLicense()}.
* @deprecated since 4.0
*/
public static String getDefaultSubmissionLicense()
{
return CoreServiceFactory.getInstance().getLicenseService().getDefaultSubmissionLicense();
}
/**
* Wrapper for {@link LicenseService#writeLicenseFile(java.lang.String, java.lang.String)}.
* @deprecated since 4.0
*/
public static void writeLicenseFile(String licenseFile, String newLicense)
{
CoreServiceFactory.getInstance().getLicenseService().writeLicenseFile(licenseFile, newLicense);
}
/**
* Recursively interpolate variable references in value of
* property named "key".
* @return new value if it contains interpolations, or null
* if it had no variable references.
*/
private static String interpolate(String key, String value, int level)
{
if (level > RECURSION_LIMIT)
{
throw new IllegalArgumentException("ConfigurationManager: Too many levels of recursion in configuration property variable interpolation, property=" + key);
}
//String value = (String)properties.get(key);
int from = 0;
StringBuffer result = null;
while (from < value.length())
{
int start = value.indexOf("${", from);
if (start >= 0)
{
int end = value.indexOf('}', start);
if (end < 0)
{
break;
}
String var = value.substring(start+2, end);
if (result == null)
{
result = new StringBuffer(value.substring(from, start));
}
else
{
result.append(value.substring(from, start));
}
if (properties.containsKey(var))
{
String ivalue = interpolate(var, properties.getProperty(var), level+1);
if (ivalue != null)
{
result.append(ivalue);
properties.setProperty(var, ivalue);
}
else
{
result.append(((String)properties.getProperty(var)).trim());
}
}
else
{
log.warn("Interpolation failed in value of property \""+key+
"\", there is no property named \""+var+"\"");
}
from = end+1;
}
else
{
break;
}
}
if (result != null && from < value.length())
{
result.append(value.substring(from));
}
return (result == null) ? null : result.toString();
} }
/** /**
@@ -947,82 +460,4 @@ public class ConfigurationManager
System.exit(1); System.exit(1);
} }
private static void info(String string)
{
if (!isLog4jConfigured())
{
System.out.println("INFO: " + string);
}
else
{
log.info(string);
}
}
private static void warn(String string)
{
if (!isLog4jConfigured())
{
System.out.println("WARN: " + string);
}
else
{
log.warn(string);
}
}
private static void fatal(String string, Exception e)
{
if (!isLog4jConfigured())
{
System.out.println("FATAL: " + string);
e.printStackTrace();
}
else
{
log.fatal(string, e);
}
}
private static void fatal(String string)
{
if (!isLog4jConfigured())
{
System.out.println("FATAL: " + string);
}
else
{
log.fatal(string);
}
}
/*
* Only current solution available to detect
* if log4j is truly configured.
*/
private static boolean isLog4jConfigured()
{
Enumeration<?> en = org.apache.log4j.LogManager.getRootLogger()
.getAllAppenders();
if (!(en instanceof org.apache.log4j.helpers.NullEnumeration))
{
return true;
}
else
{
Enumeration<?> cats = Category.getCurrentCategories();
while (cats.hasMoreElements())
{
Category c = (Category) cats.nextElement();
if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration))
{
return true;
}
}
}
return false;
}
} }

View File

@@ -8,21 +8,20 @@
package org.dspace.core; package org.dspace.core;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.utils.DSpace;
/** /**
* The Plugin Manager is a very simple component container. It creates and * The Plugin Manager is a very simple component container. It creates and
@@ -742,118 +741,34 @@ public class PluginManager
Map<String, String> reusableKey = new HashMap<String, String>(); Map<String, String> reusableKey = new HashMap<String, String>();
HashMap<String, String> keyMap = new HashMap<String, String>(); HashMap<String, String> keyMap = new HashMap<String, String>();
// 1. First pass -- grovel the actual config file to check for // Find all property keys starting with "plugin."
// duplicate keys, since Properties class hides them from us. List<String> keys = new DSpace().getConfigurationService().getPropertyKeys("plugin.");
// Also build lists of each type of key, check for misspellings.
File config = ConfigurationManager.getConfigurationFile();
try
{
fr = new FileReader(config);
cr = new BufferedReader(fr);
String line = null;
boolean continued = false;
Pattern keyPattern = Pattern.compile("([^\\s\\=\\:]+)");
while ((line = cr.readLine()) != null)
{
line = line.trim();
if (line.startsWith("!") || line.startsWith("#"))
{
continued = false;
}
else
{
if (!continued && line.startsWith("plugin."))
{
Matcher km = keyPattern.matcher(line);
if (km.find())
{
String key = line.substring(0, km.end(1));
if (keyMap.containsKey(key))
{
log.error("Duplicate key \"" + key + "\" in DSpace configuration file=" + config.toString());
}
else
{
keyMap.put(key, key);
}
if (key.startsWith(SINGLE_PREFIX)) for(String key : keys)
{
singleKey.put(key.substring(SINGLE_PREFIX.length()), key);
}
else if (key.startsWith(SEQUENCE_PREFIX))
{
sequenceKey.put(key.substring(SEQUENCE_PREFIX.length()), key);
}
else if (key.startsWith(NAMED_PREFIX))
{
namedKey.put(key.substring(NAMED_PREFIX.length()), key);
}
else if (key.startsWith(SELFNAMED_PREFIX))
{
selfnamedKey.put(key.substring(SELFNAMED_PREFIX.length()), key);
}
else if (key.startsWith(REUSABLE_PREFIX))
{
reusableKey.put(key.substring(REUSABLE_PREFIX.length()), key);
}
else
{
log.error("Key with unknown prefix \"" + key + "\" in DSpace configuration file=" + config.toString());
}
}
}
continued = line.length() > 0 && line.charAt(line.length()-1) == '\\';
}
}
}
finally
{ {
if (cr != null) if (key.startsWith(SINGLE_PREFIX))
{ {
try singleKey.put(key.substring(SINGLE_PREFIX.length()), key);
{
cr.close();
}
catch (IOException ioe)
{
}
} }
else if (key.startsWith(SEQUENCE_PREFIX))
if (fr != null)
{ {
try sequenceKey.put(key.substring(SEQUENCE_PREFIX.length()), key);
{
fr.close();
}
catch (IOException ioe)
{
}
} }
} else if (key.startsWith(NAMED_PREFIX))
// 1.1 Sanity check, make sure keyMap == set of keys from Configuration
Enumeration<String> pne = (Enumeration<String>)ConfigurationManager.propertyNames();
HashSet<String> pn = new HashSet<String>();
while (pne.hasMoreElements())
{
String nk = pne.nextElement();
if (nk.startsWith("plugin."))
{ {
pn.add(nk); namedKey.put(key.substring(NAMED_PREFIX.length()), key);
if (!keyMap.containsKey(nk))
{
log.error("Key is in ConfigurationManager.propertyNames() but NOT text crawl: \"" + nk + "\"");
}
} }
} else if (key.startsWith(SELFNAMED_PREFIX))
Iterator<String> pi = keyMap.keySet().iterator();
while (pi.hasNext())
{
String key = pi.next();
if (!pn.contains(key))
{ {
log.error("Key is in text crawl but NOT ConfigurationManager.propertyNames(): \"" + key + "\""); selfnamedKey.put(key.substring(SELFNAMED_PREFIX.length()), key);
}
else if (key.startsWith(REUSABLE_PREFIX))
{
reusableKey.put(key.substring(REUSABLE_PREFIX.length()), key);
}
else
{
log.error("Key with unknown prefix \"" + key + "\" in DSpace configuration");
} }
} }

View File

@@ -41,7 +41,7 @@ public class MicrosoftTranslator extends AbstractTranslator
@Override @Override
protected void initApi() { protected void initApi() {
apiKey = ConfigurationManager.getProperty(PLUGIN_PREFIX, "translate.api.key.microsoft"); apiKey = ConfigurationManager.getProperty(PLUGIN_PREFIX, "api.key.microsoft");
} }
@Override @Override

View File

@@ -20,7 +20,6 @@ import org.dspace.app.util.MockUtil;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.factory.AuthorizeServiceFactory; import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.AuthorizeService; import org.dspace.authorize.service.AuthorizeService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.I18nUtil; import org.dspace.core.I18nUtil;
import org.dspace.discovery.MockIndexEventConsumer; import org.dspace.discovery.MockIndexEventConsumer;
@@ -100,14 +99,11 @@ public class AbstractUnitTest
.getResource("test-config.properties"); .getResource("test-config.properties");
testProps.load(properties.openStream()); testProps.load(properties.openStream());
//load the test configuration file
ConfigurationManager.loadConfig(null);
// Initialise the service manager kernel // Initialise the service manager kernel
kernelImpl = DSpaceKernelInit.getKernel(null); kernelImpl = DSpaceKernelInit.getKernel(null);
if (!kernelImpl.isRunning()) if (!kernelImpl.isRunning())
{ {
kernelImpl.start(ConfigurationManager.getProperty("dspace.dir")); kernelImpl.start(System.getProperty("dspace.dir")); // init the kernel
} }
// Clear our old flyway object. Because this DB is in-memory, its // Clear our old flyway object. Because this DB is in-memory, its
// data is lost when the last connection is closed. So, we need // data is lost when the last connection is closed. So, we need

View File

@@ -10,6 +10,7 @@ package org.dspace.content.authority;
import java.io.IOException; import java.io.IOException;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.AbstractUnitTest;
import org.dspace.core.PluginManager; import org.dspace.core.PluginManager;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@@ -20,7 +21,7 @@ import org.junit.*;
* *
* @author mwood * @author mwood
*/ */
public class DSpaceControlledVocabularyTest public class DSpaceControlledVocabularyTest extends AbstractUnitTest
{ {
public DSpaceControlledVocabularyTest() public DSpaceControlledVocabularyTest()
{ {

View File

@@ -93,7 +93,7 @@ public class DOIIdentifierProviderTest
//we need to commit the changes so we don't block the table for testing //we need to commit the changes so we don't block the table for testing
context.restoreAuthSystemState(); context.restoreAuthSystemState();
config = kernelImpl.getConfigurationService(); config = new DSpace().getConfigurationService();
// Configure the service under test. // Configure the service under test.
config.setProperty(DOIIdentifierProvider.CFG_PREFIX, PREFIX); config.setProperty(DOIIdentifierProvider.CFG_PREFIX, PREFIX);
config.setProperty(DOIIdentifierProvider.CFG_NAMESPACE_SEPARATOR, config.setProperty(DOIIdentifierProvider.CFG_NAMESPACE_SEPARATOR,

View File

@@ -126,8 +126,8 @@ public class EZIDIdentifierProviderTest
public static void setUpClass() public static void setUpClass()
throws Exception throws Exception
{ {
// Find the usual kernel services // Find the configuration service
config = kernelImpl.getConfigurationService(); config = new DSpace().getConfigurationService();
// Configure the service under test. // Configure the service under test.
config.setProperty(EZIDIdentifierProvider.CFG_SHOULDER, TEST_SHOULDER); config.setProperty(EZIDIdentifierProvider.CFG_SHOULDER, TEST_SHOULDER);

View File

@@ -1,78 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.webui.servlet;
import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
import javax.servlet.http.HttpServlet;
import java.net.URL;
import java.net.URLConnection;
/**
* Simple servlet to load in DSpace and log4j configurations. Should always be
* started up before other servlets (use <loadOnStartup>)
*
* This class holds code to be removed in the next version of the DSpace XMLUI,
* it is now managed by a Shared Context Listener inthe dspace-api project.
*
* It is deprecated, rather than removed to maintain backward compatibility for
* local DSpace 1.5.x customized overlays.
*
* TODO: Remove in trunk
*
* @deprecated Use Servlet Context Listener provided in dspace-api (remove in >
* 1.5.x)
* @author Robert Tansley
* @version $Revision$
*/
public class LoadDSpaceConfig extends HttpServlet
{
private static final Logger LOG = Logger.getLogger(LoadDSpaceConfig.class);
public void init()
{
// On Windows, URL caches can cause problems, particularly with undeployment
// So, here we attempt to disable them if we detect that we are running on Windows
try
{
String osName = System.getProperty("os.name");
if (osName != null)
{
osName = osName.toLowerCase();
}
if (osName != null && osName.contains("windows"))
{
URL url = new URL("http://localhost/");
URLConnection urlConn = url.openConnection();
urlConn.setDefaultUseCaches(false);
}
}
// Any errors thrown in disabling the caches aren't significant to
// the normal execution of the application, so we ignore them
catch (RuntimeException e)
{
LOG.error(e.getMessage(), e);
}
catch (Exception e)
{
LOG.error(e.getMessage(), e);
}
if(!ConfigurationManager.isConfigured())
{
// Get config parameter
String config = getServletContext().getInitParameter("dspace-config");
// Load in DSpace config
ConfigurationManager.loadConfig(config);
}
}
}

View File

@@ -21,21 +21,10 @@
<display-name>DSpace Web UI</display-name> <display-name>DSpace Web UI</display-name>
<!-- ConfigurationService initialization for dspace.dir -->
<!-- Configuration Information -->
<context-param> <context-param>
<description> <description>
The location of the main DSpace configuration file The location of the DSpace home directory.
</description>
<param-name>dspace-config</param-name>
<param-value>${dspace.dir}/config/dspace.cfg</param-value>
</context-param>
<!-- new ConfigurationService initialization for dspace.dir -->
<context-param>
<description>
The location of the main DSpace configuration file
</description> </description>
<param-name>dspace.dir</param-name> <param-name>dspace.dir</param-name>
<param-value>${dspace.dir}</param-value> <param-value>${dspace.dir}</param-value>

View File

@@ -12,21 +12,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>XOAI Data Provider</display-name> <display-name>XOAI Data Provider</display-name>
<context-param>
<description>
The location of the main DSpace configuration file
</description>
<param-name>dspace-config</param-name>
<param-value>${dspace.dir}/config/dspace.cfg</param-value>
</context-param>
<context-param> <context-param>
<description>The location of the main DSpace configuration file</description> <description>The location of the DSpace home directory</description>
<param-name>dspace.dir</param-name> <param-name>dspace.dir</param-name>
<param-value>${dspace.dir}</param-value> <param-value>${dspace.dir}</param-value>
</context-param> </context-param>
<!-- Location of root application context configs (to be loaded by ContextLoaderListener below) --> <!-- Location of root application context configs (to be loaded by ContextLoaderListener below) -->

View File

@@ -15,16 +15,10 @@
id="WebApp_ID" version="2.5"> id="WebApp_ID" version="2.5">
<display-name>RDF Data Provider</display-name> <display-name>RDF Data Provider</display-name>
<context-param> <context-param>
<description> <description>
The location of the main DSpace configuration file The location of the DSpace home directory
</description>
<param-name>dspace-config</param-name>
<param-value>${dspace.dir}/config/dspace.cfg</param-value>
</context-param>
<context-param>
<description>
The location of the main DSpace configuration file
</description> </description>
<param-name>dspace.dir</param-name> <param-name>dspace.dir</param-name>
<param-value>${dspace.dir}</param-value> <param-value>${dspace.dir}</param-value>

View File

@@ -58,16 +58,10 @@
</user-data-constraint> </user-data-constraint>
</security-constraint> </security-constraint>
<!-- DSpace Configuration Information --> <!-- ConfigurationService initialization for dspace.dir -->
<context-param>
<param-name>dspace-config</param-name>
<param-value>${dspace.dir}/config/dspace.cfg</param-value>
</context-param>
<!-- new ConfigurationService initialization for dspace.dir -->
<context-param> <context-param>
<description> <description>
The location of the main DSpace configuration file The location of the DSpace home directory
</description> </description>
<param-name>dspace.dir</param-name> <param-name>dspace.dir</param-name>
<param-value>${dspace.dir}</param-value> <param-value>${dspace.dir}</param-value>

View File

@@ -42,7 +42,6 @@ public final class DSpaceConfigurationService implements ConfigurationService {
private static final Logger log = LoggerFactory.getLogger(DSpaceConfigurationService.class); private static final Logger log = LoggerFactory.getLogger(DSpaceConfigurationService.class);
//public static final String DSPACE_WEB_CONTEXT_PARAM = "dspace-config";
public static final String DSPACE = "dspace"; public static final String DSPACE = "dspace";
public static final String EXT_CONFIG = "cfg"; public static final String EXT_CONFIG = "cfg";
public static final String DOT_CONFIG = "." + EXT_CONFIG; public static final String DOT_CONFIG = "." + EXT_CONFIG;

View File

@@ -1,45 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.sword;
import javax.servlet.http.HttpServlet;
import org.dspace.core.ConfigurationManager;
/**
* Simple servlet to load in DSpace and log4j configurations. Should always be
* started up before other servlets (use <loadOnStartup>)
*
* This class holds code to be removed in the next version of the DSpace XMLUI,
* it is now managed by a Shared Context Listener inthe dspace-api project.
*
* It is deprecated, rather than removed to maintain backward compatibility for
* local DSpace 1.5.x customized overlays.
*
* TODO: Remove in trunk
*
* @deprecated Use Servlet Context Listener provided in dspace-api (remove in >
* 1.5.x)
*
* @author Robert Tansley
*/
public class LoadDSpaceConfig extends HttpServlet
{
public void init()
{
if (!ConfigurationManager.isConfigured())
{
// Get config parameter
String config = getServletContext()
.getInitParameter("dspace-config");
// Load in DSpace config
ConfigurationManager.loadConfig(config);
}
}
}

View File

@@ -13,26 +13,15 @@
<display-name>DSpace SWORD Server</display-name> <display-name>DSpace SWORD Server</display-name>
<!-- Configuration Information --> <!-- ConfigurationService initialization for dspace.dir -->
<context-param>
<param-name>dspace-config</param-name>
<param-value>${dspace.dir}/config/dspace.cfg</param-value>
<description>
The location of the main DSpace configuration file
</description>
</context-param>
<!-- new ConfigurationService initialization for dspace.dir -->
<context-param> <context-param>
<param-name>dspace.dir</param-name> <param-name>dspace.dir</param-name>
<param-value>${dspace.dir}</param-value> <param-value>${dspace.dir}</param-value>
<description> <description>
The location of the main DSpace configuration file The location of the DSpace home directory
</description> </description>
</context-param> </context-param>
<context-param> <context-param>
<param-name>sword-server-class</param-name> <param-name>sword-server-class</param-name>
<param-value>org.dspace.sword.DSpaceSWORDServer</param-value> <param-value>org.dspace.sword.DSpaceSWORDServer</param-value>

View File

@@ -14,20 +14,12 @@
<display-name>DSpace SWORD 2.0 Server</display-name> <display-name>DSpace SWORD 2.0 Server</display-name>
<context-param> <!-- ConfigurationService initialization for dspace.dir -->
<param-name>dspace-config</param-name>
<param-value>${dspace.dir}/config/dspace.cfg</param-value>
<description>
The location of the main DSpace configuration file
</description>
</context-param>
<!-- new ConfigurationService initialization for dspace.dir -->
<context-param> <context-param>
<param-name>dspace.dir</param-name> <param-name>dspace.dir</param-name>
<param-value>${dspace.dir}</param-value> <param-value>${dspace.dir}</param-value>
<description> <description>
The location of the main DSpace directory The location of the DSpace home directory
</description> </description>
</context-param> </context-param>

View File

@@ -9,9 +9,6 @@ package org.dspace.app.xmlui.cocoon;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.SocketException;
import java.net.URL;
import java.net.URLConnection;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
@@ -27,7 +24,6 @@ import org.dspace.app.xmlui.configuration.XMLUIConfiguration;
import org.dspace.app.xmlui.utils.AuthenticationUtil; import org.dspace.app.xmlui.utils.AuthenticationUtil;
import org.dspace.app.xmlui.utils.ContextUtil; import org.dspace.app.xmlui.utils.ContextUtil;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.harvest.OAIHarvester;
import org.dspace.harvest.factory.HarvestServiceFactory; import org.dspace.harvest.factory.HarvestServiceFactory;
import org.dspace.harvest.service.HarvestSchedulingService; import org.dspace.harvest.service.HarvestSchedulingService;
@@ -43,127 +39,14 @@ public class DSpaceCocoonServletFilter implements Filter
private static final Logger LOG = Logger.getLogger(DSpaceCocoonServletFilter.class); private static final Logger LOG = Logger.getLogger(DSpaceCocoonServletFilter.class);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected HarvestSchedulingService harvestSchedulingService = HarvestServiceFactory.getInstance().getHarvestSchedulingService(); protected HarvestSchedulingService harvestSchedulingService = HarvestServiceFactory.getInstance().getHarvestSchedulingService();
/**
* The DSpace config paramater, this is where the path to the DSpace
* configuration file can be obtained
*/
public static final String DSPACE_CONFIG_PARAMETER = "dspace-config";
/**
* This method holds code to be removed in the next version
* of the DSpace XMLUI, it is now managed by a Shared Context
* Listener in the dspace-api project.
*
* It is deprecated, rather than removed to maintain backward
* compatibility for local DSpace 1.5.x customized overlays.
*
* TODO: Remove in trunk
*
* @deprecated Use Servlet Context Listener provided
* in dspace-api (remove in > 1.5.x)
* @throws ServletException
*/
private void initDSpace(FilterConfig arg0) throws ServletException
{
// On Windows, URL caches can cause problems, particularly with undeployment
// So, here we attempt to disable them if we detect that we are running on Windows
try
{
String osName = System.getProperty("os.name");
if (osName != null)
{
osName = osName.toLowerCase();
}
if (osName != null && osName.contains("windows"))
{
URL url = new URL("http://localhost/");
URLConnection urlConn = url.openConnection();
urlConn.setDefaultUseCaches(false);
}
}
// Any errors thrown in disabling the caches aren't significant to
// the normal execution of the application, so we ignore them
catch (RuntimeException e)
{
LOG.error(e.getMessage(), e);
}
catch (Exception e)
{
LOG.error(e.getMessage(), e);
}
/**
* Previous stages moved to shared ServletListener available in dspace-api
*/
String dspaceConfig = null;
/**
* Stage 1
*
* Locate the dspace config
*/
// first check the local per-webapp parameter, then check the global parameter.
dspaceConfig = arg0.getInitParameter(DSPACE_CONFIG_PARAMETER);
if (dspaceConfig == null)
{
dspaceConfig = arg0.getServletContext().getInitParameter(DSPACE_CONFIG_PARAMETER);
}
// Finally, if no config parameter found throw an error
if (dspaceConfig == null || "".equals(dspaceConfig))
{
throw new ServletException(
"\n\nDSpace has failed to initialize. This has occurred because it was unable to determine \n" +
"where the dspace.cfg file is located. The path to the configuration file should be stored \n" +
"in a context variable, '"+DSPACE_CONFIG_PARAMETER+"', in either the local servlet or global contexts. \n" +
"No context variable was found in either location.\n\n");
}
/**
* Stage 2
*
* Load the dspace config. Also may load log4j configuration.
* (Please rely on ConfigurationManager or Log4j to configure logging)
*
*/
try
{
if(!ConfigurationManager.isConfigured())
{
// Load in DSpace config
ConfigurationManager.loadConfig(dspaceConfig);
}
}
catch (RuntimeException e)
{
throw e;
}
catch (Exception e)
{
throw new ServletException(
"\n\nDSpace has failed to initialize, during stage 2. Error while attempting to read the \n" +
"DSpace configuration file (Path: '"+dspaceConfig+"'). \n" +
"This has likely occurred because either the file does not exist, or its permissions \n" +
"are set incorrectly, or the path to the configuration file is incorrect. The path to \n" +
"the DSpace configuration file is stored in a context variable, 'dspace-config', in \n" +
"either the local servlet or global context.\n\n",e);
}
}
/** /**
* Before this servlet will become functional replace * Before this servlet will become functional replace
*/ */
public void init(FilterConfig arg0) throws ServletException { public void init(FilterConfig arg0) throws ServletException {
this.initDSpace(arg0);
// Paths to the various config files // Paths to the various config files
String webappConfigPath = null; String webappConfigPath = null;
String installedConfigPath = null; String installedConfigPath = null;

View File

@@ -33,17 +33,10 @@
<description>An override of the session cookie path</description> <description>An override of the session cookie path</description>
</context-param--> </context-param-->
<!-- ConfigurationService initialization for dspace.dir -->
<!-- DSpace Configuration Information -->
<context-param>
<param-name>dspace-config</param-name>
<param-value>${dspace.dir}/config/dspace.cfg</param-value>
</context-param>
<!-- new ConfigurationService initialization for dspace.dir -->
<context-param> <context-param>
<description> <description>
The location of the main DSpace configuration file The location of the DSpace home directory
</description> </description>
<param-name>dspace.dir</param-name> <param-name>dspace.dir</param-name>
<param-value>${dspace.dir}</param-value> <param-value>${dspace.dir}</param-value>

View File

@@ -793,7 +793,7 @@ Common usage:
<java classname="org.dspace.app.launcher.ScriptLauncher" classpathref="class.path" fork="yes" failonerror="yes"> <java classname="org.dspace.app.launcher.ScriptLauncher" classpathref="class.path" fork="yes" failonerror="yes">
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" /> <sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
<sysproperty key="dspace.log.init.disable" value="true" /> <sysproperty key="dspace.log.init.disable" value="true" />
<sysproperty key="dspace.configuration" value="${config}" /> <sysproperty key="dspace.dir" value="${dspace.dir}" />
<arg value="database" /> <arg value="database" />
<arg value="test" /> <arg value="test" />
</java> </java>
@@ -803,7 +803,7 @@ Common usage:
<java classname="org.dspace.app.launcher.ScriptLauncher" classpathref="class.path" fork="yes" failonerror="yes"> <java classname="org.dspace.app.launcher.ScriptLauncher" classpathref="class.path" fork="yes" failonerror="yes">
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" /> <sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
<sysproperty key="dspace.log.init.disable" value="true" /> <sysproperty key="dspace.log.init.disable" value="true" />
<sysproperty key="dspace.configuration" value="${config}" /> <sysproperty key="dspace.dir" value="${dspace.dir}" />
<arg value="database" /> <arg value="database" />
<arg value="migrate" /> <arg value="migrate" />
</java> </java>