Author: doogie
Date: Mon Oct 5 03:00:11 2009 New Revision: 821669 URL: http://svn.apache.org/viewvc?rev=821669&view=rev Log: Simple factory lookup, DelegatorFactory switched to abstract class. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=821669&r1=821668&r2=821669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java Mon Oct 5 03:00:11 2009 @@ -18,7 +18,20 @@ */ package org.ofbiz.entity; +import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.Factory; +import org.ofbiz.base.util.UtilObject; -/** <code>Delegator</code> factory interface. */ -public interface DelegatorFactory extends Factory<Delegator, String> {} +/** <code>Delegator</code> factory abstract class. */ +public abstract class DelegatorFactory implements Factory<Delegator, String> { + public static final String module = DelegatorFactoryImpl.class.getName(); + + public static Delegator getDelegator(String delegatorName) { + try { + return UtilObject.getObjectFromFactory(DelegatorFactory.class, delegatorName); + } catch (ClassNotFoundException e) { + Debug.logError(e, module); + } + return null; + } +} Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java?rev=821669&r1=821668&r2=821669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactoryImpl.java Mon Oct 5 03:00:11 2009 @@ -22,7 +22,7 @@ /** A <code>DelegatorFactory</code> implementation that returns an * instance of <code>GenericDelegator</code>. */ -public class DelegatorFactoryImpl implements DelegatorFactory { +public class DelegatorFactoryImpl extends DelegatorFactory { public static final String module = DelegatorFactoryImpl.class.getName(); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java?rev=821669&r1=821668&r2=821669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/cache/AbstractCache.java Mon Oct 5 03:00:11 2009 @@ -18,8 +18,6 @@ *******************************************************************************/ package org.ofbiz.entity.cache; -import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilObject; import org.ofbiz.base.util.cache.UtilCache; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.DelegatorFactory; @@ -34,13 +32,7 @@ } public Delegator getDelegator() { - Delegator delegator = null; - try { - delegator = UtilObject.getObjectFromFactory(DelegatorFactory.class, this.delegatorName); - } catch (ClassNotFoundException e) { - Debug.logError(e, AbstractCache.class.getName()); - } - return delegator; + return DelegatorFactory.getDelegator(this.delegatorName); } public void remove(String entityName) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=821669&r1=821668&r2=821669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Mon Oct 5 03:00:11 2009 @@ -25,7 +25,6 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; -import org.ofbiz.base.util.UtilObject; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.EntityCryptoException; @@ -256,11 +255,7 @@ if (delegator == null) { // this will be the common case for now as the delegator isn't available where we want to do this // we'll cheat a little here and assume the default delegator - try { - delegator = UtilObject.getObjectFromFactory(DelegatorFactory.class, "default"); - } catch (ClassNotFoundException e) { - Debug.logError(e, module); - } + delegator = DelegatorFactory.getDelegator("default"); } String fieldName = null; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java?rev=821669&r1=821668&r2=821669&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/finder/ListFinder.java Mon Oct 5 03:00:11 2009 @@ -28,7 +28,6 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.base.util.UtilObject; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.FlexibleMapAccessor; @@ -139,11 +138,7 @@ resultSetType = ResultSet.TYPE_FORWARD_ONLY; if (delegatorName != null && delegatorName.length() > 0) { - try { - delegator = UtilObject.getObjectFromFactory(DelegatorFactory.class, delegatorName); - } catch (ClassNotFoundException e) { - Debug.logError(e, AbstractCache.class.getName()); - } + delegator = DelegatorFactory.getDelegator(delegatorName); } EntityCondition whereEntityCondition = getWhereEntityCondition(context, modelEntity, delegator.getModelFieldTypeReader(modelEntity)); |
Free forum by Nabble | Edit this page |