You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2006/01/09 18:10:21 UTC
svn commit: r367338 - in
/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core:
RepositoryImpl.java config/FileSystemConfig.java config/WorkspaceConfig.java
Author: stefan
Date: Mon Jan 9 09:10:17 2006
New Revision: 367338
URL: http://svn.apache.org/viewcvs?rev=367338&view=rev
Log:
improving startup time: all workspaces (except the default workspace) are initialized lazily, i.e. on demand
Modified:
incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/FileSystemConfig.java
incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=367338&r1=367337&r2=367338&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Mon Jan 9 09:10:17 2006
@@ -22,6 +22,7 @@
import org.apache.jackrabbit.core.config.RepositoryConfig;
import org.apache.jackrabbit.core.config.VersioningConfig;
import org.apache.jackrabbit.core.config.WorkspaceConfig;
+import org.apache.jackrabbit.core.config.FileSystemConfig;
import org.apache.jackrabbit.core.fs.BasedFileSystem;
import org.apache.jackrabbit.core.fs.FileSystem;
import org.apache.jackrabbit.core.fs.FileSystemException;
@@ -1156,6 +1157,11 @@
private final WorkspaceConfig config;
/**
+ * file system (instantiated on init)
+ */
+ private FileSystem fs;
+
+ /**
* persistence manager (instantiated on init)
*/
private PersistenceManager persistMgr;
@@ -1211,15 +1217,6 @@
}
/**
- * Returns the workspace file system.
- *
- * @return the workspace file system
- */
- FileSystem getFileSystem() {
- return config.getFileSystem();
- }
-
- /**
* Returns the workspace configuration.
*
* @return the workspace configuration
@@ -1239,12 +1236,25 @@
}
/**
+ * Returns the workspace file system.
+ *
+ * @return the workspace file system
+ */
+ synchronized FileSystem getFileSystem() {
+ if (!initialized) {
+ throw new IllegalStateException("not initialized");
+ }
+
+ return fs;
+ }
+
+ /**
* Returns the workspace persistence manager.
*
* @return the workspace persistence manager
* @throws RepositoryException if the persistence manager could not be instantiated/initialized
*/
- synchronized PersistenceManager getPersistenceManager(PersistenceManagerConfig pmConfig)
+ synchronized PersistenceManager getPersistenceManager()
throws RepositoryException {
if (!initialized) {
throw new IllegalStateException("not initialized");
@@ -1326,7 +1336,7 @@
// lock manager is lazily instantiated in order to avoid
// 'chicken & egg' bootstrap problems
if (lockMgr == null) {
- lockMgr = new LockManagerImpl(getSystemSession(), config.getFileSystem());
+ lockMgr = new LockManagerImpl(getSystemSession(), fs);
}
return lockMgr;
}
@@ -1354,6 +1364,7 @@
* Initializes this workspace info. The following components are
* initialized immediately:
* <ul>
+ * <li>file system</li>
* <li>persistence manager</li>
* <li>shared item state manager</li>
* <li>observation manager factory</li>
@@ -1372,8 +1383,12 @@
throw new IllegalStateException("already initialized");
}
+ FileSystemConfig fsConfig = config.getFileSystemConfig();
+ fsConfig.init();
+ fs = fsConfig.getFileSystem();
+
persistMgr = createPersistenceManager(new File(config.getHomeDir()),
- config.getFileSystem(),
+ fs,
config.getPersistenceManagerConfig(),
rootNodeUUID,
nsReg,
@@ -1447,13 +1462,9 @@
}
// close workspace file system
- try {
- // close workspace file system
- config.getFileSystem().close();
- } catch (FileSystemException e) {
- log.error("error while closing filesystem of workspace "
- + config.getName(), e);
- }
+ FileSystemConfig fsConfig = config.getFileSystemConfig();
+ fsConfig.dispose();
+ fs = null;
}
}
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/FileSystemConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/FileSystemConfig.java?rev=367338&r1=367337&r2=367338&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/FileSystemConfig.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/FileSystemConfig.java Mon Jan 9 09:10:17 2006
@@ -21,9 +21,12 @@
/**
* File system configuration. This bean configuration class
- * is used to create a configured file system objects. The file system
+ * is used to create a configured file system object. The file system
* is instantiated by the {@link #init() init()} method, and accessible
- * using the {@link #getFileSystem() getFileSystem()} method.
+ * using the {@link #getFileSystem() getFileSystem()} method. Calling
+ * {@link #dispose() dispose()} will close and dispose a file system instance
+ * previously created by the {@link #init() init()} method.
+ *
*/
public class FileSystemConfig extends BeanConfig {
@@ -64,6 +67,24 @@
} else {
throw new IllegalStateException(
"File system has already been initialized.");
+ }
+ }
+
+ /**
+ * Closes and disposes a file system instance previously created by the
+ * {@link #init() init()} method, i.e. resets this instance to the
+ * <i>uninitialized</i> state.
+ */
+ public void dispose() {
+ if (fs != null) {
+ try {
+ fs.close();
+ } catch (FileSystemException fse) {
+ // ignore...
+ }
+ fs = null;
+ } else {
+ throw new IllegalStateException("File system has not been initialized.");
}
}
Modified: incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java?rev=367338&r1=367337&r2=367338&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java (original)
+++ incubator/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/config/WorkspaceConfig.java Mon Jan 9 09:10:17 2006
@@ -16,8 +16,6 @@
*/
package org.apache.jackrabbit.core.config;
-import org.apache.jackrabbit.core.fs.FileSystem;
-
/**
* Workspace configuration. This configuration class is used to
* create configured workspace objects.
@@ -73,12 +71,11 @@
}
/**
- * Initializes the workspace file system and search index implementations.
+ * Initializes the search index implementation.
*
* @throws ConfigurationException on initialization errors
*/
public void init() throws ConfigurationException {
- fsc.init();
if (sc != null) {
sc.init();
}
@@ -100,15 +97,6 @@
*/
public String getName() {
return name;
- }
-
- /**
- * Returns the workspace file system implementation.
- *
- * @return file system implementation
- */
- public FileSystem getFileSystem() {
- return fsc.getFileSystem();
}
/**