Author: arminw
Date: Sat Jan 28 02:07:14 2006
New Revision: 373114

URL: http://svn.apache.org/viewcvs?rev=373114&view=rev
Log:
do automatically configure "configurable" objects

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/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/factory/ConfigurableFactory.java?rev=373114&r1=373113&r2=373114&view=diff
==============================================================================
--- 
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
 Sat Jan 28 02:07:14 2006
@@ -86,8 +86,11 @@
     }
 
     /**
-     * factory method for creating new instances
-     * the Class to be instantiated is defined by getClassToServe().
+     * Factory method for creating new instances
+     * the Class to be instantiated is defined by getClassToServe(),
+     * if the target class implements [EMAIL PROTECTED] 
org.apache.ojb.broker.util.configuration.Configurable}
+     * interface it will be configured too.
+     *
      * @return Object the created instance
      */
     public Object createNewInstance(Class[] types, Object[] args)
@@ -104,6 +107,10 @@
             {
                 result = ClassHelper.newInstance(getClassToServe(), true);
             }
+            if(result instanceof Configurable)
+            {
+                ((Configurable) 
result).configure(OjbConfigurator.getInstance().getConfigurationFor(null));
+            }
             // if defined in OJB.properties all instances are wrapped by an 
interceptor
             result = 
InterceptorFactory.getInstance().createInterceptorFor(result);
             return result;
@@ -133,29 +140,29 @@
     {
         StringBuffer buf = new StringBuffer();
         String eol = SystemUtils.LINE_SEPARATOR;
-        buf.append(eol + "* Factory types: ");
+        buf.append(eol).append("* Factory types: ");
         if (types != null)
         {
             for (int i = 0; i < types.length; i++)
             {
                 Class type = types[i];
-                buf.append(eol + (i + 1) + " - Type: " + (type != null ? 
type.getName() : null));
+                buf.append(eol).append(i + 1).append(" - Type: ").append(type 
!= null ? type.getName() : null);
             }
         }
         else
-            buf.append(eol + "none");
+            buf.append(eol).append("none");
 
-        buf.append(eol + "* Factory arguments: ");
+        buf.append(eol).append("* Factory arguments: ");
         if (args != null)
         {
             for (int i = 0; i < args.length; i++)
             {
                 Object obj = args[i];
-                buf.append(eol + (i + 1) + " - Argument: " + obj);
+                buf.append(eol).append(i + 1).append(" - Argument: 
").append(obj);
             }
         }
         else
-            buf.append(eol + "none");
+            buf.append(eol).append("none");
         return buf.toString();
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to