jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r160536 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: RepositoryImpl.java SearchManager.java SessionImpl.java
Date Fri, 08 Apr 2005 08:39:48 GMT
Author: jukka
Date: Fri Apr  8 01:39:47 2005
New Revision: 160536

URL: http://svn.apache.org/viewcvs?view=rev&rev=160536
Log:
Simplified bean instantiation code using the BeanConfig functionality.

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java?view=diff&r1=160535&r2=160536
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java Fri
Apr  8 01:39:47 2005
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core;
 
-import org.apache.commons.collections.BeanMap;
 import org.apache.commons.collections.ReferenceMap;
 import org.apache.jackrabbit.core.config.PersistenceManagerConfig;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
@@ -67,7 +66,6 @@
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
 import java.util.Properties;
 import java.security.AccessControlContext;
 import java.security.AccessController;
@@ -711,39 +709,26 @@
     }
 
     /**
-     * Returns the workspace persistence manager
+     * Creates a workspace persistence manager based on the given
+     * configuration. The persistence manager is instantiated using
+     * information in the given persistencem manager configuration and
+     * initialized with a persistence manager context containing the other
+     * arguments.
      *
-     * @return the workspace persistence manager
-     * @throws RepositoryException if the persistence manager could not be instantiated/initialized
-     */
-    private static PersistenceManager createPersistenceManager(File homeDir,
-                                                               FileSystem fs,
-                                                               PersistenceManagerConfig pmConfig,
-                                                               String rootNodeUUID,
-                                                               NamespaceRegistry nsReg,
-                                                               NodeTypeRegistry ntReg)
+     * @return the created workspace persistence manager
+     * @throws RepositoryException if the persistence manager could
+     *                             not be instantiated/initialized
+     */
+    private static PersistenceManager createPersistenceManager(
+            File homeDir, FileSystem fs, PersistenceManagerConfig pmConfig,
+            String rootNodeUUID, NamespaceRegistry nsReg, NodeTypeRegistry ntReg)
             throws RepositoryException {
-        String className = pmConfig.getClassName();
-        Map params = pmConfig.getParameters();
         try {
-            Class c = Class.forName(className);
-            PersistenceManager persistMgr = (PersistenceManager) c.newInstance();
-            /**
-             * set the properties of the persistence manager object
-             * from the param map
-             */
-            BeanMap bm = new BeanMap(persistMgr);
-            Iterator iter = params.keySet().iterator();
-            while (iter.hasNext()) {
-                Object name = iter.next();
-                Object value = params.get(name);
-                bm.put(name, value);
-            }
-            PMContext ctx = new PMContext(homeDir, fs, rootNodeUUID, nsReg, ntReg);
-            persistMgr.init(ctx);
-            return persistMgr;
+            PersistenceManager pm = (PersistenceManager) pmConfig.newInstance();
+            pm.init(new PMContext(homeDir, fs, rootNodeUUID, nsReg, ntReg));
+            return pm;
         } catch (Exception e) {
-            String msg = "Cannot instantiate implementing class " + className;
+            String msg = "Cannot instantiate persistence manager " + pmConfig.getClassName();
             log.error(msg, e);
             throw new RepositoryException(msg, e);
         }

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java?view=diff&r1=160535&r2=160536
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SearchManager.java Fri
Apr  8 01:39:47 2005
@@ -128,8 +128,7 @@
         ntReg.addListener(propRegistry);
         // initialize query handler
         try {
-            Class handlerClass = Class.forName(config.getHandlerClassName());
-            handler = (QueryHandler) handlerClass.newInstance();
+            handler = (QueryHandler) config.newInstance();
             NodeId rootId = (NodeId) session.getHierarchyManager().resolvePath(Path.ROOT);
             handler.init(fs, session.getItemStateManager(), rootId.getUUID(), propRegistry);
         } catch (Exception e) {

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java?view=diff&r1=160535&r2=160536
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/SessionImpl.java Fri Apr
 8 01:39:47 2005
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.core;
 
-import org.apache.commons.collections.BeanMap;
 import org.apache.commons.collections.ReferenceMap;
 import org.apache.jackrabbit.core.config.AccessManagerConfig;
 import org.apache.jackrabbit.core.config.WorkspaceConfig;
@@ -266,27 +265,13 @@
                                                 HierarchyManager hierMgr)
             throws AccessDeniedException, RepositoryException {
         AccessManagerConfig amConfig = rep.getConfig().getAccessManagerConfig();
-        String className = amConfig.getClassName();
-        Map params = amConfig.getParameters();
         try {
-            Class c = Class.forName(className);
-            AccessManager accessMgr = (AccessManager) c.newInstance();
-            /**
-             * set the properties of the access manager object
-             * from the param map
-             */
-            BeanMap bm = new BeanMap(accessMgr);
-            Iterator iter = params.keySet().iterator();
-            while (iter.hasNext()) {
-                Object name = iter.next();
-                Object value = params.get(name);
-                bm.put(name, value);
-            }
             AMContext ctx = new AMContext(new File(rep.getConfig().getHomeDir()),
                     rep.getConfig().getFileSystem(),
                     subject,
                     hierMgr,
                     wsp.getName());
+            AccessManager accessMgr = (AccessManager) amConfig.newInstance();
             accessMgr.init(ctx);
             return accessMgr;
         } catch (AccessDeniedException ade) {
@@ -294,7 +279,7 @@
             throw ade;
         } catch (Exception e) {
             // wrap in RepositoryException
-            String msg = "failed to instantiate AccessManager implementation: " + className;
+            String msg = "failed to instantiate AccessManager implementation: " + amConfig.getClassName();
             log.error(msg, e);
             throw new RepositoryException(msg, e);
         }



Mime
View raw message