Author: jonesde
Date: Wed May 28 00:58:13 2008 New Revision: 660850 URL: http://svn.apache.org/viewvc?rev=660850&view=rev Log: Added further support for javolution ObjectFactory which will bring the efficiency improvements that along with syntax cleanup are part of this whole factory method effort Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java?rev=660850&r1=660849&r2=660850&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java Wed May 28 00:58:13 2008 @@ -41,7 +41,7 @@ /** - * Generic Entity Value Object - Handles persisntence for any defined entity. + * Generic Entity Value Object - Handles persistence for any defined entity. * */ public class GenericValue extends GenericEntity implements Reusable { @@ -54,10 +54,10 @@ } }; - /** Hashtable to cache various related entity collections */ + /** Map to cache various related entity collections */ public transient Map<String, List<GenericValue>> relatedCache = null; - /** Hashtable to cache various related cardinality one entity collections */ + /** Map to cache various related cardinality one entity collections */ public transient Map<String, GenericValue> relatedOneCache = null; /** This Map will contain the original field values from the database iff Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java?rev=660850&r1=660849&r2=660850&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityCondition.java Wed May 28 00:58:13 2008 @@ -44,91 +44,91 @@ public abstract class EntityCondition extends EntityConditionBase implements Reusable { public static EntityExpr makeCondition(Object lhs, EntityComparisonOperator operator, Object rhs) { - EntityExpr expr = new EntityExpr(); + EntityExpr expr = EntityExpr.entityExprFactory.object(); expr.init(lhs, operator, rhs); return expr; } public static EntityExpr makeCondition(String fieldName, Object value) { - EntityExpr expr = new EntityExpr(); + EntityExpr expr = EntityExpr.entityExprFactory.object(); expr.init(fieldName, EntityOperator.EQUALS, value); return expr; } public static EntityExpr makeCondition(EntityCondition lhs, EntityJoinOperator operator, EntityCondition rhs) { - EntityExpr expr = new EntityExpr(); + EntityExpr expr = EntityExpr.entityExprFactory.object(); expr.init(lhs, operator, rhs); return expr; } public static <T extends EntityCondition> EntityConditionList<T> makeCondition(EntityJoinOperator operator, T... conditionList) { - EntityConditionList<T> ecl = new EntityConditionList<T>(); + EntityConditionList<T> ecl = EntityConditionList.entityConditionListFactory.object(); ecl.init(operator, conditionList); return ecl; } public static <T extends EntityCondition> EntityConditionList<T> makeCondition(T... conditionList) { - EntityConditionList<T> ecl = new EntityConditionList<T>(); + EntityConditionList<T> ecl = EntityConditionList.entityConditionListFactory.object(); ecl.init(EntityOperator.AND, conditionList); return ecl; } public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList, EntityJoinOperator operator) { - EntityConditionList<T> ecl = new EntityConditionList<T>(); + EntityConditionList<T> ecl = EntityConditionList.entityConditionListFactory.object(); ecl.init(conditionList, operator); return ecl; } public static <T extends EntityCondition> EntityConditionList<T> makeCondition(List<T> conditionList) { - EntityConditionList<T> ecl = new EntityConditionList<T>(); + EntityConditionList<T> ecl = EntityConditionList.entityConditionListFactory.object(); ecl.init(conditionList, EntityOperator.AND); return ecl; } public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityComparisonOperator compOp, EntityJoinOperator joinOp) { - EntityFieldMap efm = new EntityFieldMap(); + EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object(); efm.init(fieldMap, compOp, joinOp); return efm; } public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap, EntityJoinOperator joinOp) { - EntityFieldMap efm = new EntityFieldMap(); + EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object(); efm.init(fieldMap, EntityOperator.EQUALS, joinOp); return efm; } public static EntityFieldMap makeCondition(Map<String, ? extends Object> fieldMap) { - EntityFieldMap efm = new EntityFieldMap(); + EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object(); efm.init(fieldMap, EntityOperator.EQUALS, EntityOperator.AND); return efm; } public static EntityFieldMap makeCondition(EntityComparisonOperator compOp, EntityJoinOperator joinOp, Object... keysValues) { - EntityFieldMap efm = new EntityFieldMap(); + EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object(); efm.init(compOp, joinOp, keysValues); return efm; } public static EntityFieldMap makeCondition(EntityJoinOperator joinOp, Object... keysValues) { - EntityFieldMap efm = new EntityFieldMap(); + EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object(); efm.init(EntityOperator.EQUALS, joinOp, keysValues); return efm; } public static EntityFieldMap makeConditionMap(Object... keysValues) { - EntityFieldMap efm = new EntityFieldMap(); + EntityFieldMap efm = EntityFieldMap.entityFieldMapFactory.object(); efm.init(EntityOperator.EQUALS, EntityOperator.AND, keysValues); return efm; } public static EntityDateFilterCondition makeConditionDate(String fromDateName, String thruDateName) { - EntityDateFilterCondition edfc = new EntityDateFilterCondition(); + EntityDateFilterCondition edfc = EntityDateFilterCondition.entityDateFilterConditionFactory.object(); edfc.init(fromDateName, thruDateName); return edfc; } public static EntityWhereString makeConditionWhere(String sqlString) { - EntityWhereString ews = new EntityWhereString(); + EntityWhereString ews = EntityWhereString.entityWhereStringFactory.object(); ews.init(sqlString); return ews; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java?rev=660850&r1=660849&r2=660850&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionList.java Wed May 28 00:58:13 2008 @@ -21,6 +21,8 @@ import java.util.Iterator; import java.util.List; +import javolution.context.ObjectFactory; + /** * Encapsulates a list of EntityConditions to be used as a single EntityCondition combined as specified * @@ -28,6 +30,12 @@ public class EntityConditionList<T extends EntityCondition> extends EntityConditionListBase<T> { public static final String module = EntityConditionList.class.getName(); + protected static final ObjectFactory<EntityConditionList> entityConditionListFactory = new ObjectFactory<EntityConditionList>() { + protected EntityConditionList create() { + return new EntityConditionList(); + } + }; + protected EntityConditionList() { super(); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java?rev=660850&r1=660849&r2=660850&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java Wed May 28 00:58:13 2008 @@ -22,6 +22,8 @@ import java.util.List; import java.util.Map; +import javolution.context.ObjectFactory; + import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericModelException; @@ -30,6 +32,12 @@ public class EntityDateFilterCondition extends EntityCondition { + protected static final ObjectFactory<EntityDateFilterCondition> entityDateFilterConditionFactory = new ObjectFactory<EntityDateFilterCondition>() { + protected EntityDateFilterCondition create() { + return new EntityDateFilterCondition(); + } + }; + protected String fromDateName = null; protected String thruDateName = null; 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=660850&r1=660849&r2=660850&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 Wed May 28 00:58:13 2008 @@ -22,11 +22,14 @@ import java.util.List; import java.util.Map; +import javolution.context.ObjectFactory; + import org.ofbiz.base.util.Debug; import org.ofbiz.entity.EntityCryptoException; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericModelException; +import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.config.DatasourceInfo; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelField; @@ -38,6 +41,12 @@ public class EntityExpr extends EntityCondition { public static final String module = EntityExpr.class.getName(); + protected static final ObjectFactory<EntityExpr> entityExprFactory = new ObjectFactory<EntityExpr>() { + protected EntityExpr create() { + return new EntityExpr(); + } + }; + private Object lhs = null; private EntityOperator<?> operator = null; private Object rhs = null; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java?rev=660850&r1=660849&r2=660850&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldMap.java Wed May 28 00:58:13 2008 @@ -21,10 +21,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import javolution.context.ObjectFactory; import javolution.util.FastMap; import org.ofbiz.entity.util.EntityUtil; @@ -35,6 +35,12 @@ */ public class EntityFieldMap extends EntityConditionListBase<EntityExpr> { + protected static final ObjectFactory<EntityFieldMap> entityFieldMapFactory = new ObjectFactory<EntityFieldMap>() { + protected EntityFieldMap create() { + return new EntityFieldMap(); + } + }; + protected Map<String, ? extends Object> fieldMap = null; protected EntityFieldMap() { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java?rev=660850&r1=660849&r2=660850&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFieldValue.java Wed May 28 00:58:13 2008 @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; +import javolution.context.ObjectFactory; import javolution.lang.Reusable; import org.ofbiz.entity.GenericDelegator; @@ -37,12 +38,18 @@ */ public class EntityFieldValue extends EntityConditionValue implements Reusable { + protected static final ObjectFactory<EntityFieldValue> entityFieldValueFactory = new ObjectFactory<EntityFieldValue>() { + protected EntityFieldValue create() { + return new EntityFieldValue(); + } + }; + protected String fieldName = null; public static EntityFieldValue makeFieldValue(String fieldName) { - EntityFieldValue efv = new EntityFieldValue(); - efv.init(fieldName); - return efv; + EntityFieldValue efv = EntityFieldValue.entityFieldValueFactory.object(); + efv.init(fieldName); + return efv; } protected EntityFieldValue() {} Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java?rev=660850&r1=660849&r2=660850&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityFunction.java Wed May 28 00:58:13 2008 @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; +import javolution.context.ObjectFactory; import javolution.lang.Reusable; import org.ofbiz.entity.GenericDelegator; @@ -45,27 +46,32 @@ public static final int ID_UPPER = 3; public static final int ID_LOWER = 4; - public static EntityFunction<Integer> LENGTH(EntityConditionValue nested) { LENGTH ef = new LENGTH(); ef.init(nested); return ef; } - public static EntityFunction<Integer> LENGTH(Object value) { LENGTH ef = new LENGTH(); ef.init(value); return ef; } - public static EntityFunction<String> TRIM(EntityConditionValue nested) { TRIM ef = new TRIM(); ef.init(nested); return ef; } - public static EntityFunction<String> TRIM(Object value) { TRIM ef = new TRIM(); ef.init(value); return ef; } - public static EntityFunction<String> UPPER(EntityConditionValue nested) { UPPER ef = new UPPER(); ef.init(nested); return ef; } - public static EntityFunction<String> UPPER(Object value) { UPPER ef = new UPPER(); ef.init(value); return ef; } - public static EntityFunction<String> UPPER_FIELD(String fieldName) { UPPER ef = new UPPER(); ef.init(EntityFieldValue.makeFieldValue(fieldName)); return ef; } - public static EntityFunction<String> LOWER(EntityConditionValue nested) { LOWER ef = new LOWER(); ef.init(nested); return ef; } - public static EntityFunction<String> LOWER(Object value) { LOWER ef = new LOWER(); ef.init(value); return ef; } + public static EntityFunction<Integer> LENGTH(EntityConditionValue nested) { LENGTH ef = LENGTH.lengthFactory.object(); ef.init(nested); return ef; } + public static EntityFunction<Integer> LENGTH(Object value) { LENGTH ef = LENGTH.lengthFactory.object(); ef.init(value); return ef; } + public static EntityFunction<String> TRIM(EntityConditionValue nested) { TRIM ef = TRIM.trimFactory.object(); ef.init(nested); return ef; } + public static EntityFunction<String> TRIM(Object value) { TRIM ef = TRIM.trimFactory.object(); ef.init(value); return ef; } + public static EntityFunction<String> UPPER(EntityConditionValue nested) { UPPER ef = UPPER.upperFactory.object(); ef.init(nested); return ef; } + public static EntityFunction<String> UPPER(Object value) { UPPER ef = UPPER.upperFactory.object(); ef.init(value); return ef; } + public static EntityFunction<String> UPPER_FIELD(String fieldName) { UPPER ef = UPPER.upperFactory.object(); ef.init(EntityFieldValue.makeFieldValue(fieldName)); return ef; } + public static EntityFunction<String> LOWER(EntityConditionValue nested) { LOWER ef = LOWER.lowerFactory.object(); ef.init(nested); return ef; } + public static EntityFunction<String> LOWER(Object value) { LOWER ef = LOWER.lowerFactory.object(); ef.init(value); return ef; } public static class LENGTH extends EntityFunction<Integer> { public static Fetcher<Integer> FETCHER = new Fetcher<Integer>() { public Integer getValue(Object value) { return value.toString().length(); } }; + protected static final ObjectFactory<LENGTH> lengthFactory = new ObjectFactory<LENGTH>() { + protected LENGTH create() { + return new LENGTH(); + } + }; protected LENGTH() {} /** @deprecated Use EntityCondition.LENGTH() instead */ public LENGTH(EntityConditionValue nested) { init(nested); } /** @deprecated Use EntityCondition.LENGTH() instead */ public LENGTH(Object value) { init(value); } public void init(Object value) { - super.init(FETCHER, ID_LENGTH, "LENGTH", value); + super.init(FETCHER, ID_LENGTH, "LENGTH", value); } }; @@ -73,6 +79,11 @@ public static Fetcher<String> FETCHER = new Fetcher<String>() { public String getValue(Object value) { return value.toString().trim(); } }; + protected static final ObjectFactory<TRIM> trimFactory = new ObjectFactory<TRIM>() { + protected TRIM create() { + return new TRIM(); + } + }; protected TRIM() {} /** @deprecated Use EntityCondition.TRIM() instead */ public TRIM(EntityConditionValue nested) { init(nested); } @@ -87,6 +98,11 @@ public static Fetcher<String> FETCHER = new Fetcher<String>() { public String getValue(Object value) { return value.toString().toUpperCase(); } }; + protected static final ObjectFactory<UPPER> upperFactory = new ObjectFactory<UPPER>() { + protected UPPER create() { + return new UPPER(); + } + }; protected UPPER() {} /** @deprecated Use EntityCondition.UPPER() instead */ public UPPER(EntityConditionValue nested) { init(nested); } @@ -101,6 +117,11 @@ public static Fetcher<String> FETCHER = new Fetcher<String>() { public String getValue(Object value) { return value.toString().toLowerCase(); } }; + protected static final ObjectFactory<LOWER> lowerFactory = new ObjectFactory<LOWER>() { + protected LOWER create() { + return new LOWER(); + } + }; protected LOWER() {} /** @deprecated Use EntityCondition.LOWER() instead */ public LOWER(EntityConditionValue nested) { init(nested); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java?rev=660850&r1=660849&r2=660850&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityWhereString.java Wed May 28 00:58:13 2008 @@ -21,6 +21,8 @@ import java.util.List; import java.util.Map; +import javolution.context.ObjectFactory; + import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericModelException; @@ -40,6 +42,12 @@ */ public class EntityWhereString extends EntityCondition { + protected static final ObjectFactory<EntityWhereString> entityWhereStringFactory = new ObjectFactory<EntityWhereString>() { + protected EntityWhereString create() { + return new EntityWhereString(); + } + }; + protected String sqlString; protected EntityWhereString() {} |
Free forum by Nabble | Edit this page |