Index: /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java =================================================================== --- /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java (revision 422321) +++ /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/ConfigurationParser.java (working copy) @@ -28,7 +28,6 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import java.io.File; import java.io.IOException; import java.util.Properties; @@ -41,7 +40,7 @@ * The following code sample outlines the usage of this class: *
* Properties variables = ...; // parser variables - * ConfigurationParser parser = new ConfigurationParser(variables); + * RepositoryConfigurationParser parser = new RepositoryConfigurationParser(variables); * RepositoryConfig rc = parser.parseRepositoryConfig(...); * WorkspaceConfig wc = parser.parseWorkspaceConfig(...); *@@ -50,45 +49,15 @@ * initialized. The caller needs to initialize the configuration objects * before using them. */ -public class ConfigurationParser { - - /** Name of the repository home directory parser variable. */ - public static final String REPOSITORY_HOME_VARIABLE = "rep.home"; - - /** Name of the workspace home directory parser variable. */ - public static final String WORKSPACE_HOME_VARIABLE = "wsp.home"; - - /** Name of the repository name parser variable. */ - public static final String WORKSPACE_NAME_VARIABLE = "wsp.name"; - - /** Name of the security configuration element. */ - public static final String SECURITY_ELEMENT = "Security"; - - /** Name of the access manager configuration element. */ - public static final String ACCESS_MANAGER_ELEMENT = "AccessManager"; - - /** Name of the login module configuration element. */ - public static final String LOGIN_MODULE_ELEMENT = "LoginModule"; - - /** Name of the general workspace configuration element. */ - public static final String WORKSPACES_ELEMENT = "Workspaces"; - - /** Name of the workspace configuration element. */ - public static final String WORKSPACE_ELEMENT = "Workspace"; +/* + * o.a.j.core.config.ConfigurationParser + * o.a.j.core.config.RepositoryConfigurationParser + * o.a.j.backup.BackupConfigurationParser - /** Name of the versioning configuration element. */ - public static final String VERSIONING_ELEMENT = "Versioning"; - - /** Name of the file system configuration element. */ - public static final String FILE_SYSTEM_ELEMENT = "FileSystem"; - - /** Name of the persistence manager configuration element. */ - public static final String PERSISTENCE_MANAGER_ELEMENT = - "PersistenceManager"; - - /** Name of the search index configuration element. */ - public static final String SEARCH_INDEX_ELEMENT = "SearchIndex"; + */ +public class ConfigurationParser { + /** Name of the bean parameter configuration element. */ public static final String PARAM_ELEMENT = "param"; @@ -100,14 +69,11 @@ /** Name of the config root path configuration attribute. */ public static final String CONFIG_ROOT_PATH_ATTRIBUTE = "configRootPath"; - - /** Name of the maximum idle time configuration attribute. */ - public static final String MAX_IDLE_TIME_ATTRIBUTE = "maxIdleTime"; - - /** Name of the default workspace configuration attribute. */ - public static final String DEFAULT_WORKSPACE_ATTRIBUTE = - "defaultWorkspace"; - + + /** Name of the persistence manager configuration element. */ + public static final String PERSISTENCE_MANAGER_ELEMENT = + "PersistenceManager"; + /** Name of the bean implementation class configuration attribute. */ public static final String CLASS_ATTRIBUTE = "class"; @@ -117,11 +83,7 @@ /** Name of the bean parameter value configuration attribute. */ public static final String VALUE_ATTRIBUTE = "value"; - /** Name of the default search index implementation class. */ - public static final String DEFAULT_QUERY_HANDLER = - "org.apache.jackrabbit.core.query.lucene.SearchIndex"; - - /** + /** * The configuration parser variables. These name-value pairs * are used to substitute
${...} variable references
* with context-dependent values in the configuration.
@@ -147,324 +109,7 @@
return variables;
}
- /**
- * Parses repository configuration. Repository configuration uses the
- * following format:
- * - * <Repository> - * <FileSystem ...> - * <Security appName="..."> - * <AccessManager ...> - * <LoginModule ... (optional)> - * </Security> - * <Workspaces rootPath="..." defaultWorkspace="..."/> - * <Workspace ...> - * <Versioning ...> - * </Repository> - *- *
- * The FileSystem element is a
- * {@link #parseBeanConfig(Element,String) bean configuration} element,
- * that specifies the file system implementation for storing global
- * repository information. The Security element contains
- * an AccessManager bean configuration element and the
- * JAAS name of the repository application. The Workspaces
- * element contains general workspace parameters, and the
- * Workspace element is a template for the individual
- * workspace configuration files. The Versioning element
- * contains
- * {@link #parseVersioningConfig(Element) versioning configuration} for
- * the repository.
- *
- * In addition to the configured information, the returned repository - * configuration object also contains the repository home directory path - * that is given as the ${rep.home} parser variable. Note that the - * variable must be available for the configuration document to - * be correctly parsed. - *
- * {@link #replaceVariables(String) Variable replacement} is performed - * on the security application name attribute, the general workspace - * configuration attributes, and on the file system, access manager, - * and versioning configuration information. - *
- * Note that the returned repository configuration object has not been - * initialized. - * - * @param xml repository configuration document - * @return repository configuration - * @throws ConfigurationException if the configuration is broken - * @see #parseBeanConfig(Element, String) - * @see #parseVersioningConfig(Element) - */ - public RepositoryConfig parseRepositoryConfig(InputSource xml) - throws ConfigurationException { - Element root = parseXML(xml); - - // Repository home directory - String home = variables.getProperty(REPOSITORY_HOME_VARIABLE); - - // File system implementation - FileSystemConfig fsc = - new FileSystemConfig(parseBeanConfig(root, FILE_SYSTEM_ELEMENT)); - - // Security configuration and access manager implementation - Element security = getElement(root, SECURITY_ELEMENT); - SecurityConfig securityConfig = parseSecurityConfig(security); - - // General workspace configuration - Element workspaces = getElement(root, WORKSPACES_ELEMENT); - String workspaceDirectory = replaceVariables( - getAttribute(workspaces, ROOT_PATH_ATTRIBUTE)); - - String workspaceConfigDirectory = - getAttribute(workspaces, CONFIG_ROOT_PATH_ATTRIBUTE, null); - - String defaultWorkspace = replaceVariables( - getAttribute(workspaces, DEFAULT_WORKSPACE_ATTRIBUTE)); - - int maxIdleTime = Integer.parseInt( - getAttribute(workspaces, MAX_IDLE_TIME_ATTRIBUTE, "0")); - - // Workspace configuration template - Element template = getElement(root, WORKSPACE_ELEMENT); - - // Versioning configuration - VersioningConfig vc = parseVersioningConfig(root); - - // Optional search configuration - SearchConfig sc = parseSearchConfig(root); - - return new RepositoryConfig(home, securityConfig, fsc, - workspaceDirectory, workspaceConfigDirectory, defaultWorkspace, - maxIdleTime, template, vc, sc, this); - } - - /** - * Parses security configuration. Security configuration - * uses the following format: - *
- * <Security appName="..."> - * <AccessManager ...> - * <LoginModule ... (optional)> - * </Security> - *- * - * Both the
AccessManager and LoginModule
- * elements are {@link #parseBeanConfig(Element,String) bean configuration}
- * elements.
- *
- * The login module is an optional feature of repository configuration.
- *
- * @param security the <security> element.
- * @return the security configuration.
- * @throws ConfigurationException
- */
- public SecurityConfig parseSecurityConfig(Element security)
- throws ConfigurationException {
- String appName = getAttribute(security, APP_NAME_ATTRIBUTE);
- AccessManagerConfig amc = parseAccessManagerConfig(security);
- LoginModuleConfig lmc = parseLoginModuleConfig(security);
- return new SecurityConfig(appName, amc, lmc);
- }
-
- /**
- * Parses the access manager configuration.
- *
- * @param security the <security> element.
- * @return the access manager configuration.
- * @throws ConfigurationException
- */
- public AccessManagerConfig parseAccessManagerConfig(Element security)
- throws ConfigurationException {
- return new AccessManagerConfig(
- parseBeanConfig(security, ACCESS_MANAGER_ELEMENT));
- }
-
- /**
- * Parses the login module configuration.
- *
- * @param security the <security> element.
- * @return the login module configuration.
- * @throws ConfigurationException
- */
- public LoginModuleConfig parseLoginModuleConfig(Element security)
- throws ConfigurationException {
- // Optional login module
- Element loginModule = getElement(security, LOGIN_MODULE_ELEMENT, false);
-
- if (loginModule != null) {
- return new LoginModuleConfig(parseBeanConfig(security, LOGIN_MODULE_ELEMENT));
- } else {
- return null;
- }
- }
-
- /**
- * Parses workspace configuration. Workspace configuration uses the
- * following format:
- * - * <Workspace name="..."> - * <FileSystem ...> - * <PersistenceManager ...> - * <SearchIndex ...> - * </Workspace> - *- *
- * All the child elements (FileSystem,
- * PersistenceManager, and SearchIndex) are
- * {@link #parseBeanConfig(Element,String) bean configuration} elements.
- * In addition to bean configuration, the
- * {@link #parseSearchConfig(Element) search element} also contains
- * configuration for the search file system.
- *
- * In addition to the configured information, the returned workspace - * configuration object also contains the workspace home directory path - * that is given as the ${wsp.home} parser variable. Note that the - * variable must be available for the configuration document to - * be correctly parsed. - *
- * Variable replacement is performed on the optional workspace name - * attribute. If the name is not given, then the name of the workspace - * home directory is used as the workspace name. Once the name has been - * determined, it will be added as the ${wsp.name} variable in a temporary - * configuration parser that is used to parse the contained configuration - * elements. - *
- * The search index configuration element is optional. If it is not given, - * then the workspace will not have search capabilities. - *
- * Note that the returned workspace configuration object has not been - * initialized. - * - * @param xml workspace configuration document - * @return workspace configuration - * @throws ConfigurationException if the configuration is broken - * @see #parseBeanConfig(Element, String) - * @see #parseSearchConfig(Element) - */ - public WorkspaceConfig parseWorkspaceConfig(InputSource xml) - throws ConfigurationException { - Element root = parseXML(xml); - - // Workspace home directory - String home = variables.getProperty(WORKSPACE_HOME_VARIABLE); - - // Workspace name - String name = - getAttribute(root, NAME_ATTRIBUTE, new File(home).getName()); - - // Create a temporary parser that contains the ${wsp.name} variable - Properties tmpVariables = (Properties) variables.clone(); - tmpVariables.put(WORKSPACE_NAME_VARIABLE, name); - ConfigurationParser tmpParser = createSubParser(tmpVariables); - - // File system implementation - FileSystemConfig fsc = new FileSystemConfig( - tmpParser.parseBeanConfig(root, FILE_SYSTEM_ELEMENT)); - - // Persistence manager implementation - PersistenceManagerConfig pmc = tmpParser.parsePersistenceManagerConfig(root); - - // Search implementation (optional) - SearchConfig sc = tmpParser.parseSearchConfig(root); - - return new WorkspaceConfig(home, name, fsc, pmc, sc); - } - - /** - * Parses search index configuration. Search index configuration - * uses the following format: - *
- * <SearchIndex class="..."> - * <param name="..." value="..."> - * ... - * <FileSystem ...> - * </Search> - *- * - * Both the
SearchIndex and FileSystem
- * elements are {@link #parseBeanConfig(Element,String) bean configuration}
- * elements. If the search implementation class is not given, then
- * a default implementation is used.
- *
- * The search index is an optional feature of workspace configuration.
- * If the search configuration element is not found, then this method
- * returns null.
- *
- * The FileSystem element in a search index configuration is optional.
- * However some implementations may require a FileSystem.
- *
- * @param parent parent of the SearchIndex element
- * @return search configuration, or null
- * @throws ConfigurationException if the configuration is broken
- */
- protected SearchConfig parseSearchConfig(Element parent)
- throws ConfigurationException {
- NodeList children = parent.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE
- && SEARCH_INDEX_ELEMENT.equals(child.getNodeName())) {
- Element element = (Element) child;
-
- // Search implementation class
- String className = getAttribute(
- element, CLASS_ATTRIBUTE, DEFAULT_QUERY_HANDLER);
-
- // Search parameters
- Properties parameters = parseParameters(element);
-
- // Optional file system implementation
- FileSystemConfig fsc = null;
- if (getElement(element, FILE_SYSTEM_ELEMENT, false) != null) {
- fsc = new FileSystemConfig(
- parseBeanConfig(element, FILE_SYSTEM_ELEMENT));
- }
-
- return new SearchConfig(className, parameters, fsc);
- }
- }
- return null;
- }
-
- /**
- * Parses versioning configuration. Versioning configuration uses the
- * following format:
- * - * <Versioning rootPath="..."> - * <FileSystem ...> - * <PersistenceManager ...> - * </Versioning> - *- *
- * Both the FileSystem and PersistenceManager
- * elements are {@link #parseBeanConfig(Element,String) bean configuration}
- * elements. In addition to the bean parameter values,
- * {@link #replaceVariables(String) variable replacement} is performed
- * also on the versioning root path attribute.
- *
- * @param parent parent of the Versioning element
- * @return versioning configuration
- * @throws ConfigurationException if the configuration is broken
- */
- protected VersioningConfig parseVersioningConfig(Element parent)
- throws ConfigurationException {
- Element element = getElement(parent, VERSIONING_ELEMENT);
-
- // Versioning home directory
- String home =
- replaceVariables(getAttribute(element, ROOT_PATH_ATTRIBUTE));
-
- // File system implementation
- FileSystemConfig fsc = new FileSystemConfig(
- parseBeanConfig(element, FILE_SYSTEM_ELEMENT));
-
- // Persistence manager implementation
- PersistenceManagerConfig pmc = parsePersistenceManagerConfig(element);
-
- return new VersioningConfig(home, fsc, pmc);
- }
-
+
/**
* Parses the PersistenceManager config.
*
@@ -692,10 +337,11 @@
* @param variables the variables overlay
* @return a new configuration parser instance
*/
- protected ConfigurationParser createSubParser(Properties variables) {
+ protected RepositoryConfigurationParser createSubParser(Properties variables) {
// overlay the properties
Properties props = new Properties(this.variables);
props.putAll(variables);
- return new ConfigurationParser(props);
+ return new RepositoryConfigurationParser(props);
}
+
}
Index: /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
===================================================================
--- /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java (revision 422321)
+++ /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java (working copy)
@@ -122,7 +122,7 @@
*
* Note that in addition to parsing the repository configuration, this * method also initializes the configuration (creates the configured - * directories, etc.). The {@link ConfigurationParser} class should be + * directories, etc.). The {@link RepositoryConfigurationParser} class should be * used directly to just parse the configuration. * * @param xml repository configuration document @@ -134,8 +134,8 @@ throws ConfigurationException { Properties variables = new Properties(); variables.setProperty( - ConfigurationParser.REPOSITORY_HOME_VARIABLE, home); - ConfigurationParser parser = new ConfigurationParser(variables); + RepositoryConfigurationParser.REPOSITORY_HOME_VARIABLE, home); + RepositoryConfigurationParser parser = new RepositoryConfigurationParser(variables); RepositoryConfig config = parser.parseRepositoryConfig(xml); config.init(); @@ -171,7 +171,7 @@ /** * the default parser */ - private final ConfigurationParser parser; + private final RepositoryConfigurationParser parser; /** * Workspace physical root directory. This directory contains a subdirectory @@ -224,7 +224,7 @@ * @param defaultWorkspace name of the default workspace * @param vc versioning configuration * @param sc search configuration for system search manager. - * @param parser the ConfigurationParser that servers as config factory + * @param parser the RepositoryConfigurationParser that servers as config factory */ public RepositoryConfig(String home, SecurityConfig sec, FileSystemConfig fsc, String workspaceDirectory, String workspaceConfigDirectory, @@ -230,7 +230,7 @@ String workspaceDirectory, String workspaceConfigDirectory, String defaultWorkspace, int workspaceMaxIdleTime, Element template, VersioningConfig vc, SearchConfig sc, - ConfigurationParser parser) { + RepositoryConfigurationParser parser) { workspaces = new HashMap(); this.home = home; this.sec = sec; @@ -347,9 +347,9 @@ Properties variables = new Properties(); variables.setProperty( - ConfigurationParser.WORKSPACE_HOME_VARIABLE, + RepositoryConfigurationParser.WORKSPACE_HOME_VARIABLE, directory.getPath()); - ConfigurationParser localParser = parser.createSubParser(variables); + RepositoryConfigurationParser localParser = parser.createSubParser(variables); return localParser.parseWorkspaceConfig(xml); } catch (FileNotFoundException e) { return null; @@ -395,9 +395,9 @@ } Properties variables = new Properties(); variables.setProperty( - ConfigurationParser.WORKSPACE_HOME_VARIABLE, + RepositoryConfigurationParser.WORKSPACE_HOME_VARIABLE, homeDir.getPath()); - ConfigurationParser localParser = parser.createSubParser(variables); + RepositoryConfigurationParser localParser = parser.createSubParser(variables); return localParser.parseWorkspaceConfig(xml); } catch (FileSystemException e) { throw new ConfigurationException("Failed to load workspace configuration", e); @@ -596,7 +596,7 @@ public WorkspaceConfig createWorkspaceConfig(String name, InputSource template) throws ConfigurationException { - ConfigurationParser parser = new ConfigurationParser(new Properties()); + RepositoryConfigurationParser parser = new RepositoryConfigurationParser(new Properties()); Element workspaceTemplate = parser.parseXML(template); return internalCreateWorkspaceConfig(name, workspaceTemplate); } Index: /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java =================================================================== --- /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java (revision 422320) +++ /home/ntoper/workspace/jackrabbit2/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java (working copy) @@ -41,7 +41,7 @@ * The following code sample outlines the usage of this class: *
* Properties variables = ...; // parser variables - * ConfigurationParser parser = new ConfigurationParser(variables); + * RepositoryConfigurationParser parser = new RepositoryConfigurationParser(variables); * RepositoryConfig rc = parser.parseRepositoryConfig(...); * WorkspaceConfig wc = parser.parseWorkspaceConfig(...); *@@ -50,7 +50,7 @@ * initialized. The caller needs to initialize the configuration objects * before using them. */ -public class ConfigurationParser { +public class RepositoryConfigurationParser { /** Name of the repository home directory parser variable. */ public static final String REPOSITORY_HOME_VARIABLE = "rep.home"; @@ -135,7 +135,7 @@ * * @param variables parser variables */ - public ConfigurationParser(Properties variables) { + public RepositoryConfigurationParser(Properties variables) { this.variables = variables; } @@ -356,7 +356,7 @@ // Create a temporary parser that contains the ${wsp.name} variable Properties tmpVariables = (Properties) variables.clone(); tmpVariables.put(WORKSPACE_NAME_VARIABLE, name); - ConfigurationParser tmpParser = createSubParser(tmpVariables); + RepositoryConfigurationParser tmpParser = createSubParser(tmpVariables); // File system implementation FileSystemConfig fsc = new FileSystemConfig( @@ -692,10 +692,10 @@ * @param variables the variables overlay * @return a new configuration parser instance */ - protected ConfigurationParser createSubParser(Properties variables) { + protected RepositoryConfigurationParser createSubParser(Properties variables) { // overlay the properties Properties props = new Properties(this.variables); props.putAll(variables); - return new ConfigurationParser(props); + return new RepositoryConfigurationParser(props); } }