jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r829798 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/config/ main/java/org/apache/jackrabbit/core/security/authorization/ main/java/org/apache/jackrabbit/core/securit...
Date Mon, 26 Oct 2009 13:48:31 GMT
Author: jukka
Date: Mon Oct 26 13:48:30 2009
New Revision: 829798

URL: http://svn.apache.org/viewvc?rev=829798&view=rev
Log:
JCR-1438: Replace Config classes with factories

Reintroduced change from revision 826653:

Use generics in BeanConfig.newInstance() to avoid the need of class casts.

Use the standard java.beans classes instead of BeanMap for the configured bean properties.
This allows better control over value types.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ImportConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/UserManagerConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProviderFactoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/SecurityConfigTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/DefaultSecurityManager.java
Mon Oct 26 13:48:30 2009
@@ -210,7 +210,8 @@
         // create the workspace access manager
         SecurityManagerConfig smc = config.getSecurityManagerConfig();
         if (smc != null && smc.getWorkspaceAccessConfig() != null) {
-            workspaceAccessManager = (WorkspaceAccessManager) smc.getWorkspaceAccessConfig().newInstance();
+            workspaceAccessManager =
+                smc.getWorkspaceAccessConfig().newInstance(WorkspaceAccessManager.class);
         } else {
             // fallback -> the default implementation
             log.debug("No WorkspaceAccessManager configured; using default.");
@@ -271,7 +272,7 @@
                 log.debug("No configuration entry for AccessManager. Using org.apache.jackrabbit.core.security.DefaultAccessManager");
                 accessMgr = new DefaultAccessManager();
             } else {
-                accessMgr = (AccessManager) amConfig.newInstance();
+                accessMgr = amConfig.newInstance(AccessManager.class);
             }
 
             accessMgr.init(amContext, pp, workspaceAccessManager);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Mon Oct 26 13:48:30 2009
@@ -446,7 +446,7 @@
                 log.debug("No configuration entry for SecurityManager. Using org.apache.jackrabbit.core.security.simple.SimpleSecurityManager");
                 securityMgr = new SimpleSecurityManager();
             } else {
-                securityMgr = (JackrabbitSecurityManager) smc.newInstance();
+                securityMgr = smc.newInstance(JackrabbitSecurityManager.class);
             }
 
             securityMgr.init(this, securitySession);
