jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1032787 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java
Date Mon, 08 Nov 2010 23:42:50 GMT
Author: jukka
Date: Mon Nov  8 23:42:50 2010
New Revision: 1032787

URL: http://svn.apache.org/viewvc?rev=1032787&view=rev
Log:
JCR-2802: Deprecate all non-bundle persistence managers

Log warnings when encountering deprecated configurations.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/BeanConfig.java

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=1032787&r1=1032786&r2=1032787&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 Nov  8 23:42:50 2010
@@ -172,15 +172,18 @@ public class BeanConfig {
      */
     @SuppressWarnings("unchecked")
     public <T> T newInstance(Class<T> klass) throws ConfigurationException {
+        String cname = getClassName();
         try {
-            Class<?> objectClass =
-                Class.forName(getClassName(), true, getClassLoader());
+            Class<?> objectClass = Class.forName(cname, true, getClassLoader());
             if (!klass.isAssignableFrom(objectClass)) {
                 throw new ConfigurationException(
-                        "Configured class "+getClassName()
+                        "Configured class " + cname
                         + " does not implement " + klass.getName()
                         + ". Please fix the repository configuration.");
             }
+            if (objectClass.getAnnotation(Deprecated.class) != null) {
+                log.warn("{} has been deprecated", cname);
+            }
 
             // Instantiate the object using the default constructor
             Object instance = objectClass.newInstance();
@@ -192,11 +195,15 @@ public class BeanConfig {
                 String name = enumeration.nextElement().toString();
                 Method setter = setters.get(name);
                 if (setter != null) {
+                    if (setter.getAnnotation(Deprecated.class) != null) {
+                        log.warn("Parameter {} of {} has been deprecated",
+                                name, cname);
+                    }
                     String value = properties.getProperty(name);
                     setProperty(instance, name, setter, value);
                 } else if (validate) {
                     throw new ConfigurationException(
-                            "Configured class " + getClassName()
+                            "Configured class " + cname
                             + " does not contain a property named " + name);
                 }
             }
@@ -208,15 +215,15 @@ public class BeanConfig {
             return (T) instance;
         } catch (ClassNotFoundException e) {
             throw new ConfigurationException(
-                    "Configured bean implementation class " + getClassName()
+                    "Configured bean implementation class " + cname
                     + " was not found.", e);
         } catch (InstantiationException e) {
             throw new ConfigurationException(
-                    "Configured bean implementation class " + getClassName()
+                    "Configured bean implementation class " + cname
                     + " can not be instantiated.", e);
         } catch (IllegalAccessException e) {
             throw new ConfigurationException(
-                    "Configured bean implementation class " + getClassName()
+                    "Configured bean implementation class " + cname
                     + " is protected.", e);
         }
     }



Mime
View raw message