You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2007/05/16 00:49:21 UTC

svn commit: r538352 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/factory/ConfigurableFactory.java

Author: arminw
Date: Tue May 15 15:49:21 2007
New Revision: 538352

URL: http://svn.apache.org/viewvc?view=rev&rev=538352
Log:
add support for shortcut name mapping

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/factory/ConfigurableFactory.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/factory/ConfigurableFactory.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/factory/ConfigurableFactory.java?view=diff&rev=538352&r1=538351&r2=538352
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/factory/ConfigurableFactory.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/factory/ConfigurableFactory.java Tue May 15 15:49:21 2007
@@ -18,6 +18,7 @@
 import org.apache.commons.lang.SystemUtils;
 import org.apache.ojb.broker.PersistenceBrokerException;
 import org.apache.ojb.broker.util.ClassHelper;
+import org.apache.ojb.broker.util.ShortcutMapper;
 import org.apache.ojb.broker.util.configuration.Configurable;
 import org.apache.ojb.broker.util.configuration.Configuration;
 import org.apache.ojb.broker.util.configuration.ConfigurationException;
@@ -64,6 +65,15 @@
     protected abstract String getConfigurationKey();
 
     /**
+     * Overrride in factory implementation class if needed.
+     * Returns the base interface of the object to instantiate.
+     */
+    protected Class getBaseInterface()
+    {
+        return null;
+    }
+
+    /**
      * @see org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
      * looks up the the key getConfigurationKey() in the OjbConfiguration
      * to determine the Class to be served.
@@ -75,7 +85,12 @@
             getLogger().error("ConfigurableFactory configuration key is 'null'");
             throw new PersistenceBrokerException("ConfigurableFactory configuration key is 'null'");
         }
-        Class clazz = pConfig.getClass(getConfigurationKey(), null);
+        Class clazz = null;
+        if(getBaseInterface() != null)
+        {
+            clazz = ShortcutMapper.resolve(pConfig.getString(getConfigurationKey(), null), getBaseInterface());
+        }
+        if(clazz == null) clazz = pConfig.getClass(getConfigurationKey(), null);
         if (clazz == null)
         {
             getLogger().error("ConfigurableFactory configuration key class for key'" + getConfigurationKey() + "' does not exist.");



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org