Refactored GenericDelegator:

1. Converted GenericDelegator to an interface. We already have DelegatorInterface, but it isn't being used anywhere. Removed DelegatorInterface.java.

2. Extracted the static, cached data from the GenericDelegator implementation and put it in its own class - DelegatorData. The GenericDelegator implementation holds a reference to the DelegatorData instance. This makes it possible to have per-thread instances of GenericDelegator.

3. Replaced the ThreadLocal variables with regular variables. ThreadLocal variables are no longer needed. Client code doesn't need to be concerned with pushing and popping the GenericDelegator state.

This commit paves the way for the forthcoming ExecutionContext.

User modifications will have to replace GenericDelegator.getGenericDelegator(...) with DelegatorFactory.getGenericDelegator(...). Also, replace the push code with the new setXxx methods, and remove the pop code. If modifications used DelegatorInterface, replace that with GenericDelegator.

Aside from those changes, this commit is backwards compatible.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@802567 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adrian Crum
2009-08-09 18:04:26 +00:00
parent b96f551de7
commit 6786aa4dbc
45 changed files with 3786 additions and 3473 deletions
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpSessionListener;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.webapp.stats.VisitHandler;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -58,7 +59,7 @@ public class CartEventListener implements HttpSessionListener {
String delegatorName = (String) session.getAttribute("delegatorName");
GenericDelegator delegator = null;
if (UtilValidate.isNotEmpty(delegatorName)) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
if (delegator == null) {
Debug.logError("Could not find delegator with delegatorName in session, not saving abandoned cart info.", module);
@@ -21,6 +21,7 @@ package org.ofbiz.order.shoppingcart;
import javolution.util.FastList;
import javolution.util.FastMap;
import org.ofbiz.base.util.*;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
@@ -275,7 +276,7 @@ public class ShoppingCart implements Serializable {
public GenericDelegator getDelegator() {
if (delegator == null) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
return delegator;
}
@@ -41,6 +41,7 @@ import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
@@ -2406,7 +2407,7 @@ public class ShoppingCartItem implements java.io.Serializable {
if (UtilValidate.isEmpty(delegatorName)) {
throw new IllegalStateException("Bad delegator name");
}
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
return delegator;
}
@@ -35,6 +35,7 @@ import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -500,7 +501,7 @@ public class PackingSession implements java.io.Serializable {
public GenericDelegator getDelegator() {
if (_delegator == null) {
_delegator = GenericDelegator.getGenericDelegator(delegatorName);
_delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
return _delegator;
}
@@ -32,6 +32,7 @@ import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -76,7 +77,7 @@ public class VerifyPickSession implements Serializable {
public GenericDelegator getDelegator() {
if (_delegator == null) {
_delegator = GenericDelegator.getGenericDelegator(delegatorName);
_delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
return _delegator;
}
@@ -34,6 +34,7 @@ import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilNumber;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -102,7 +103,7 @@ public class WeightPackageSession implements Serializable {
public GenericDelegator getDelegator() {
if (_delegator == null) {
_delegator = GenericDelegator.getGenericDelegator(delegatorName);
_delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
return _delegator;
}
@@ -36,6 +36,7 @@ import org.ofbiz.base.container.ContainerConfig;
import org.ofbiz.base.container.ContainerException;
import org.ofbiz.base.container.ContainerConfig.Container.Property;
import org.ofbiz.base.util.*;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.apache.catalina.Cluster;
@@ -168,7 +169,7 @@ public class CatalinaContainer implements Container {
//int debug = ContainerConfig.getPropertyValue(cc, "debug", 0);
// grab some global context settings
this.delegator = GenericDelegator.getGenericDelegator(ContainerConfig.getPropertyValue(cc, "delegator-name", "default"));
this.delegator = DelegatorFactory.getGenericDelegator(ContainerConfig.getPropertyValue(cc, "delegator-name", "default"));
this.contextReloadable = ContainerConfig.getPropertyValue(cc, "apps-context-reloadable", false);
this.crossContext = ContainerConfig.getPropertyValue(cc, "apps-cross-context", true);
this.distribute = ContainerConfig.getPropertyValue(cc, "apps-distributable", true);
@@ -0,0 +1,110 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.ofbiz.entity;
import java.util.Map;
import javolution.util.FastMap;
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.cache.Cache;
import org.ofbiz.entity.config.DelegatorInfo;
import org.ofbiz.entity.config.EntityConfigUtil;
import org.ofbiz.entity.eca.EntityEcaHandler;
import org.ofbiz.entity.model.ModelGroupReader;
import org.ofbiz.entity.model.ModelReader;
import org.ofbiz.entity.util.DistributedCacheClear;
import org.ofbiz.entity.util.EntityCrypto;
import org.ofbiz.entity.util.SequenceUtil;
/** Data source for the DelegatorImpl Class. */
public class DelegatorData implements Cloneable {
public static final String module = DelegatorData.class.getName();
/**
* the delegatorDataCache will now be a HashMap, allowing reload of
* definitions, but the delegator will always be the same object for the
* given name
*/
protected static final Map<String, DelegatorData> delegatorDataCache = FastMap.newInstance();
/**
* keeps a list of field key sets used in the by and cache, a Set (of Sets
* of fieldNames) for each entityName
*/
protected Map<?, ?> andCacheFieldSets = FastMap.newInstance();
protected Cache cache = null;
protected EntityCrypto crypto = null;
protected DelegatorInfo delegatorInfo = null;
protected String delegatorName = null;
protected DistributedCacheClear distributedCacheClear = null;
protected EntityEcaHandler<?> entityEcaHandler = null;
protected ModelGroupReader modelGroupReader = null;
protected ModelReader modelReader = null;
protected String originalDelegatorName = null;
protected SequenceUtil sequencer = null;
protected boolean initialized = false;
public static synchronized DelegatorData getInstance(String delegatorName) throws GenericEntityException {
if (delegatorName == null) {
delegatorName = "default";
Debug.logWarning(new Exception("Location where getting delegator with null name"), "Got a getGenericDelegator call with a null delegatorName, assuming \"default\" for the name.", module);
}
DelegatorData delegatorData = delegatorDataCache.get(delegatorName);
if (delegatorData == null) {
if (Debug.infoOn()) {
Debug.logInfo("Creating new delegator data instance [" + delegatorName + "] (" + Thread.currentThread().getName() + ")", module);
}
delegatorData = new DelegatorData(delegatorName);
delegatorDataCache.put(delegatorName, delegatorData);
}
return delegatorData;
}
/** Only allow creation through the factory method */
protected DelegatorData() {
}
/** Only allow creation through the factory method */
protected DelegatorData(String delegatorName) throws GenericEntityException {
this.delegatorName = delegatorName;
this.originalDelegatorName = delegatorName;
this.modelReader = ModelReader.getModelReader(delegatorName);
this.modelGroupReader = ModelGroupReader.getModelGroupReader(delegatorName);
this.cache = new Cache(delegatorName);
this.delegatorInfo = EntityConfigUtil.getDelegatorInfo(this.delegatorName);
}
@Override
protected Object clone() {
DelegatorData delegatorData = new DelegatorData();
delegatorData.modelReader = this.modelReader;
delegatorData.modelGroupReader = this.modelGroupReader;
delegatorData.delegatorName = this.delegatorName;
delegatorData.delegatorInfo = this.delegatorInfo;
delegatorData.cache = this.cache;
delegatorData.andCacheFieldSets = this.andCacheFieldSets;
delegatorData.distributedCacheClear = this.distributedCacheClear;
delegatorData.originalDelegatorName = this.originalDelegatorName;
delegatorData.entityEcaHandler = this.entityEcaHandler;
delegatorData.sequencer = this.sequencer;
delegatorData.crypto = this.crypto;
return delegatorData;
}
}
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.ofbiz.entity;
import org.ofbiz.base.util.Debug;
/** GenericDelegator Factory Class. */
public class DelegatorFactory {
public static final String module = DelegatorFactory.class.getName();
public static GenericDelegator getGenericDelegator(String delegatorName) {
if (delegatorName == null) {
delegatorName = "default";
Debug.logWarning(new Exception("Location where getting delegator with null name"), "Got a getGenericDelegator call with a null delegatorName, assuming default for the name.", module);
}
DelegatorData delegatorData = null;
try {
delegatorData = DelegatorData.getInstance(delegatorName);
} catch (GenericEntityException e) {
Debug.logError(e, "Could not create delegator with name \"" + delegatorName + "\": ", module);
}
if (delegatorData != null) {
return new DelegatorImpl(delegatorData);
}
return null;
}
}
File diff suppressed because it is too large Load Diff
@@ -1,236 +0,0 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*******************************************************************************/
package org.ofbiz.entity;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.ofbiz.entity.cache.Cache;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.datasource.GenericHelper;
import org.ofbiz.entity.model.ModelEntity;
import org.ofbiz.entity.model.ModelFieldType;
import org.ofbiz.entity.model.ModelGroupReader;
import org.ofbiz.entity.model.ModelReader;
import org.ofbiz.entity.util.EntityFindOptions;
import org.ofbiz.entity.util.EntityListIterator;
import org.ofbiz.entity.util.SequenceUtil;
/**
* Delegator Interface
*/
public interface DelegatorInterface {
String getDelegatorName();
ModelReader getModelReader();
ModelGroupReader getModelGroupReader();
ModelEntity getModelEntity(String entityName);
String getEntityGroupName(String entityName);
Map<String, ModelEntity> getModelEntityMapByGroup(String groupName) throws GenericEntityException;
String getGroupHelperName(String groupName);
String getEntityHelperName(String entityName);
String getEntityHelperName(ModelEntity entity);
GenericHelper getEntityHelper(String entityName) throws GenericEntityException;
GenericHelper getEntityHelper(ModelEntity entity) throws GenericEntityException;
ModelFieldType getEntityFieldType(ModelEntity entity, String type) throws GenericEntityException;
Collection<String> getEntityFieldTypeNames(ModelEntity entity) throws GenericEntityException;
GenericValue makeValue(String entityName);
GenericValue makeValue(String entityName, Object... fields);
GenericValue makeValue(String entityName, Map<String, ? extends Object> fields);
GenericValue makeValueSingle(String entityName, Object singlePkValue);
GenericValue makeValidValue(String entityName, Object... fields);
GenericValue makeValidValue(String entityName, Map<String, ? extends Object> fields);
GenericPK makePK(String entityName);
GenericPK makePK(String entityName, Object... fields);
GenericPK makePK(String entityName, Map<String, ? extends Object> fields);
GenericPK makePKSingle(String entityName, Object singlePkValue);
GenericValue create(String entityName, Object... fields) throws GenericEntityException;
GenericValue create(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException;
GenericValue createSingle(String entityName, Object singlePkValue) throws GenericEntityException;
GenericValue create(GenericValue value) throws GenericEntityException;
GenericValue create(GenericValue value, boolean doCacheClear) throws GenericEntityException;
GenericValue create(GenericPK primaryKey) throws GenericEntityException;
GenericValue create(GenericPK primaryKey, boolean doCacheClear) throws GenericEntityException;
GenericValue createOrStore(GenericValue value, boolean doCacheClear) throws GenericEntityException;
GenericValue createOrStore(GenericValue value) throws GenericEntityException;
GenericValue findOne(String entityName, Map<String, ? extends Object> fields, boolean useCache) throws GenericEntityException;
GenericValue findByPrimaryKey(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException;
GenericValue findByPrimaryKeyCache(String entityName, Object... fields) throws GenericEntityException;
GenericValue findByPrimaryKeyCache(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException;
GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEntityException;
int removeByPrimaryKey(GenericPK primaryKey) throws GenericEntityException;
int removeByPrimaryKey(GenericPK primaryKey, boolean doCacheClear) throws GenericEntityException;
int removeValue(GenericValue value) throws GenericEntityException;
int removeValue(GenericValue value, boolean doCacheClear) throws GenericEntityException;
List<GenericValue> findByAnd(String entityName, Object... fields) throws GenericEntityException;
List<GenericValue> findByAnd(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException;
List<GenericValue> findByAnd(String entityName, Map<String, ? extends Object> fields, List<String> orderBy) throws GenericEntityException;
//List<GenericValue> findByAnd(ModelEntity modelEntity, Map<String, ? extends Object> fields, List<String> orderBy) throws GenericEntityException;
List<GenericValue> findByOr(String entityName, Map<String, ? extends Object> fields, List<String> orderBy) throws GenericEntityException;
List<GenericValue> findByAndCache(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException;
List<GenericValue> findByAndCache(String entityName, Map<String, ? extends Object> fields, List<String> orderBy) throws GenericEntityException;
EntityListIterator find(String entityName, EntityCondition whereEntityCondition,
EntityCondition havingEntityCondition, Set<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions)
throws GenericEntityException;
List<GenericValue> findList(String entityName, EntityCondition entityCondition,
Set<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions, boolean useCache)
throws GenericEntityException;
int removeByAnd(String entityName, Object... fields) throws GenericEntityException;
int removeByAnd(String entityName, Map<String, ? extends Object> fields) throws GenericEntityException;
int removeByAnd(String entityName, boolean doCacheClear, Object... fields) throws GenericEntityException;
int removeByAnd(String entityName, Map<String, ? extends Object> fields, boolean doCacheClear) throws GenericEntityException;
int removeByCondition(String entityName, EntityCondition condition) throws GenericEntityException;
int removeByCondition(String entityName, EntityCondition condition, boolean doCacheClear) throws GenericEntityException;
List<GenericValue> getMultiRelation(GenericValue value, String relationNameOne, String relationNameTwo, List<String> orderBy) throws GenericEntityException;
List<GenericValue> getRelated(String relationName, Map<String, ? extends Object> byAndFields, List<String> orderBy, GenericValue value) throws GenericEntityException;
GenericPK getRelatedDummyPK(String relationName, Map<String, ? extends Object> byAndFields, GenericValue value) throws GenericEntityException;
List<GenericValue> getRelatedCache(String relationName, GenericValue value) throws GenericEntityException;
GenericValue getRelatedOne(String relationName, GenericValue value) throws GenericEntityException;
GenericValue getRelatedOneCache(String relationName, GenericValue value) throws GenericEntityException;
int removeRelated(String relationName, GenericValue value) throws GenericEntityException;
int removeRelated(String relationName, GenericValue value, boolean doCacheClear) throws GenericEntityException;
void refresh(GenericValue value) throws GenericEntityException;
void refresh(GenericValue value, boolean doCacheClear) throws GenericEntityException;
int store(GenericValue value) throws GenericEntityException;
int store(GenericValue value, boolean doCacheClear) throws GenericEntityException;
int storeAll(List<GenericValue> values) throws GenericEntityException;
int storeAll(List<GenericValue> values, boolean doCacheClear) throws GenericEntityException;
int storeByCondition(String entityName, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException;
int storeByCondition(String entityName, Map<String, ? extends Object> fieldsToSet, EntityCondition condition, boolean doCacheClear) throws GenericEntityException;
int removeAll(String entityName) throws GenericEntityException;
int removeAll(List<? extends GenericEntity> dummyPKs) throws GenericEntityException;
int removeAll(List<? extends GenericEntity> dummyPKs, boolean doCacheClear) throws GenericEntityException;
void clearAllCaches();
void clearAllCaches(boolean distribute);
void clearCacheLine(String entityName);
void clearCacheLine(String entityName, Object... fields);
void clearCacheLine(String entityName, Map<String, ? extends Object> fields);
void clearCacheLineFlexible(GenericEntity dummyPK);
void clearCacheLineFlexible(GenericEntity dummyPK, boolean distribute);
void clearCacheLine(GenericPK primaryKey);
void clearCacheLine(GenericPK primaryKey, boolean distribute);
void clearCacheLine(GenericValue value);
void clearCacheLine(GenericValue value, boolean distribute);
void clearCacheLineByCondition(String entityName, EntityCondition condition);
void clearAllCacheLinesByDummyPK(Collection<GenericPK> dummyPKs);
void clearAllCacheLinesByValue(Collection<GenericValue> values);
GenericValue getFromPrimaryKeyCache(GenericPK primaryKey);
String getNextSeqId(String seqName);
String getNextSeqId(String seqName, long staggerMax);
Long getNextSeqIdLong(String seqName);
Long getNextSeqIdLong(String seqName, long staggerMax);
void setSequencer(SequenceUtil sequencer);
void refreshSequencer();
Cache getCache();
}
File diff suppressed because it is too large Load Diff
@@ -285,7 +285,7 @@ public class GenericEntity extends Observable implements Map<String, Object>, Lo
public GenericDelegator getDelegator() {
if (internalDelegator == null) {
if (delegatorName == null) delegatorName = "default";
if (delegatorName != null) internalDelegator = GenericDelegator.getGenericDelegator(delegatorName);
if (delegatorName != null) internalDelegator = DelegatorFactory.getGenericDelegator(delegatorName);
if (internalDelegator == null) {
throw new IllegalStateException("[GenericEntity.getDelegator] could not find delegator with name " + delegatorName);
}
@@ -300,7 +300,7 @@ public class GenericEntity extends Observable implements Map<String, Object>, Lo
this.internalDelegator = internalDelegator;
}
public Object get(String name) {
protected Object getFieldValue(String name) {
if (getModelEntity().getField(name) == null) {
throw new IllegalArgumentException("[GenericEntity.get] \"" + name + "\" is not a field of " + entityName);
}
@@ -696,7 +696,7 @@ public class GenericEntity extends Observable implements Map<String, Object>, Lo
public Object get(String name, String resource, Locale locale) {
Object fieldValue = null;
try {
fieldValue = get(name);
fieldValue = getFieldValue(name);
} catch (IllegalArgumentException e) {
if (Debug.verboseOn()) {
Debug.logVerbose(e, "The field name (or key) [" + name + "] is not valid for entity [" + this.getEntityName() + "], printing IllegalArgumentException instead of throwing it because Map interface specification does not allow throwing that exception.", module);
@@ -754,7 +754,7 @@ public class GenericEntity extends Observable implements Map<String, Object>, Lo
while (iter != null && iter.hasNext()) {
ModelField curField = iter.next();
keyBuffer.append('.');
keyBuffer.append(this.get(curField.getName()));
keyBuffer.append(this.getFieldValue(curField.getName()));
}
String bundleKey = keyBuffer.toString();
@@ -1337,7 +1337,7 @@ public class GenericEntity extends Observable implements Map<String, Object>, Lo
public Object get(Object key) {
try {
return this.get((String) key);
return this.get((String)key, this.getDelegator().getLocale());
} catch (IllegalArgumentException e) {
if (Debug.verboseOn()) {
Debug.logVerbose(e, "The field name (or key) [" + key + "] is not valid for entity [" + this.getEntityName() + "], printing IllegalArgumentException instead of throwing it because Map interface specification does not allow throwing that exception.", module);
@@ -19,6 +19,7 @@
package org.ofbiz.entity.cache;
import org.ofbiz.base.util.cache.UtilCache;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
public abstract class AbstractCache<K, V> {
@@ -31,7 +32,7 @@ public abstract class AbstractCache<K, V> {
}
public GenericDelegator getDelegator() {
return GenericDelegator.getGenericDelegator(delegatorName);
return DelegatorFactory.getGenericDelegator(delegatorName);
}
public void remove(String entityName) {
@@ -27,6 +27,7 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.ObjectType;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.EntityCryptoException;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericEntityException;
@@ -251,7 +252,7 @@ public class EntityExpr extends EntityCondition {
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
delegator = GenericDelegator.getGenericDelegator("default");
delegator = DelegatorFactory.getGenericDelegator("default");
}
String fieldName = null;
@@ -32,6 +32,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.collections.FlexibleMapAccessor;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -136,7 +137,7 @@ public abstract class ListFinder extends Finder {
resultSetType = ResultSet.TYPE_FORWARD_ONLY;
if (delegatorName != null && delegatorName.length() > 0) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
EntityCondition whereEntityCondition = getWhereEntityCondition(context, modelEntity, delegator.getModelFieldTypeReader(modelEntity));
@@ -35,6 +35,7 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.UtilURL;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.jdbc.DatabaseUtil;
@@ -224,7 +225,7 @@ public class EntityDataLoadContainer implements Container {
String delegatorNameToUse = overrideDelegator != null ? overrideDelegator : delegatorName;
String groupNameToUse = overrideGroup != null ? overrideGroup : entityGroupName;
GenericDelegator delegator = GenericDelegator.getGenericDelegator(delegatorNameToUse);
GenericDelegator delegator = DelegatorFactory.getGenericDelegator(delegatorNameToUse);
if (delegator == null) {
throw new ContainerException("Invalid delegator name!");
}
@@ -35,6 +35,7 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericEntityException;
@@ -148,7 +149,7 @@ public class EntitySyncContext {
// what to do with the delegatorName? this is the delegatorName to use in this service...
String delegatorName = (String) context.get("delegatorName");
if (UtilValidate.isNotEmpty(delegatorName)) {
this.delegator = GenericDelegator.getGenericDelegator(delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
@@ -41,6 +41,7 @@ import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.UtilURL;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericEntityException;
@@ -133,7 +134,7 @@ public class EntitySyncServices {
GenericDelegator delegator = dctx.getDelegator();
String overrideDelegatorName = (String) context.get("delegatorName");
if (UtilValidate.isNotEmpty(overrideDelegatorName)) {
delegator = GenericDelegator.getGenericDelegator(overrideDelegatorName);
delegator = DelegatorFactory.getGenericDelegator(overrideDelegatorName);
if (delegator == null) {
return ServiceUtil.returnError("Could not find delegator with specified name " + overrideDelegatorName);
}
@@ -29,6 +29,7 @@ import org.ofbiz.base.container.Container;
import org.ofbiz.base.container.ContainerConfig;
import org.ofbiz.base.container.ContainerException;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.service.GenericDispatcher;
import org.ofbiz.service.LocalDispatcher;
@@ -60,7 +61,7 @@ public abstract class XuiContainer implements Container {
// get the delegator
String delegatorName = ContainerConfig.getPropertyValue(cc, "delegator-name", "default");
GenericDelegator delegator = GenericDelegator.getGenericDelegator(delegatorName);
GenericDelegator delegator = DelegatorFactory.getGenericDelegator(delegatorName);
// get the dispatcher
String dispatcherName = ContainerConfig.getPropertyValue(cc, "dispatcher-name", "xui-dispatcher");
@@ -26,6 +26,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.collections.FlexibleMapAccessor;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.finder.EntityFinderUtil.Condition;
@@ -101,7 +102,7 @@ public class EntityCount extends MethodOperation {
String delegatorName = this.delegatorNameExdr.expandString(context);
if (delegatorName != null && delegatorName.length() > 0) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
ModelEntity modelEntity = delegator.getModelEntity(entityName);
@@ -28,6 +28,7 @@ import org.ofbiz.base.location.FlexibleLocation;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.util.EntityDataAssert;
import org.ofbiz.entity.util.EntitySaxReader;
@@ -86,7 +87,7 @@ public class EntityData extends MethodOperation {
GenericDelegator delegator = methodContext.getDelegator();
if (delegatorName != null && delegatorName.length() > 0) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
URL dataUrl = null;
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -87,7 +88,7 @@ public class FindByAnd extends MethodOperation {
GenericDelegator delegator = methodContext.getDelegator();
if (delegatorName != null && delegatorName.length() > 0) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
try {
@@ -25,6 +25,7 @@ import java.util.Map;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericValue;
@@ -78,7 +79,7 @@ public class FindByPrimaryKey extends MethodOperation {
GenericDelegator delegator = methodContext.getDelegator();
if (delegatorName != null && delegatorName.length() > 0) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
Map<String, ? extends Object> inMap = mapAcsr.get(methodContext);
@@ -34,6 +34,7 @@ import org.ofbiz.base.util.UtilTimer;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.collections.LRUMap;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -104,7 +105,7 @@ public class ServiceDispatcher {
try {
GenericDelegator origDelegator = this.delegator;
if (!this.delegator.getOriginalDelegatorName().equals(this.delegator.getDelegatorName())) {
origDelegator = GenericDelegator.getGenericDelegator(this.delegator.getOriginalDelegatorName());
origDelegator = DelegatorFactory.getGenericDelegator(this.delegator.getOriginalDelegatorName());
}
this.jm = JobManager.getInstance(origDelegator, enableJM);
} catch (GeneralRuntimeException e) {
@@ -276,11 +277,12 @@ public class ServiceDispatcher {
// get eventMap once for all calls for speed, don't do event calls if it is null
Map<String, List<ServiceEcaRule>> eventMap = ServiceEcaUtil.getServiceEventMap(modelService.name);
// check the locale
Locale locale = this.checkLocale(context);
// setup the engine and context
DispatchContext ctx = localContext.get(localName);
GenericDelegator delegator = ctx.getDelegator();
Locale locale = this.checkLocale(context);
delegator.setLocale(locale);
GenericEngine engine = this.getGenericEngine(modelService.engineName);
// set IN attributes with default-value as applicable
@@ -356,7 +358,7 @@ public class ServiceDispatcher {
// now that we have authed, if there is a userLogin, set the EE userIdentifier
if (userLogin != null && userLogin.getString("userLoginId") != null) {
GenericDelegator.pushUserIdentifier(userLogin.getString("userLoginId"));
delegator.setUserIdentifier(userLogin.getString("userLoginId"));
}
// pre-validate ECA
@@ -551,9 +553,6 @@ public class ServiceDispatcher {
// call notifications -- event is determined from the result (success, error, fail)
modelService.evalNotifications(this.getLocalContext(localName), context, result);
// clear out the EE userIdentifier
GenericDelegator.popUserIdentifier();
}
} catch (GenericTransactionException te) {
Debug.logError(te, "Problems with the transaction", module);
@@ -35,6 +35,7 @@ import org.ofbiz.base.container.ContainerException;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.GenericEntityException;
@@ -85,7 +86,7 @@ public class JavaMailContainer implements Container {
String delegatorName = ContainerConfig.getPropertyValue(cfg, "delegator-name", "default");
this.deleteMail = "true".equals(ContainerConfig.getPropertyValue(cfg, "delete-mail", "false"));
this.delegator = GenericDelegator.getGenericDelegator(delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(delegatorName);
this.dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherName, delegator);
this.timerDelay = (long) ContainerConfig.getPropertyValue(cfg, "poll-delay", 300000);
this.maxSize = (long) ContainerConfig.getPropertyValue(cfg, "maxSize", 1000000); // maximum size in bytes
@@ -29,6 +29,7 @@ import javax.naming.NamingException;
import org.ofbiz.base.container.Container;
import org.ofbiz.base.container.ContainerConfig;
import org.ofbiz.base.container.ContainerException;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.service.GenericDispatcher;
import org.ofbiz.service.LocalDispatcher;
@@ -120,7 +121,7 @@ public class RmiServiceContainer implements Container {
}
// get the delegator for this container
GenericDelegator delegator = GenericDelegator.getGenericDelegator(delegatorProp.value);
GenericDelegator delegator = DelegatorFactory.getGenericDelegator(delegatorProp.value);
// create the LocalDispatcher
LocalDispatcher dispatcher = GenericDispatcher.getLocalDispatcher(name, delegator);
@@ -33,6 +33,7 @@ import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.testtools.EntityTestCase;
import org.ofbiz.service.GenericDispatcher;
@@ -68,7 +69,7 @@ public class ModelTestSuite {
String uniqueSuffix = "-" + RandomStringUtils.randomAlphanumeric(10);
this.delegator = GenericDelegator.getGenericDelegator(this.originalDelegatorName).makeTestDelegator(this.originalDelegatorName + uniqueSuffix);
this.delegator = DelegatorFactory.getGenericDelegator(this.originalDelegatorName).makeTestDelegator(this.originalDelegatorName + uniqueSuffix);
this.dispatcher = GenericDispatcher.getLocalDispatcher(originalDispatcherName + uniqueSuffix, delegator);
for (Element testCaseElement : UtilXml.childElementList(mainElement, UtilMisc.toSet("test-case", "test-group"))) {
@@ -50,6 +50,7 @@ import static org.ofbiz.base.util.UtilGenerics.checkMap;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilObject;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.security.Security;
import org.ofbiz.security.SecurityConfigurationException;
@@ -329,7 +330,7 @@ public class ContextFilter implements Filter {
delegatorName = "default";
}
if (Debug.verboseOn()) Debug.logVerbose("Setup Entity Engine Delegator with name " + delegatorName, module);
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
config.getServletContext().setAttribute("delegator", delegator);
if (delegator == null) {
Debug.logError("[ContextFilter.init] ERROR: delegator factory returned null for delegatorName \"" + delegatorName + "\"", module);
@@ -36,6 +36,7 @@ import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilJ2eeCompat;
import org.ofbiz.base.util.UtilTimer;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.transaction.GenericTransactionException;
@@ -111,11 +112,6 @@ public class ControlServlet extends HttpServlet {
GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
//Debug.log("Cert Chain: " + request.getAttribute("javax.servlet.request.X509Certificate"), module);
// set the Entity Engine user info if we have a userLogin
if (userLogin != null) {
GenericDelegator.pushUserIdentifier(userLogin.getString("userLoginId"));
}
// workaraound if we are in the root webapp
String webappName = UtilHttp.getApplicationName(request);
@@ -148,7 +144,7 @@ public class ControlServlet extends HttpServlet {
GenericDelegator delegator = null;
String delegatorName = (String) session.getAttribute("delegatorName");
if (UtilValidate.isNotEmpty(delegatorName)) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
if (delegator == null) {
delegator = (GenericDelegator) getServletContext().getAttribute("delegator");
@@ -194,10 +190,15 @@ public class ControlServlet extends HttpServlet {
UtilHttp.setInitialRequestInfo(request);
VisitHandler.getVisitor(request, response);
// set the Entity Engine user info if we have a userLogin
String visitId = VisitHandler.getVisitId(session);
if (UtilValidate.isNotEmpty(visitId)) {
GenericDelegator.pushSessionIdentifier(visitId);
if (delegator != null) {
// set the GenericDelegator properties
String visitId = VisitHandler.getVisitId(session);
if (UtilValidate.isNotEmpty(visitId)) {
delegator.setSessionIdentifier(visitId);
}
if (userLogin != null) {
delegator.setUserIdentifier(userLogin.getString("userLoginId"));
}
}
// display details on the servlet objects
@@ -310,10 +311,6 @@ public class ControlServlet extends HttpServlet {
}
}
if (Debug.timingOn()) timer.timerString("[" + rname + "] Request Done", module);
// sanity check 2: make sure there are no user or session infos in the delegator, ie clear the thread
GenericDelegator.clearUserIdentifierStack();
GenericDelegator.clearSessionIdentifierStack();
}
/**
@@ -107,6 +107,8 @@ public class RequestHandler {
GenericValue userLogin, GenericDelegator delegator) throws RequestHandlerException {
HttpSession session = request.getSession();
Locale locale = UtilHttp.getLocale(request);
delegator.setLocale(locale);
// get the controllerConfig once for this method so we don't have to get it over and over inside the method
ConfigXMLReader.ControllerConfig controllerConfig = this.getControllerConfig();
@@ -180,7 +182,6 @@ public class RequestHandler {
// If the request method was POST then return an error to avoid problems with XSRF where the request may have come from another machine/program and had the same session ID but was not encrypted as it should have been (we used to let it pass to not lose data since it was too late to protect that data anyway)
if (request.getMethod().equalsIgnoreCase("POST")) {
// we can't redirect with the body parameters, and for better security from XSRF, just return an error message
Locale locale = UtilHttp.getLocale(request);
String errMsg = UtilProperties.getMessage("WebappUiLabels", "requestHandler.InsecureFormPostToSecureRequest", locale);
Debug.logError("Got a insecure (non-https) form POST to a secure (http) request [" + requestMap.uri + "], returning error", module);
@@ -387,7 +388,6 @@ public class RequestHandler {
// check to see if there is an "error" response, if so go there and make an request error message
if (requestMap.requestResponseMap.containsKey("error")) {
eventReturn = "error";
Locale locale = UtilHttp.getLocale(request);
String errMsg = UtilProperties.getMessage("WebappUiLabels", "requestHandler.error_call_event", locale);
request.setAttribute("_ERROR_MESSAGE_", errMsg + ": " + e.toString());
} else {
@@ -43,6 +43,7 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntity;
import org.ofbiz.entity.GenericValue;
@@ -117,7 +118,7 @@ public class CoreEvents {
return "error";
}
GenericDelegator delegator = GenericDelegator.getGenericDelegator(delegatorName);
GenericDelegator delegator = DelegatorFactory.getGenericDelegator(delegatorName);
if (delegator == null) {
String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.no_delegator_name_defined", locale);
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletResponse;
import javolution.util.FastMap;
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.service.GenericDispatcher;
import org.ofbiz.service.GenericServiceException;
@@ -52,7 +53,7 @@ public class ServiceStreamHandler implements EventHandler {
public void init(ServletContext context) throws EventHandlerException {
String delegatorName = context.getInitParameter("entityDelegatorName");
this.delegator = GenericDelegator.getGenericDelegator(delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(delegatorName);
this.dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherName, delegator);
}
@@ -49,6 +49,7 @@ import org.apache.xmlrpc.server.XmlRpcNoSuchHandlerException;
import org.apache.xmlrpc.util.HttpUtil;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericDispatcher;
@@ -74,7 +75,7 @@ public class XmlRpcEventHandler extends XmlRpcHttpServer implements EventHandler
public void init(ServletContext context) throws EventHandlerException {
String delegatorName = context.getInitParameter("entityDelegatorName");
this.delegator = GenericDelegator.getGenericDelegator(delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(delegatorName);
this.dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherName, delegator);
this.setHandlerMapping(new ServiceRpcHandler());
@@ -33,6 +33,7 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -353,7 +354,7 @@ public class ServerHitBin {
public GenericDelegator getDelegator() {
if (this.delegator == null) {
this.delegator = GenericDelegator.getGenericDelegator(this.delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(this.delegatorName);
}
// if still null, then we have a problem
if (this.delegator == null) {
@@ -32,6 +32,7 @@ import org.ofbiz.base.util.UtilHttp;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -107,7 +108,7 @@ public class VisitHandler {
// first try the session attribute delegatorName
String delegatorName = (String) session.getAttribute("delegatorName");
if (UtilValidate.isNotEmpty(delegatorName)) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
// then try the ServletContext attribute delegator, should always be there...
@@ -199,7 +200,7 @@ public class VisitHandler {
String delegatorName = (String) session.getAttribute("delegatorName");
if (delegator == null && UtilValidate.isNotEmpty(delegatorName)) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
if (delegator == null) {
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpSession;
import org.ofbiz.base.util.CachedClassLoader;
import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.security.Security;
import org.ofbiz.security.SecurityFactory;
@@ -67,7 +68,7 @@ public class WebDavServlet extends GenericServlet {
Thread.currentThread().setContextClassLoader(loader);
ServletContext context = this.getServletContext();
String delegatorName = context.getInitParameter("entityDelegatorName");
this.delegator = GenericDelegator.getGenericDelegator(delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(delegatorName);
String dispatcherName = context.getInitParameter("localDispatcherName");
this.dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherName, this.delegator);
this.security = SecurityFactory.getInstance(this.delegator);
@@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletRequest;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -59,7 +60,7 @@ public class WebslingerContextMapper extends AbstractMappingWebslingerServletCon
System.err.println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
servletContext = config.getServletContext();
String delegatorName = servletContext.getInitParameter("entityDelegatorName");
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
if (readerFiles != null) {
for (String reader: CollectionUtil.split(readerFiles, ";")) {
@@ -103,7 +104,7 @@ public class WebslingerContextMapper extends AbstractMappingWebslingerServletCon
@Override
protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
OfbizLayout ofbizLayout = (OfbizLayout) layout;
GenericDelegator delegator = GenericDelegator.getGenericDelegator(ofbizLayout.delegatorName);
GenericDelegator delegator = DelegatorFactory.getGenericDelegator(ofbizLayout.delegatorName);
context.setAttribute("delegator", delegator);
context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator, globalReaderURLs));
context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
@@ -62,6 +62,7 @@ import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilURL;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilProperties.UtilResourceBundle;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -349,7 +350,7 @@ public class WebToolsServices {
}
String groupNameToUse = overrideGroup != null ? overrideGroup : "org.ofbiz";
GenericDelegator delegator = UtilValidate.isNotEmpty(overrideDelegator) ? GenericDelegator.getGenericDelegator(overrideDelegator) : dctx.getDelegator();
GenericDelegator delegator = UtilValidate.isNotEmpty(overrideDelegator) ? DelegatorFactory.getGenericDelegator(overrideDelegator) : dctx.getDelegator();
String helperName = delegator.getGroupHelperName(groupNameToUse);
if (helperName == null) {
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.shark.audit;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
@@ -40,7 +41,7 @@ public abstract class AuditEntityObject {
public GenericDelegator getGenericDelegator() {
if (this.delegator == null && delegatorName != null) {
this.delegator = GenericDelegator.getGenericDelegator(delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
return this.delegator;
}
@@ -40,6 +40,7 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralRuntimeException;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -107,7 +108,7 @@ public class SharkContainer implements Container, Runnable
}
// get the delegator and dispatcher objects
SharkContainer.delegator = GenericDelegator.getGenericDelegator(delegatorProp.value);
SharkContainer.delegator = DelegatorFactory.getGenericDelegator(delegatorProp.value);
try {
SharkContainer.dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherProp.value, SharkContainer.delegator);
} catch (GenericServiceException e) {
@@ -18,6 +18,7 @@
*******************************************************************************/
package org.ofbiz.shark.instance;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericDelegator;
@@ -39,7 +40,7 @@ public abstract class InstanceEntityObject {
public GenericDelegator getGenericDelegator() {
if (this.delegator == null && delegatorName != null) {
this.delegator = GenericDelegator.getGenericDelegator(delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
return this.delegator;
}
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
@@ -146,7 +147,7 @@ public abstract class AbstractRequester implements WfRequester, Serializable {
protected synchronized GenericDelegator getDelegator() {
if (this.delegator == null && this.delegatorName != null) {
this.delegator = GenericDelegator.getGenericDelegator(this.delegatorName);
this.delegator = DelegatorFactory.getGenericDelegator(this.delegatorName);
}
return this.delegator;
}
@@ -28,6 +28,7 @@ import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -145,7 +146,7 @@ public class WebPosSession {
public GenericDelegator getDelegator() {
if (UtilValidate.isEmpty(delegator)) {
delegator = GenericDelegator.getGenericDelegator(delegatorName);
delegator = DelegatorFactory.getGenericDelegator(delegatorName);
}
return delegator;
}
@@ -35,6 +35,7 @@ import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilURL;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.DelegatorFactory;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
@@ -1312,7 +1313,7 @@ public class XpdlReader {
if (args.length > 0)
sampleFileName = args[0];
List values = readXpdl(UtilURL.fromFilename(sampleFileName), GenericDelegator.getGenericDelegator("default"));
List values = readXpdl(UtilURL.fromFilename(sampleFileName), DelegatorFactory.getGenericDelegator("default"));
Iterator viter = values.iterator();
while (viter.hasNext())