@@ -1392,7 +1392,7 @@
                                                                DataStore dataStore)
             throws RepositoryException {
         try {
-            PersistenceManager pm = (PersistenceManager) pmConfig.newInstance();
+            PersistenceManager pm = pmConfig.newInstance(PersistenceManager.class);
             pm.init(new PMContext(homeDir, fs, rootNodeId, nsReg, ntReg, dataStore));
             return pm;
         } catch (Exception e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
Mon Oct 26 13:48:30 2009
@@ -16,23 +16,29 @@
  */
 package org.apache.jackrabbit.core.config;
 
-import org.apache.commons.collections.BeanMap;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Properties;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.io.InputStream;
-import java.io.IOException;
-
 /**
  * Bean configuration class. BeanConfig instances contain the class name
  * and property information required to instantiate a class that conforms
  * with the JavaBean conventions.
  */
-public class BeanConfig<T> {
+public class BeanConfig {
 
     private static Logger log = LoggerFactory.getLogger(BeanConfig.class);
 
@@ -151,38 +157,40 @@
      * @return new bean instance
      * @throws ConfigurationException on bean configuration errors
      */
-    public Object newInstance() throws ConfigurationException {
+    @SuppressWarnings("unchecked")
+    public <T> T newInstance(Class<T> klass) throws ConfigurationException {
         try {
-            // Instantiate the object using the default constructor
             Class<?> objectClass =
                 Class.forName(getClassName(), true, getClassLoader());
-            Object object = objectClass.newInstance();
+            if (!klass.isAssignableFrom(objectClass)) {
+                throw new ConfigurationException(
+                        "Configured class "+getClassName()
+                        + " does not implement " + klass.getName()
+                        + ". Please fix the repository configuration.");
+            }
+
+            // Instantiate the object using the default constructor
+            Object instance = objectClass.newInstance();
 
             // Set all configured bean properties
-            BeanMap map = new BeanMap(object);
-            for (Object key : map.keySet()) {
-                String value = properties.getProperty(key.toString());
+            List<?> names = Collections.list(properties.propertyNames());
+            BeanInfo info = Introspector.getBeanInfo(objectClass, Object.class);
+            for (PropertyDescriptor property : info.getPropertyDescriptors()) {
+                String value = properties.getProperty(property.getName());
                 if (value != null) {
-                    map.put(key, value);
+                    setProperty(instance, property, value);
+                    names.remove(property.getName());
                 }
             }
 
-            if (validate) {
-                // Check that no invalid property names were configured
-                for (Object key : properties.keySet()) {
-                    if (!map.containsKey(key)
-                            && properties.getProperty(key.toString()) != null) {
-                        String msg =
-                            "Configured class " + object.getClass().getName()
-                            + " does not contain the property " + key
-                            + ". Please fix the repository configuration.";
-                        log.error(msg);
-                        throw new ConfigurationException(msg);
-                    }
-                }
+            // Check that no invalid property names were configured
+            if (validate && !names.isEmpty()) {
+                throw new ConfigurationException(
+                        "Configured class " + getClassName()
+                        + " does not contain the properties " + names);
             }
 
-            return (T) object;
+            return (T) instance;
         } catch (ClassNotFoundException e) {
             throw new ConfigurationException(
                     "Configured bean implementation class " + getClassName()
@@ -195,6 +203,71 @@
             throw new ConfigurationException(
                     "Configured bean implementation class " + getClassName()
                     + " is protected.", e);
+        } catch (IntrospectionException e) {
+            throw new ConfigurationException(
+                    "Configured bean implementation class " + getClassName()
+                    + " can not be introspected", e);
+        }
+    }
+
+    private void setProperty(
+            Object instance, PropertyDescriptor property, String value)
+            throws ConfigurationException {
+        Method method = property.getWriteMethod();
+        if (method == null) {
+            throw new ConfigurationException(
+                    "Property " + property.getName() + " of class "
+                    + getClassName() + " can not be written"); 
+        }
+
+        Class<?>[] types = method.getParameterTypes();
+        if (types.length != 1) {
+            throw new ConfigurationException(
+                    "Property " + property.getName() + " of class "
+                    + getClassName() + " has an invalid setter");
+        }
+
+        Class<?> type = types[0];
+        try {
+            if (types[0].isAssignableFrom(String.class)
+                || types[0].isAssignableFrom(Object.class)) {
+                method.invoke(instance, value);
+            } else if (types[0].isAssignableFrom(Boolean.TYPE)
+                    || types[0].isAssignableFrom(Boolean.class)) {
+                method.invoke(instance, Boolean.valueOf(value));
+            } else if (types[0].isAssignableFrom(Integer.TYPE)
+                    || types[0].isAssignableFrom(Integer.class)) {
+                method.invoke(instance, Integer.valueOf(value));
+            } else if (types[0].isAssignableFrom(Long.TYPE)
+                    || types[0].isAssignableFrom(Long.class)) {
+                method.invoke(instance, Long.valueOf(value));
+            } else if (types[0].isAssignableFrom(Double.TYPE)
+                    || types[0].isAssignableFrom(Double.class)) {
+                method.invoke(instance, Double.valueOf(value));
+            } else {
+                throw new ConfigurationException(
+                        "The type (" + type.getName()
+                        + ") of property " + property.getName() + " of class "
+                        + getClassName() + " is not supported");
+            }
+        } catch (NumberFormatException e) {
+            throw new ConfigurationException(
+                    "Invalid number format (" + value + ") for property "
+                    + property.getName() + " of class " + getClassName(), e);
+        } catch (InvocationTargetException e) {
+            throw new ConfigurationException(
+                    "Property " + property.getName() + " of class "
+                    + getClassName() + " can not be set to \"" + value + "\"",
+                    e);
+        } catch (IllegalAccessException e) {
+            throw new ConfigurationException(
+                    "The setter of property " + property.getName()
+                    + " of class " + getClassName() + " can not be accessed",
+                    e);
+        } catch (IllegalArgumentException e) {
+            throw new ConfigurationException(
+                    "Unable to call the setter of property "
+                    + property.getName() + " of class " + getClassName(), e);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ImportConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ImportConfig.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ImportConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/ImportConfig.java
Mon Oct 26 13:48:30 2009
@@ -49,15 +49,11 @@
     }
 
     public List<ProtectedNodeImporter> getProtectedNodeImporters() {
-        List<ProtectedNodeImporter> pnis = new ArrayList();
+        List<ProtectedNodeImporter> pnis =
+            new ArrayList<ProtectedNodeImporter>();
         for (BeanConfig bc : protectedNodeImporters) {
             try {
-                Object o = bc.newInstance();
-                if (o instanceof ProtectedNodeImporter) {
-                    pnis.add((ProtectedNodeImporter) o);
-                } else {
-                    log.warn("Invalid configuration entry: " + bc.getClassName() +" does
not implement ProtectedNodeImporter.");                    
-                }
+                pnis.add(bc.newInstance(ProtectedNodeImporter.class));
             } catch (ConfigurationException e) {
                 log.warn(e.getMessage());
             }
@@ -66,15 +62,11 @@
     }
 
     public List<ProtectedPropertyImporter> getProtectedPropertyImporters() {
-        List<ProtectedPropertyImporter> ppis = new ArrayList();
+        List<ProtectedPropertyImporter> ppis =
+            new ArrayList<ProtectedPropertyImporter>();
         for (BeanConfig bc : protectedPropertyImporters) {
             try {
-                Object o = bc.newInstance();
-                if (o instanceof ProtectedPropertyImporter) {
-                    ppis.add((ProtectedPropertyImporter) o);
-                } else {
-                    log.warn("Invalid configuration entry: " + bc.getClassName() +" does
not implement ProtectedPropertyImporter.");
-                }
+                ppis.add(bc.newInstance(ProtectedPropertyImporter.class));
             } catch (ConfigurationException e) {
                 log.warn(e.getMessage());
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/LoginModuleConfig.java
Mon Oct 26 13:48:30 2009
@@ -60,12 +60,6 @@
     }
 
     public LoginModule getLoginModule() throws ConfigurationException {
-        Object result = newInstance();
-        if (result instanceof LoginModule) {
-            return (LoginModule) result;
-        } else {
-            throw new ConfigurationException("Invalid login module implementation class "
-                    + getClassName() + ".");
-        }
+        return newInstance(LoginModule.class);
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfigurationParser.java
Mon Oct 26 13:48:30 2009
@@ -576,7 +576,7 @@
                                 className, parseParameters(element));
 
                         QueryHandler handler =
-                            (QueryHandler) config.newInstance();
+                            config.newInstance(QueryHandler.class);
                         try {
                             handler.init(fs, context);
                             return handler;
@@ -689,14 +689,7 @@
             public ISMLocking getISMLocking() throws RepositoryException {
                 Element element = getElement(parent, ISM_LOCKING_ELEMENT, false);
                 if (element != null) {
-                    BeanConfig config = parseBeanConfig(element);
-                    try {
-                        return (ISMLocking) config.newInstance();
-                    } catch (ClassCastException e) {
-                        throw new RepositoryException(
-                                "Invalid ISMLocking class: "
-                                + config.getClassName(), e);
-                    }
+                    return parseBeanConfig(element).newInstance(ISMLocking.class);
                 } else {
                     return new DefaultISMLocking();
                 }
@@ -831,25 +824,18 @@
             public Journal getJournal(NamespaceResolver resolver)
                     throws RepositoryException {
                 BeanConfig config = parseBeanConfig(cluster, JOURNAL_ELEMENT);
-                Object object = config.newInstance();
-                if (object instanceof Journal) {
-                    Journal journal = (Journal) object;
-                    if (journal instanceof AbstractJournal) {
-                        ((AbstractJournal) journal).setRepositoryHome(home);
-                    }
-                    try {
-                        journal.init(id, resolver);
-                    } catch (JournalException e) {
-                        // TODO: Should JournalException extend RepositoryException?
-                        throw new RepositoryException(
-                                "Journal initialization failed: " + journal, e);
-                    }
-                    return journal;
-                } else {
+                Journal journal = config.newInstance(Journal.class);
+                if (journal instanceof AbstractJournal) {
+                    ((AbstractJournal) journal).setRepositoryHome(home);
+                }
+                try {
+                    journal.init(id, resolver);
+                } catch (JournalException e) {
+                    // TODO: Should JournalException extend RepositoryException?
                     throw new RepositoryException(
-                            "Invalid Journal implementation class: "
-                            + config.getClassName());
+                            "Journal initialization failed: " + journal, e);
                 }
+                return journal;
             }
         };
     }
@@ -883,7 +869,7 @@
                             && DATA_STORE_ELEMENT.equals(child.getNodeName())) {
                         BeanConfig bc =
                             parseBeanConfig(parent, DATA_STORE_ELEMENT);
-                        DataStore store = (DataStore) bc.newInstance();
+                        DataStore store = bc.newInstance(DataStore.class);
                         store.init(directory);
                         return store;
                     }
@@ -913,7 +899,6 @@
     protected RepositoryLockMechanismFactory getRepositoryLockMechanismFactory(final Element
root) {
         return new RepositoryLockMechanismFactory() {
             public RepositoryLockMechanism getRepositoryLockMechanism() throws RepositoryException
{
-                RepositoryLockMechanism lock = null;
                 NodeList children = root.getChildNodes();
                 for (int i = 0; i < children.getLength(); i++) {
                     Node child = children.item(i);
@@ -921,14 +906,10 @@
                             && REPOSITORY_LOCK_MECHANISM_ELEMENT.equals(child.getNodeName()))
{
                         BeanConfig bc =
                             parseBeanConfig(root, REPOSITORY_LOCK_MECHANISM_ELEMENT);
-                        lock = (RepositoryLockMechanism) bc.newInstance();
-                        break;
+                        return bc.newInstance(RepositoryLockMechanism.class);
                     }
                 }
-                if (lock == null) {
-                    lock = new RepositoryLock();
-                }
-                return lock;
+                return new RepositoryLock();
             }
         };
     }
@@ -975,13 +956,9 @@
         return new FileSystemFactory() {
             public FileSystem getFileSystem() throws RepositoryException {
                 try {
-                    FileSystem fs = (FileSystem) config.newInstance();
+                    FileSystem fs = config.newInstance(FileSystem.class);
                     fs.init();
                     return fs;
-                } catch (ClassCastException e) {
-                    throw new RepositoryException(
-                            "Invalid file system implementation class: "
-                            + config.getClassName(), e);
                 } catch (FileSystemException e) {
                     throw new RepositoryException(
                             "File system initialization failure.", e);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/UserManagerConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/UserManagerConfig.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/UserManagerConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/UserManagerConfig.java
Mon Oct 26 13:48:30 2009
@@ -39,7 +39,7 @@
 
     private Constructor<?> constr;
 
-    public UserManagerConfig(BeanConfig<?> config) {
+    public UserManagerConfig(BeanConfig config) {
         super(config);
         setValidate(false); // omit validation of the config properties
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProviderFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProviderFactoryImpl.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProviderFactoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlProviderFactoryImpl.java
Mon Oct 26 13:48:30 2009
@@ -74,7 +74,7 @@
         Map props;
         if (config != null && config.getAccessControlProviderConfig() != null) {
             BeanConfig bc = config.getAccessControlProviderConfig();
-            prov = (AccessControlProvider) bc.newInstance();
+            prov = bc.newInstance(AccessControlProvider.class);
             props = bc.getParameters();
         } else {
             log.debug("No ac-provider configuration for workspace " + workspaceName + " ->
using defaults.");

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManager.java
Mon Oct 26 13:48:30 2009
@@ -176,7 +176,8 @@
 
         SecurityManagerConfig smc = config.getSecurityManagerConfig();
         if (smc != null && smc.getWorkspaceAccessConfig() != null) {
-            workspaceAccessManager = (WorkspaceAccessManager) smc.getWorkspaceAccessConfig().newInstance();
+            workspaceAccessManager =
+                smc.getWorkspaceAccessConfig().newInstance(WorkspaceAccessManager.class);
         } else {
             // fallback -> the default simple implementation
             log.debug("No WorkspaceAccessManager configured; using default.");
@@ -216,7 +217,7 @@
             if (amc == null) {
                 accessMgr = new SimpleAccessManager();
             } else {
-                accessMgr = (AccessManager) amc.newInstance();
+                accessMgr = amc.newInstance(AccessManager.class);
             }
             accessMgr.init(amContext, acP, workspaceAccessManager);
             return accessMgr;

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
Mon Oct 26 13:48:30 2009
@@ -213,7 +213,8 @@
 
         BeanConfig bc = smc.getWorkspaceAccessConfig();
         if (bc != null) {
-            WorkspaceAccessManager wac = (WorkspaceAccessManager) smc.getWorkspaceAccessConfig().newInstance();
+            WorkspaceAccessManager wac =
+                smc.getWorkspaceAccessConfig().newInstance(WorkspaceAccessManager.class);
             assertEquals("org.apache.jackrabbit.core.security.simple.SimpleWorkspaceAccessManager",
wac.getClass().getName());
         }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/SecurityConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/SecurityConfigTest.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/SecurityConfigTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/SecurityConfigTest.java
Mon Oct 26 13:48:30 2009
@@ -18,7 +18,9 @@
 
 import org.apache.jackrabbit.core.DefaultSecurityManager;
 import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.security.AccessManager;
 import org.apache.jackrabbit.core.security.DefaultAccessManager;
+import org.apache.jackrabbit.core.security.JackrabbitSecurityManager;
 import org.apache.jackrabbit.core.security.user.UserManagerImpl;
 import org.apache.jackrabbit.core.security.user.UserPerWorkspaceUserManager;
 import org.apache.jackrabbit.core.security.authentication.DefaultLoginModule;
@@ -72,12 +74,12 @@
 
         SecurityManagerConfig smc = config.getSecurityManagerConfig();
         assertNotNull(smc);
-        assertTrue(smc.newInstance() instanceof SimpleSecurityManager);
+        assertTrue(smc.newInstance(JackrabbitSecurityManager.class) instanceof SimpleSecurityManager);
         assertNull(smc.getWorkspaceAccessConfig());
         assertNull(smc.getWorkspaceName());
 
         assertNotNull(config.getAccessManagerConfig());
-        assertTrue(config.getAccessManagerConfig().newInstance() instanceof SimpleAccessManager);
+        assertTrue(config.getAccessManagerConfig().newInstance(AccessManager.class) instanceof
SimpleAccessManager);
 
         assertNull(config.getLoginModuleConfig());
     }
@@ -91,7 +93,7 @@
 
         SecurityManagerConfig smc = config.getSecurityManagerConfig();
         assertNotNull(smc);
-        assertTrue(smc.newInstance() instanceof DefaultSecurityManager);
+        assertTrue(smc.newInstance(JackrabbitSecurityManager.class) instanceof DefaultSecurityManager);
         assertNull(smc.getWorkspaceAccessConfig());
         assertEquals("security", smc.getWorkspaceName());
 
@@ -99,7 +101,7 @@
 
         AccessManagerConfig amc = config.getAccessManagerConfig();
         assertNotNull(amc);
-        assertTrue(amc.newInstance() instanceof DefaultAccessManager);
+        assertTrue(amc.newInstance(AccessManager.class) instanceof DefaultAccessManager);
 
         LoginModuleConfig lmc = config.getLoginModuleConfig();
         assertNotNull(lmc);
@@ -314,4 +316,4 @@
                     "           <UserManager class=\"org.apache.jackrabbit.core.security.user.UserPerWorkspaceUserManager\"
/>" +
                     "        </SecurityManager>" +
                     "    </Security>";
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java?rev=829798&r1=829797&r2=829798&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java
Mon Oct 26 13:48:30 2009
@@ -77,7 +77,7 @@
         if (ws != null) {
             BeanConfig ppfConfig =  ws.getAccessControlProviderConfig();
             if (ppfConfig != null) {
-                AccessControlProvider prov = (AccessControlProvider) ppfConfig.newInstance();
+                ppfConfig.newInstance(AccessControlProvider.class);
             }
         }
     }



Mime
View raw message