db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r538369 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata: FieldDescriptor.java ObjectCacheDescriptor.java
Date Tue, 15 May 2007 23:06:00 GMT
Author: arminw
Date: Tue May 15 16:05:59 2007
New Revision: 538369

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

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java?view=diff&rev=538369&r1=538368&r2=538369
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java
Tue May 15 16:05:59 2007
@@ -33,6 +33,7 @@
 import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
 import org.apache.ojb.broker.metadata.fieldaccess.AnonymousPersistentField;
 import org.apache.ojb.broker.util.ClassHelper;
+import org.apache.ojb.broker.util.ShortcutMapper;
 
 /**
  * A FieldDescriptor holds the mapping information for a specific member-variable
@@ -45,9 +46,9 @@
  */
 public class FieldDescriptor extends AttributeDescriptorBase implements XmlCapable, Serializable
 {
-	private static final long serialVersionUID = 8231802073685958561L;
-	
-	public static final String ACCESS_ANONYMOUS = RepositoryElements.TAG_ACCESS_ANONYMOUS;
+    private static final long serialVersionUID = 8231802073685958561L;
+
+    public static final String ACCESS_ANONYMOUS = RepositoryElements.TAG_ACCESS_ANONYMOUS;
     public static final String ACCESS_READONLY = RepositoryElements.TAG_ACCESS_READONLY;
     public static final String ACCESS_READWRITE = RepositoryElements.TAG_ACCESS_READWRITE;
 
@@ -321,12 +322,18 @@
     {
         try
         {
-            this.fieldConversion = (FieldConversion) ClassHelper.newInstance(fieldConversionClassName);
+            Class clazz = ShortcutMapper.resolve(fieldConversionClassName, FieldConversion.class);
+            if(clazz == null)
+            {
+                throw new MetadataException("Can't resolve FieldConversion class for conversion
name: " + fieldConversionClassName);
+            }
+            this.fieldConversion = (FieldConversion) ClassHelper.newInstance(clazz);
         }
         catch (Exception e)
         {
             throw new MetadataException(
-                    "Could not instantiate FieldConversion class using default constructor",
e);
+                    "Could not instantiate FieldConversion class using default constructor,
name was: "
+                            + fieldConversionClassName, e);
         }
     }
 
@@ -340,7 +347,7 @@
         // if no explicit class is specified use the default implementation
         if (nullCheck == null)
         {
-        	nullCheck = new NullCheckDefaultImpl();
+            nullCheck = new NullCheckDefaultImpl();
         }
         return nullCheck;
     }
@@ -361,7 +368,7 @@
         // if no explicit class is specified use the default implementation
         if (nullCheck == null)
         {
-        	nullCheck = new NullCheckDefaultImpl();
+            nullCheck = new NullCheckDefaultImpl();
         }
         return nullCheck.representsNull(this, aValue);
     }
@@ -386,7 +393,7 @@
     {
         return representsNull(getPersistentField().get(obj));
     }
-    
+
     /**
      * Creates the {@link NullCheck} implementation to use for this field.
      *
@@ -398,7 +405,9 @@
     {
         try
         {
-            this.nullCheck = (NullCheck) ClassHelper.newInstance(nullCheckClassName);
+            Class tmp = ShortcutMapper.resolve(nullCheckClassName, NullCheck.class);
+            if(tmp == null) throw new ClassNotFoundException("Can' find class: " + nullCheckClassName);
+            this.nullCheck = (NullCheck) ClassHelper.newInstance(tmp);
         }
         catch(ClassNotFoundException e)
         {
@@ -841,9 +850,9 @@
         // NullCheck
         if( this.getNullCheck().getClass() != NullCheckDefaultImpl.class )
         {
-        	result.append( "        " );
-        	result.append( tags.getAttribute( NULL_CHECK, getNullCheck().getClass().getName()
) );
-        	result.append( eol );
+            result.append( "        " );
+            result.append( tags.getAttribute( NULL_CHECK, getNullCheck().getClass().getName()
) );
+            result.append( eol );
         }
 
         // length

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java?view=diff&rev=538369&r1=538368&r2=538369
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/ObjectCacheDescriptor.java
Tue May 15 16:05:59 2007
@@ -20,7 +20,9 @@
 import org.apache.commons.lang.SystemUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
+import org.apache.ojb.broker.cache.ObjectCache;
 import org.apache.ojb.broker.cache.ObjectCacheEmptyImpl;
+import org.apache.ojb.broker.util.ShortcutMapper;
 import org.apache.ojb.broker.util.XmlHelper;
 
 /**
@@ -37,7 +39,7 @@
  */
 public class ObjectCacheDescriptor extends DescriptorBase implements XmlCapable
 {
-	private static final long serialVersionUID = 2583853027407750053L;
+    private static final long serialVersionUID = 2583853027407750053L;
     private static final Class DEF_OBJECT_CACHE = ObjectCacheEmptyImpl.class;
     private Class objectCache;
 
@@ -55,6 +57,12 @@
     public Class getObjectCache()
     {
         return objectCache;
+    }
+
+    public void setObjectCache(String name)
+    {
+        Class tmp = ShortcutMapper.resolve(name, ObjectCache.class);
+        if(tmp != null) this.objectCache = tmp;
     }
 
     public void setObjectCache(Class objectCache)



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


Mime
View raw message