Author: adrianc
Date: Fri Jun 7 15:18:27 2013
New Revision: 1490678
URL: http://svn.apache.org/r1490678
Log:
Second pass at removing cached DOM tree code from EntityConfigUtil.java. I
converted some of the code to use the new thread-safe models.
Removed:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityDataReaderInfo.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityEcaReaderInfo.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityGroupReaderInfo.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityModelReaderInfo.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/FieldTypeInfo.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/ResourceLoaderInfo.java
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityConfig.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java
ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java?rev=1490678&r1=1490677&r2=1490678&view=diff
==============================================================================
---
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java
(original)
+++
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java
Fri Jun 7 15:18:27 2013
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.ofbiz.base.config.GenericConfigException;
-import org.ofbiz.base.config.ResourceLoader;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilURL;
@@ -37,7 +36,13 @@ import org.ofbiz.entity.GenericEntityCon
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.config.model.Datasource;
import org.ofbiz.entity.config.model.EntityConfig;
+import org.ofbiz.entity.config.model.EntityDataReader;
+import org.ofbiz.entity.config.model.EntityEcaReader;
+import org.ofbiz.entity.config.model.EntityGroupReader;
+import org.ofbiz.entity.config.model.EntityModelReader;
+import org.ofbiz.entity.config.model.FieldType;
import org.ofbiz.entity.config.model.InlineJdbc;
+import org.ofbiz.entity.config.model.ResourceLoader;
import org.ofbiz.entity.jdbc.ConnectionFactory;
import org.ofbiz.entity.transaction.TransactionFactory;
import org.w3c.dom.Document;
@@ -112,17 +117,11 @@ public class EntityConfigUtil {
private static volatile AtomicReference<EntityConfigUtil> configRef = new
AtomicReference<EntityConfigUtil>();
// ========== engine info fields ==========
- private final Map<String, ResourceLoaderInfo> resourceLoaderInfos = new
HashMap<String, ResourceLoaderInfo>();
private final Map<String, DelegatorInfo> delegatorInfos = new
HashMap<String, DelegatorInfo>();
- private final Map<String, EntityModelReaderInfo> entityModelReaderInfos =
new HashMap<String, EntityModelReaderInfo>();
- private final Map<String, EntityGroupReaderInfo> entityGroupReaderInfos =
new HashMap<String, EntityGroupReaderInfo>();
- private final Map<String, EntityEcaReaderInfo> entityEcaReaderInfos = new
HashMap<String, EntityEcaReaderInfo>();
- private final Map<String, EntityDataReaderInfo> entityDataReaderInfos =
new HashMap<String, EntityDataReaderInfo>();
- private final Map<String, FieldTypeInfo> fieldTypeInfos = new
HashMap<String, FieldTypeInfo>();
private static Element getXmlRootElement() throws
GenericEntityConfException {
try {
- return
ResourceLoader.getXmlRootElement(ENTITY_ENGINE_XML_FILENAME);
+ return
org.ofbiz.base.config.ResourceLoader.getXmlRootElement(ENTITY_ENGINE_XML_FILENAME);
} catch (GenericConfigException e) {
throw new GenericEntityConfException("Could not get entity engine
XML root element", e);
}
@@ -138,7 +137,7 @@ public class EntityConfigUtil {
public static void reinitialize() throws GenericEntityException {
try {
- ResourceLoader.invalidateDocument(ENTITY_ENGINE_XML_FILENAME);
+
org.ofbiz.base.config.ResourceLoader.invalidateDocument(ENTITY_ENGINE_XML_FILENAME);
initialize(getXmlRootElement());
} catch (Exception e) {
throw new GenericEntityException("Error reloading entity config
XML file " + ENTITY_ENGINE_XML_FILENAME, e);
@@ -150,49 +149,11 @@ public class EntityConfigUtil {
}
private EntityConfigUtil(Element rootElement) throws
GenericEntityException {
- // not load all of the maps...
-
- // resource-loader - resourceLoaderInfos
- for (Element curElement: UtilXml.childElementList(rootElement,
"resource-loader")) {
- ResourceLoaderInfo resourceLoaderInfo = new
ResourceLoaderInfo(curElement);
- resourceLoaderInfos.put(resourceLoaderInfo.name,
resourceLoaderInfo);
- }
-
// delegator - delegatorInfos
for (Element curElement: UtilXml.childElementList(rootElement,
"delegator")) {
DelegatorInfo delegatorInfo = new DelegatorInfo(curElement);
delegatorInfos.put(delegatorInfo.name, delegatorInfo);
}
-
- // entity-model-reader - entityModelReaderInfos
- for (Element curElement: UtilXml.childElementList(rootElement,
"entity-model-reader")) {
- EntityModelReaderInfo entityModelReaderInfo = new
EntityModelReaderInfo(curElement);
- entityModelReaderInfos.put(entityModelReaderInfo.name,
entityModelReaderInfo);
- }
-
- // entity-group-reader - entityGroupReaderInfos
- for (Element curElement: UtilXml.childElementList(rootElement,
"entity-group-reader")) {
- EntityGroupReaderInfo entityGroupReaderInfo = new
EntityGroupReaderInfo(curElement);
- entityGroupReaderInfos.put(entityGroupReaderInfo.name,
entityGroupReaderInfo);
- }
-
- // entity-eca-reader - entityEcaReaderInfos
- for (Element curElement: UtilXml.childElementList(rootElement,
"entity-eca-reader")) {
- EntityEcaReaderInfo entityEcaReaderInfo = new
EntityEcaReaderInfo(curElement);
- entityEcaReaderInfos.put(entityEcaReaderInfo.name,
entityEcaReaderInfo);
- }
-
- // entity-data-reader - entityDataReaderInfos
- for (Element curElement: UtilXml.childElementList(rootElement,
"entity-data-reader")) {
- EntityDataReaderInfo entityDataReaderInfo = new
EntityDataReaderInfo(curElement);
- entityDataReaderInfos.put(entityDataReaderInfo.name,
entityDataReaderInfo);
- }
-
- // field-type - fieldTypeInfos
- for (Element curElement: UtilXml.childElementList(rootElement,
"field-type")) {
- FieldTypeInfo fieldTypeInfo = new FieldTypeInfo(curElement);
- fieldTypeInfos.put(fieldTypeInfo.name, fieldTypeInfo);
- }
}
public static String getTxFactoryClass() throws GenericEntityConfException
{
@@ -227,32 +188,32 @@ public class EntityConfigUtil {
return getEntityConfig().getConnectionFactory().getClassName();
}
- public static ResourceLoaderInfo getResourceLoaderInfo(String name) {
- return configRef.get().resourceLoaderInfos.get(name);
+ public static ResourceLoader getResourceLoader(String name) throws
GenericEntityConfException {
+ return getEntityConfig().getResourceLoader(name);
}
public static DelegatorInfo getDelegatorInfo(String name) {
return configRef.get().delegatorInfos.get(name);
}
- public static EntityModelReaderInfo getEntityModelReaderInfo(String name) {
- return configRef.get().entityModelReaderInfos.get(name);
+ public static EntityModelReader getEntityModelReader(String name) throws
GenericEntityConfException {
+ return getEntityConfig().getEntityModelReader(name);
}
- public static EntityGroupReaderInfo getEntityGroupReaderInfo(String name) {
- return configRef.get().entityGroupReaderInfos.get(name);
+ public static EntityGroupReader getEntityGroupReader(String name) throws
GenericEntityConfException {
+ return getEntityConfig().getEntityGroupReader(name);
}
- public static EntityEcaReaderInfo getEntityEcaReaderInfo(String name) {
- return configRef.get().entityEcaReaderInfos.get(name);
+ public static EntityEcaReader getEntityEcaReader(String name) throws
GenericEntityConfException {
+ return getEntityConfig().getEntityEcaReader(name);
}
- public static EntityDataReaderInfo getEntityDataReaderInfo(String name) {
- return configRef.get().entityDataReaderInfos.get(name);
+ public static EntityDataReader getEntityDataReader(String name) throws
GenericEntityConfException {
+ return getEntityConfig().getEntityDataReader(name);
}
- public static FieldTypeInfo getFieldTypeInfo(String name) {
- return configRef.get().fieldTypeInfos.get(name);
+ public static FieldType getFieldType(String name) throws
GenericEntityConfException {
+ return getEntityConfig().getFieldType(name);
}
public static Datasource getDatasource(String name) {
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityConfig.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityConfig.java?rev=1490678&r1=1490677&r2=1490678&view=diff
==============================================================================
---
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityConfig.java
(original)
+++
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityConfig.java
Fri Jun 7 15:18:27 2013
@@ -38,15 +38,21 @@ import org.w3c.dom.Element;
public final class EntityConfig {
private final List<ResourceLoader> resourceLoaderList; // <resource-loader>
+ private final Map<String, ResourceLoader> resourceLoaderMap; //
<resource-loader>
private final TransactionFactory transactionFactory; //
<transaction-factory>
private final ConnectionFactory connectionFactory; // <connection-factory>
private final DebugXaResources debugXaResources; // <debug-xa-resources>
private final List<Delegator> delegatorList; // <delegator>
private final List<EntityModelReader> entityModelReaderList; //
<entity-model-reader>
+ private final Map<String, EntityModelReader> entityModelReaderMap; //
<entity-model-reader>
private final List<EntityGroupReader> entityGroupReaderList; //
<entity-group-reader>
+ private final Map<String, EntityGroupReader> entityGroupReaderMap; //
<entity-group-reader>
private final List<EntityEcaReader> entityEcaReaderList; //
<entity-eca-reader>
+ private final Map<String, EntityEcaReader> entityEcaReaderMap; //
<entity-eca-reader>
private final List<EntityDataReader> entityDataReaderList; //
<entity-data-reader>
+ private final Map<String, EntityDataReader> entityDataReaderMap; //
<entity-data-reader>
private final List<FieldType> fieldTypeList; // <field-type>
+ private final Map<String, FieldType> fieldTypeMap; // <field-type>
private final List<Datasource> datasourceList; // <datasource>
private final Map<String, Datasource> datasourceMap;
@@ -56,10 +62,14 @@ public final class EntityConfig {
throw new GenericEntityConfException("<" + element.getNodeName() +
"> element child elements <resource-loader> are missing");
} else {
List<ResourceLoader> resourceLoaderList = new
ArrayList<ResourceLoader>(resourceLoaderElementList.size());
+ Map<String, ResourceLoader> resourceLoaderMap = new
HashMap<String, ResourceLoader>();
for (Element resourceLoaderElement : resourceLoaderElementList) {
- resourceLoaderList.add(new
ResourceLoader(resourceLoaderElement));
+ ResourceLoader resourceLoader = new
ResourceLoader(resourceLoaderElement);
+ resourceLoaderList.add(resourceLoader);
+ resourceLoaderMap.put(resourceLoader.getName(),
resourceLoader);
}
this.resourceLoaderList =
Collections.unmodifiableList(resourceLoaderList);
+ this.resourceLoaderMap =
Collections.unmodifiableMap(resourceLoaderMap);
}
Element transactionFactoryElement = UtilXml.firstChildElement(element,
"transaction-factory");
if (transactionFactoryElement == null) {
@@ -94,50 +104,72 @@ public final class EntityConfig {
throw new GenericEntityConfException("<" + element.getNodeName() +
"> element child elements <entity-model-reader> are missing");
} else {
List<EntityModelReader> entityModelReaderList = new
ArrayList<EntityModelReader>(entityModelReaderElementList.size());
+ Map<String, EntityModelReader> entityModelReaderMap = new
HashMap<String, EntityModelReader>();
for (Element entityModelReaderElement :
entityModelReaderElementList) {
- entityModelReaderList.add(new
EntityModelReader(entityModelReaderElement));
+ EntityModelReader entityModelReader = new
EntityModelReader(entityModelReaderElement);
+ entityModelReaderList.add(entityModelReader);
+ entityModelReaderMap.put(entityModelReader.getName(),
entityModelReader);
}
this.entityModelReaderList =
Collections.unmodifiableList(entityModelReaderList);
+ this.entityModelReaderMap =
Collections.unmodifiableMap(entityModelReaderMap);
}
List<? extends Element> entityGroupReaderElementList =
UtilXml.childElementList(element, "entity-group-reader");
if (entityGroupReaderElementList.isEmpty()) {
throw new GenericEntityConfException("<" + element.getNodeName() +
"> element child elements <entity-group-reader> are missing");
} else {
List<EntityGroupReader> entityGroupReaderList = new
ArrayList<EntityGroupReader>(entityGroupReaderElementList.size());
+ Map<String, EntityGroupReader> entityGroupReaderMap = new
HashMap<String, EntityGroupReader>();
for (Element entityGroupReaderElement :
entityGroupReaderElementList) {
- entityGroupReaderList.add(new
EntityGroupReader(entityGroupReaderElement));
+ EntityGroupReader entityGroupReader = new
EntityGroupReader(entityGroupReaderElement);
+ entityGroupReaderList.add(entityGroupReader);
+ entityGroupReaderMap.put(entityGroupReader.getName(),
entityGroupReader);
}
this.entityGroupReaderList =
Collections.unmodifiableList(entityGroupReaderList);
+ this.entityGroupReaderMap =
Collections.unmodifiableMap(entityGroupReaderMap);
}
List<? extends Element> entityEcaReaderElementList =
UtilXml.childElementList(element, "entity-eca-reader");
if (entityEcaReaderElementList.isEmpty()) {
this.entityEcaReaderList = Collections.emptyList();
+ this.entityEcaReaderMap = Collections.emptyMap();
} else {
List<EntityEcaReader> entityEcaReaderList = new
ArrayList<EntityEcaReader>(entityEcaReaderElementList.size());
+ Map<String, EntityEcaReader> entityEcaReaderMap = new
HashMap<String, EntityEcaReader>();
for (Element entityEcaReaderElement : entityEcaReaderElementList) {
+ EntityEcaReader entityEcaReader = new
EntityEcaReader(entityEcaReaderElement);
entityEcaReaderList.add(new
EntityEcaReader(entityEcaReaderElement));
+ entityEcaReaderMap.put(entityEcaReader.getName(),
entityEcaReader);
}
this.entityEcaReaderList =
Collections.unmodifiableList(entityEcaReaderList);
+ this.entityEcaReaderMap =
Collections.unmodifiableMap(entityEcaReaderMap);
}
List<? extends Element> entityDataReaderElementList =
UtilXml.childElementList(element, "entity-data-reader");
if (entityDataReaderElementList.isEmpty()) {
this.entityDataReaderList = Collections.emptyList();
+ this.entityDataReaderMap = Collections.emptyMap();
} else {
List<EntityDataReader> entityDataReaderList = new
ArrayList<EntityDataReader>(entityDataReaderElementList.size());
+ Map<String, EntityDataReader> entityDataReaderMap = new
HashMap<String, EntityDataReader>();
for (Element entityDataReaderElement :
entityDataReaderElementList) {
- entityDataReaderList.add(new
EntityDataReader(entityDataReaderElement));
+ EntityDataReader entityDataReader = new
EntityDataReader(entityDataReaderElement);
+ entityDataReaderList.add(entityDataReader);
+ entityDataReaderMap.put(entityDataReader.getName(),
entityDataReader);
}
this.entityDataReaderList =
Collections.unmodifiableList(entityDataReaderList);
+ this.entityDataReaderMap =
Collections.unmodifiableMap(entityDataReaderMap);
}
List<? extends Element> fieldTypeElementList =
UtilXml.childElementList(element, "field-type");
if (fieldTypeElementList.isEmpty()) {
throw new GenericEntityConfException("<" + element.getNodeName() +
"> element child elements <field-type> are missing");
} else {
List<FieldType> fieldTypeList = new
ArrayList<FieldType>(fieldTypeElementList.size());
+ Map<String, FieldType> fieldTypeMap = new HashMap<String,
FieldType>();
for (Element fieldTypeElement : fieldTypeElementList) {
- fieldTypeList.add(new FieldType(fieldTypeElement));
+ FieldType fieldType = new FieldType(fieldTypeElement);
+ fieldTypeList.add(fieldType);
+ fieldTypeMap.put(fieldType.getName(), fieldType);
}
this.fieldTypeList = Collections.unmodifiableList(fieldTypeList);
+ this.fieldTypeMap = Collections.unmodifiableMap(fieldTypeMap);
}
List<? extends Element> datasourceElementList =
UtilXml.childElementList(element, "datasource");
if (datasourceElementList.isEmpty()) {
@@ -155,6 +187,11 @@ public final class EntityConfig {
}
}
+ /** Returns the specified <code><resource-loader></code> child
element, or <code>null</code> if no child element was found. */
+ public ResourceLoader getResourceLoader(String name) {
+ return this.resourceLoaderMap.get(name);
+ }
+
/** Returns the <code><resource-loader></code> child elements. */
public List<ResourceLoader> getResourceLoaderList() {
return this.resourceLoaderList;
@@ -180,26 +217,51 @@ public final class EntityConfig {
return this.delegatorList;
}
+ /** Returns the specified <code><entity-model-reader></code> child
element, or <code>null</code> if no child element was found. */
+ public EntityModelReader getEntityModelReader(String name) {
+ return this.entityModelReaderMap.get(name);
+ }
+
/** Returns the <code><entity-model-reader></code> child elements. */
public List<EntityModelReader> getEntityModelReaderList() {
return this.entityModelReaderList;
}
+ /** Returns the specified <code><entity-group-reader></code> child
element, or <code>null</code> if no child element was found. */
+ public EntityGroupReader getEntityGroupReader(String name) {
+ return this.entityGroupReaderMap.get(name);
+ }
+
/** Returns the <code><entity-group-reader></code> child elements. */
public List<EntityGroupReader> getEntityGroupReaderList() {
return this.entityGroupReaderList;
}
+ /** Returns the specified <code><entity-eca-reader></code> child
element, or <code>null</code> if no child element was found. */
+ public EntityEcaReader getEntityEcaReader(String name) {
+ return this.entityEcaReaderMap.get(name);
+ }
+
/** Returns the <code><entity-eca-reader></code> child elements. */
public List<EntityEcaReader> getEntityEcaReaderList() {
return this.entityEcaReaderList;
}
+ /** Returns the specified <code><entity-data-reader></code> child
element, or <code>null</code> if no child element was found. */
+ public EntityDataReader getEntityDataReader(String name) {
+ return this.entityDataReaderMap.get(name);
+ }
+
/** Returns the <code><entity-data-reader></code> child elements. */
public List<EntityDataReader> getEntityDataReaderList() {
return this.entityDataReaderList;
}
+ /** Returns the specified <code><field-type></code> child element,
or <code>null</code> if no child element was found. */
+ public FieldType getFieldType(String name) {
+ return this.fieldTypeMap.get(name);
+ }
+
/** Returns the <code><field-type></code> child elements. */
public List<FieldType> getFieldTypeList() {
return this.fieldTypeList;
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java?rev=1490678&r1=1490677&r2=1490678&view=diff
==============================================================================
---
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java
(original)
+++
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelFieldTypeReader.java
Fri Jun 7 15:18:27 2013
@@ -32,9 +32,10 @@ import org.ofbiz.base.util.UtilTimer;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.cache.UtilCache;
-import org.ofbiz.entity.config.model.Datasource;
+import org.ofbiz.entity.GenericEntityConfException;
import org.ofbiz.entity.config.EntityConfigUtil;
-import org.ofbiz.entity.config.FieldTypeInfo;
+import org.ofbiz.entity.config.model.Datasource;
+import org.ofbiz.entity.config.model.FieldType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -72,11 +73,16 @@ public class ModelFieldTypeReader implem
String tempModelName = datasourceInfo.getFieldTypeName();
ModelFieldTypeReader reader = readers.get(tempModelName);
while (reader == null) {
- FieldTypeInfo fieldTypeInfo =
EntityConfigUtil.getFieldTypeInfo(tempModelName);
+ FieldType fieldTypeInfo = null;
+ try {
+ fieldTypeInfo = EntityConfigUtil.getFieldType(tempModelName);
+ } catch (GenericEntityConfException e) {
+ Debug.logWarning(e, "Exception thrown while getting field type
config: ", module);
+ }
if (fieldTypeInfo == null) {
throw new IllegalArgumentException("Could not find a
field-type definition with name \"" + tempModelName + "\"");
}
- ResourceHandler fieldTypeResourceHandler = new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
fieldTypeInfo.resourceElement);
+ ResourceHandler fieldTypeResourceHandler = new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
fieldTypeInfo.getLoader(), fieldTypeInfo.getLocation());
UtilTimer utilTimer = new UtilTimer();
utilTimer.timerString("[ModelFieldTypeReader.getModelFieldTypeReader] Reading
field types from " + fieldTypeResourceHandler.getLocation());
Document document = null;
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java?rev=1490678&r1=1490677&r2=1490678&view=diff
==============================================================================
---
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java
(original)
+++
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java
Fri Jun 7 15:18:27 2013
@@ -39,7 +39,8 @@ import org.ofbiz.base.util.cache.UtilCac
import org.ofbiz.entity.GenericEntityConfException;
import org.ofbiz.entity.config.DelegatorInfo;
import org.ofbiz.entity.config.EntityConfigUtil;
-import org.ofbiz.entity.config.EntityGroupReaderInfo;
+import org.ofbiz.entity.config.model.EntityGroupReader;
+import org.ofbiz.entity.config.model.Resource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -78,13 +79,13 @@ public class ModelGroupReader implements
public ModelGroupReader(String modelName) throws
GenericEntityConfException {
this.modelName = modelName;
- EntityGroupReaderInfo entityGroupReaderInfo =
EntityConfigUtil.getEntityGroupReaderInfo(modelName);
+ EntityGroupReader entityGroupReaderInfo =
EntityConfigUtil.getEntityGroupReader(modelName);
if (entityGroupReaderInfo == null) {
throw new GenericEntityConfException("Cound not find an
entity-group-reader with the name " + modelName);
}
- for (Element resourceElement: entityGroupReaderInfo.resourceElements) {
- this.entityGroupResourceHandlers.add(new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
resourceElement));
+ for (Resource resourceElement:
entityGroupReaderInfo.getResourceList()) {
+ this.entityGroupResourceHandlers.add(new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
resourceElement.getLoader(), resourceElement.getLocation()));
}
// get all of the component resource group stuff, ie specified in each
ofbiz-component.xml file
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java?rev=1490678&r1=1490677&r2=1490678&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
(original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java
Fri Jun 7 15:18:27 2013
@@ -19,13 +19,13 @@
package org.ofbiz.entity.model;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@@ -44,7 +44,8 @@ import org.ofbiz.entity.GenericEntityExc
import org.ofbiz.entity.GenericModelException;
import org.ofbiz.entity.config.DelegatorInfo;
import org.ofbiz.entity.config.EntityConfigUtil;
-import org.ofbiz.entity.config.EntityModelReaderInfo;
+import org.ofbiz.entity.config.model.EntityModelReader;
+import org.ofbiz.entity.config.model.Resource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -103,15 +104,15 @@ public class ModelReader implements Seri
resourceHandlerEntities = new HashMap<ResourceHandler,
Collection<String>>();
entityResourceHandlerMap = new HashMap<String, ResourceHandler>();
- EntityModelReaderInfo entityModelReaderInfo =
EntityConfigUtil.getEntityModelReaderInfo(modelName);
+ EntityModelReader entityModelReaderInfo =
EntityConfigUtil.getEntityModelReader(modelName);
if (entityModelReaderInfo == null) {
throw new GenericEntityConfException("Cound not find an
entity-model-reader with the name " + modelName);
}
// get all of the main resource model stuff, ie specified in the
entityengine.xml file
- for (Element resourceElement: entityModelReaderInfo.resourceElements) {
- ResourceHandler handler = new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
resourceElement);
+ for (Resource resourceElement :
entityModelReaderInfo.getResourceList()) {
+ ResourceHandler handler = new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
resourceElement.getLoader(), resourceElement.getLocation());
entityResourceHandlers.add(handler);
}
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java?rev=1490678&r1=1490677&r2=1490678&view=diff
==============================================================================
---
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java
(original)
+++
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java
Fri Jun 7 15:18:27 2013
@@ -33,11 +33,15 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityConfException;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.config.EntityConfigUtil;
-import org.ofbiz.entity.config.EntityDataReaderInfo;
-import org.ofbiz.entity.config.model.*;
+import org.ofbiz.entity.config.model.Datasource;
+import org.ofbiz.entity.config.model.EntityDataReader;
+import org.ofbiz.entity.config.model.ReadData;
+import org.ofbiz.entity.config.model.Resource;
+import org.ofbiz.entity.config.model.SqlLoadPath;
import org.ofbiz.entity.model.ModelEntity;
import org.ofbiz.entity.model.ModelReader;
import org.ofbiz.entity.model.ModelUtil;
@@ -107,16 +111,15 @@ public class EntityDataLoader {
}
// get all of the main resource model stuff, ie specified in
the entityengine.xml file
- EntityDataReaderInfo entityDataReaderInfo =
EntityConfigUtil.getEntityDataReaderInfo(readerName);
-
- if (entityDataReaderInfo == null) {
- Debug.logInfo("Could not find entity-data-reader named: "
+ readerName + ". Creating a new reader with this name. ", module);
- entityDataReaderInfo = new
EntityDataReaderInfo(readerName);
+ EntityDataReader entityDataReaderInfo = null;
+ try {
+ entityDataReaderInfo =
EntityConfigUtil.getEntityDataReader(readerName);
+ } catch (GenericEntityConfException e) {
+ Debug.logWarning(e, "Exception thrown while getting entity
data reader config: ", module);
}
-
if (entityDataReaderInfo != null) {
- for (Element resourceElement:
entityDataReaderInfo.resourceElements) {
- ResourceHandler handler = new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
resourceElement);
+ for (Resource resourceElement:
entityDataReaderInfo.getResourceList()) {
+ ResourceHandler handler = new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
resourceElement.getLoader(), resourceElement.getLocation());
try {
urlList.add(handler.getURL());
} catch (GenericConfigException e) {
Modified:
ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java?rev=1490678&r1=1490677&r2=1490678&view=diff
==============================================================================
---
ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
(original)
+++
ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java
Fri Jun 7 15:18:27 2013
@@ -37,9 +37,10 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.cache.UtilCache;
import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityConfException;
import org.ofbiz.entity.config.DelegatorInfo;
import org.ofbiz.entity.config.EntityConfigUtil;
-import org.ofbiz.entity.config.EntityEcaReaderInfo;
+import org.ofbiz.entity.config.model.*;
import org.w3c.dom.Element;
/**
@@ -71,15 +72,20 @@ public class EntityEcaUtil {
}
protected static void readConfig(String entityEcaReaderName, Map<String,
Map<String, List<EntityEcaRule>>> ecaCache) {
- EntityEcaReaderInfo entityEcaReaderInfo =
EntityConfigUtil.getEntityEcaReaderInfo(entityEcaReaderName);
+ EntityEcaReader entityEcaReaderInfo = null;
+ try {
+ entityEcaReaderInfo =
EntityConfigUtil.getEntityEcaReader(entityEcaReaderName);
+ } catch (GenericEntityConfException e) {
+ Debug.logError(e, "Exception thrown while getting
entity-eca-reader config with name: " + entityEcaReaderName, module);
+ }
if (entityEcaReaderInfo == null) {
Debug.logError("BAD ERROR: Could not find entity-eca-reader config
with name: " + entityEcaReaderName, module);
return;
}
List<Future<List<EntityEcaRule>>> futures = FastList.newInstance();
- for (Element eecaResourceElement:
entityEcaReaderInfo.resourceElements) {
- ResourceHandler handler = new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
eecaResourceElement);
+ for (Resource eecaResourceElement :
entityEcaReaderInfo.getResourceList()) {
+ ResourceHandler handler = new
MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME,
eecaResourceElement.getLoader(), eecaResourceElement.getLocation());
futures.add(ExecutionPool.GLOBAL_EXECUTOR.submit(createEcaLoaderCallable(handler)));
}