Author: jacopoc
Date: Tue Aug 26 09:16:52 2014 New Revision: 1620538 URL: http://svn.apache.org/r1620538 Log: Merged framework-api-cleanup branch into trunk. Added: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/ConnectionFactory.java - copied unchanged from r1620529, ofbiz/branches/framework-api-cleanup/framework/entity/src/org/ofbiz/entity/connection/ConnectionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactoryLoader.java - copied unchanged from r1620529, ofbiz/branches/framework-api-cleanup/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactoryLoader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/DumbTransactionFactory.java - copied unchanged from r1620529, ofbiz/branches/framework-api-cleanup/framework/entity/src/org/ofbiz/entity/transaction/DumbTransactionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/JNDITransactionFactory.java - copied unchanged from r1620529, ofbiz/branches/framework-api-cleanup/framework/entity/src/org/ofbiz/entity/transaction/JNDITransactionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactory.java - copied unchanged from r1620529, ofbiz/branches/framework-api-cleanup/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactoryLoader.java - copied unchanged from r1620529, ofbiz/branches/framework-api-cleanup/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactoryLoader.java Removed: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/EntityConfigUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/ConnectionFactoryInterface.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/ConnectionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/DumbFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/JNDIFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionFactoryInterface.java Modified: ofbiz/trunk/ (props changed) ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java ofbiz/trunk/framework/entity/config/entityengine.xml ofbiz/trunk/framework/entity/dtd/entity-config.xsd ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ConnectionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Datasource.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DebugXaResources.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DelegatorElement.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityConfig.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityDataReader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityEcaReader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityGroupReader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityModelReader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/FieldType.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/GroupMap.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/InlineJdbc.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/JndiJdbc.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ReadData.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Resource.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ResourceLoader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/SqlLoadPath.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionManagerJndi.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TyrexDataSource.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/UserTransactionJndi.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.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/test/EntityTestSuite.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityDataLoader.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/SequenceUtil.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java ofbiz/trunk/framework/geronimo/src/org/ofbiz/geronimo/GeronimoTransactionFactory.java ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceSynchronization.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/DataVisionViewHandler.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsJXlsViewHandler.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPdfViewHandler.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsPoiXlsViewHandler.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/JasperReportsXmlViewHandler.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java ofbiz/trunk/framework/webtools/webapp/webtools/entity/ModelWriter.jsp Propchange: ofbiz/trunk/ ------------------------------------------------------------------------------ Merged /ofbiz/branches/framework-api-cleanup:r1619853-1620529 Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java Tue Aug 26 09:16:52 2014 @@ -47,7 +47,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityConditionSubSelect; import org.ofbiz.entity.condition.EntityConditionValue; import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.config.EntityConfigUtil; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.model.DynamicViewEntity; import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.model.ModelViewEntity.ComplexAlias; @@ -647,7 +647,7 @@ public class ProductSearch { this.entityConditionList.add(topCond); - Debug.logInfo("topCond=" + topCond.makeWhereString(null, FastList.<EntityConditionParam>newInstance(), EntityConfigUtil.getDatasource(delegator.getEntityHelperName("Product"))), module); + Debug.logInfo("topCond=" + topCond.makeWhereString(null, FastList.<EntityConditionParam>newInstance(), EntityConfig.getDatasource(delegator.getEntityHelperName("Product"))), module); } public EntityListIterator doQuery(Delegator delegator) { Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonServices.java Tue Aug 26 09:16:52 2014 @@ -344,18 +344,14 @@ public class CommonServices { } public static Map<String, Object> displayXaDebugInfo(DispatchContext dctx, Map<String, ?> context) { - try { - if (TransactionUtil.debugResources()) { - if (UtilValidate.isNotEmpty(TransactionUtil.debugResMap)) { - TransactionUtil.logRunningTx(); - } else { - Debug.logInfo("No running transaction to display.", module); - } + if (TransactionUtil.debugResources()) { + if (UtilValidate.isNotEmpty(TransactionUtil.debugResMap)) { + TransactionUtil.logRunningTx(); } else { - Debug.logInfo("Debug resources is disabled.", module); + Debug.logInfo("No running transaction to display.", module); } - } catch (GenericEntityConfException e) { - return ServiceUtil.returnError(e.getMessage()); + } else { + Debug.logInfo("Debug resources is disabled.", module); } return ServiceUtil.returnSuccess(); Modified: ofbiz/trunk/framework/entity/config/entityengine.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/config/entityengine.xml?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/config/entityengine.xml (original) +++ ofbiz/trunk/framework/entity/config/entityengine.xml Tue Aug 26 09:16:52 2014 @@ -32,7 +32,7 @@ access. For a detailed description see t <!-- Use this one for getting the JTA objects from JNDI --> <!-- NOTE: to use the JndiFactory you must specify the necessary JNDI properties - <transaction-factory class="org.ofbiz.entity.transaction.JNDIFactory"> + <transaction-factory class="org.ofbiz.entity.transaction.JNDITransactionFactory"> <user-transaction-jndi jndi-server-name="default" jndi-name="java:comp/UserTransaction"/> <transaction-manager-jndi jndi-server-name="default" jndi-name="java:comp/UserTransaction"/> </transaction-factory> Modified: ofbiz/trunk/framework/entity/dtd/entity-config.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/dtd/entity-config.xsd?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/dtd/entity-config.xsd (original) +++ ofbiz/trunk/framework/entity/dtd/entity-config.xsd Tue Aug 26 09:16:52 2014 @@ -24,7 +24,7 @@ under the License. <xs:sequence> <xs:element maxOccurs="unbounded" ref="resource-loader"/> <xs:element ref="transaction-factory"/> - <xs:element ref="connection-factory"/> + <xs:element minOccurs="0" ref="connection-factory"/> <xs:element ref="debug-xa-resources"/> <xs:element maxOccurs="unbounded" ref="delegator"/> <xs:element maxOccurs="unbounded" ref="entity-model-reader"/> Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Tue Aug 26 09:16:52 2014 @@ -52,9 +52,9 @@ import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.cache.Cache; import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.config.model.Datasource; import org.ofbiz.entity.config.model.DelegatorElement; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.datasource.GenericHelper; import org.ofbiz.entity.datasource.GenericHelperFactory; import org.ofbiz.entity.datasource.GenericHelperInfo; @@ -210,7 +210,7 @@ public class GenericDelegator implements protected GenericDelegator(String delegatorFullName) throws GenericEntityException { //if (Debug.infoOn()) Debug.logInfo("Creating new Delegator with name \"" + delegatorFullName + "\".", module); this.setDelegatorNames(delegatorFullName); - this.delegatorInfo = EntityConfigUtil.getDelegator(delegatorBaseName); + this.delegatorInfo = EntityConfig.getInstance().getDelegator(delegatorBaseName); String kekText; // before continuing, if there is a tenantId use the base delegator to see if it is valid @@ -282,7 +282,7 @@ public class GenericDelegator implements GenericHelper helper = GenericHelperFactory.getHelper(helperInfo); try { - Datasource datasource = EntityConfigUtil.getDatasource(helperBaseName); + Datasource datasource = EntityConfig.getDatasource(helperBaseName); if (datasource.getCheckOnStart()) { if (Debug.infoOn()) { Debug.logInfo("Doing database check as requested in entityengine.xml with addMissing=" + datasource.getAddMissingOnStart(), module); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ConnectionFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ConnectionFactory.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ConnectionFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ConnectionFactory.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -34,7 +33,7 @@ public final class ConnectionFactory { private final String className; // type = xs:string ConnectionFactory(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String className = element.getAttribute("class").intern(); if (className.isEmpty()) { throw new GenericEntityConfException("<connection-factory> element class attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Datasource.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Datasource.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Datasource.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Datasource.java Tue Aug 26 09:16:52 2014 @@ -25,7 +25,6 @@ import java.util.List; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -83,7 +82,7 @@ public final class Datasource { private final TyrexDataSource tyrexDataSource; // <tyrex-dataSource> Datasource(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String name = element.getAttribute("name").intern(); if (name.isEmpty()) { throw new GenericEntityConfException("<datasource> element name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DebugXaResources.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DebugXaResources.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DebugXaResources.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DebugXaResources.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -34,7 +33,7 @@ public final class DebugXaResources { private final boolean value; // type = xs:string DebugXaResources(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String value = element.getAttribute("value").intern(); if (value.isEmpty()) { throw new GenericEntityConfException("<debug-xa-resources> element value attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DelegatorElement.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DelegatorElement.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DelegatorElement.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/DelegatorElement.java Tue Aug 26 09:16:52 2014 @@ -27,7 +27,6 @@ import java.util.HashMap; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -54,7 +53,7 @@ public final class DelegatorElement { private final Map<String, String> groupMapMap; // <group-map> DelegatorElement(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String name = element.getAttribute("name").intern(); if (name.isEmpty()) { throw new GenericEntityConfException("<delegator> element name attribute is empty" + lineNumberText); 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=1620538&r1=1620537&r2=1620538&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 Tue Aug 26 09:16:52 2014 @@ -18,6 +18,7 @@ *******************************************************************************/ package org.ofbiz.entity.config.model; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -25,18 +26,25 @@ import java.util.Map; import java.util.HashMap; import org.ofbiz.base.lang.ThreadSafe; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilURL; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityConfException; import org.w3c.dom.Element; /** - * An object that models the <code><entity-config></code> element. + * A singleton class that models the <code><entity-config></code> element. * * @see <code>entity-config.xsd</code> */ @ThreadSafe public final class EntityConfig { + public static final String ENTITY_ENGINE_XML_FILENAME = "entityengine.xml"; + private static final String module = EntityConfig.class.getName(); + + private static final EntityConfig instance = createNewInstance(); private final List<ResourceLoader> resourceLoaderList; // <resource-loader> private final Map<String, ResourceLoader> resourceLoaderMap; // <resource-loader> private final TransactionFactory transactionFactory; // <transaction-factory> @@ -57,7 +65,18 @@ public final class EntityConfig { private final List<Datasource> datasourceList; // <datasource> private final Map<String, Datasource> datasourceMap; - public EntityConfig(Element element) throws GenericEntityConfException { + private EntityConfig() throws GenericEntityConfException { + Element element; + URL confUrl = UtilURL.fromResource(ENTITY_ENGINE_XML_FILENAME); + if (confUrl == null) { + throw new GenericEntityConfException("Could not find the " + ENTITY_ENGINE_XML_FILENAME + " file"); + } + try { + element = UtilXml.readXmlDocument(confUrl, true, true).getDocumentElement(); + } catch (Exception e) { + throw new GenericEntityConfException("Exception thrown while reading " + ENTITY_ENGINE_XML_FILENAME + ": ", e); + } + List<? extends Element> resourceLoaderElementList = UtilXml.childElementList(element, "resource-loader"); if (resourceLoaderElementList.isEmpty()) { throw new GenericEntityConfException("<entity-config> element child elements <resource-loader> are missing"); @@ -79,10 +98,10 @@ public final class EntityConfig { this.transactionFactory = new TransactionFactory(transactionFactoryElement); } Element connectionFactoryElement = UtilXml.firstChildElement(element, "connection-factory"); - if (connectionFactoryElement == null) { - throw new GenericEntityConfException("<entity-config> element child element <connection-factory> is missing"); - } else { + if (connectionFactoryElement != null) { this.connectionFactory = new ConnectionFactory(connectionFactoryElement); + } else { + this.connectionFactory = null; } Element debugXaResourcesElement = UtilXml.firstChildElement(element, "debug-xa-resources"); if (debugXaResourcesElement == null) { @@ -192,6 +211,30 @@ public final class EntityConfig { } } + private static EntityConfig createNewInstance() { + EntityConfig entityConfig = null; + try { + entityConfig = new EntityConfig(); + } catch (GenericEntityConfException gece) { + Debug.logError(gece, module); + } + return entityConfig; + } + + public static EntityConfig getInstance() throws GenericEntityConfException { + if (instance == null) { + throw new GenericEntityConfException("EntityConfig is not initialized."); + } + return instance; + } + + public static String createConfigFileLineNumberText(Element element) { + if (element.getUserData("startLine") != null) { + return " [" + ENTITY_ENGINE_XML_FILENAME + " line " + element.getUserData("startLine") + "]"; + } + return ""; + } + /** 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); @@ -283,9 +326,45 @@ public final class EntityConfig { } /** Returns the specified <code><datasource></code> child element or <code>null</code> if it does not exist. */ + /* public Datasource getDatasource(String name) { return this.datasourceMap.get(name); } + */ + public static Datasource getDatasource(String name) { + try { + return getInstance().datasourceMap.get(name); + } catch (GenericEntityConfException e) { + // FIXME: Doing this so we don't have to rewrite the entire API. + throw new RuntimeException(e); + } + } + + /** + * Returns the configured JDBC password. + * + * @param inlineJdbcElement + * @return The configured JDBC password. + * @throws GenericEntityConfException If the password was not found. + * + * @see <code>entity-config.xsd</code> + */ + public static String getJdbcPassword(InlineJdbc inlineJdbcElement) throws GenericEntityConfException { + String jdbcPassword = inlineJdbcElement.getJdbcPassword(); + if (!jdbcPassword.isEmpty()) { + return jdbcPassword; + } + String jdbcPasswordLookup = inlineJdbcElement.getJdbcPasswordLookup(); + if (jdbcPasswordLookup.isEmpty()) { + throw new GenericEntityConfException("No jdbc-password or jdbc-password-lookup specified for inline-jdbc element, line: " + inlineJdbcElement.getLineNumber()); + } + String key = "jdbc-password.".concat(jdbcPasswordLookup); + jdbcPassword = UtilProperties.getPropertyValue("passwords.properties", key); + if (jdbcPassword.isEmpty()) { + throw new GenericEntityConfException("'" + key + "' property not found in passwords.properties file for inline-jdbc element, line: " + inlineJdbcElement.getLineNumber()); + } + return jdbcPassword; + } /** Returns the <code><datasource></code> child elements as a <code>Map</code>. */ public Map<String, Datasource> getDatasourceMap() { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityDataReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityDataReader.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityDataReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityDataReader.java Tue Aug 26 09:16:52 2014 @@ -25,7 +25,6 @@ import java.util.List; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -48,7 +47,7 @@ public final class EntityDataReader { } EntityDataReader(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String name = element.getAttribute("name").intern(); if (name.isEmpty()) { throw new GenericEntityConfException("<entity-data-reader> element name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityEcaReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityEcaReader.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityEcaReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityEcaReader.java Tue Aug 26 09:16:52 2014 @@ -25,7 +25,6 @@ import java.util.List; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -40,7 +39,7 @@ public final class EntityEcaReader { private final List<Resource> resourceList; // <resource> EntityEcaReader(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String name = element.getAttribute("name").intern(); if (name.isEmpty()) { throw new GenericEntityConfException("<entity-eca-reader> element name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityGroupReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityGroupReader.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityGroupReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityGroupReader.java Tue Aug 26 09:16:52 2014 @@ -25,7 +25,6 @@ import java.util.List; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -42,7 +41,7 @@ public final class EntityGroupReader { private final List<Resource> resourceList; // <resource> EntityGroupReader(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String name = element.getAttribute("name").intern(); if (name.isEmpty()) { throw new GenericEntityConfException("<entity-group-reader> element name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityModelReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityModelReader.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityModelReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/EntityModelReader.java Tue Aug 26 09:16:52 2014 @@ -25,7 +25,6 @@ import java.util.List; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -40,7 +39,7 @@ public final class EntityModelReader { private final List<Resource> resourceList; // <resource> EntityModelReader(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String name = element.getAttribute("name").intern(); if (name.isEmpty()) { throw new GenericEntityConfException("<entity-model-reader> element name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/FieldType.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/FieldType.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/FieldType.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/FieldType.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -36,7 +35,7 @@ public final class FieldType { private final String location; // type = xs:string FieldType(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String name = element.getAttribute("name").intern(); if (name.isEmpty()) { throw new GenericEntityConfException("<field-type> element name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/GroupMap.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/GroupMap.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/GroupMap.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/GroupMap.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ public final class GroupMap { private final String datasourceName; // type = xs:string GroupMap(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String groupName = element.getAttribute("group-name").intern(); if (groupName.isEmpty()) { throw new GenericEntityConfException("<group-map> element group-name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/InlineJdbc.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/InlineJdbc.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/InlineJdbc.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/InlineJdbc.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -54,7 +53,7 @@ public final class InlineJdbc extends Jd InlineJdbc(Element element) throws GenericEntityConfException { super(element); - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String jdbcDriver = element.getAttribute("jdbc-driver").intern(); if (jdbcDriver.isEmpty()) { throw new GenericEntityConfException("<inline-jdbc> element jdbc-driver attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/JndiJdbc.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/JndiJdbc.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/JndiJdbc.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/JndiJdbc.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -36,7 +35,7 @@ public final class JndiJdbc extends Jdbc JndiJdbc(Element element) throws GenericEntityConfException { super(element); - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String jndiServerName = element.getAttribute("jndi-server-name").intern(); if (jndiServerName.isEmpty()) { throw new GenericEntityConfException("<jndi-jdbc> element jndi-server-name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ReadData.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ReadData.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ReadData.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ReadData.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -34,7 +33,7 @@ public final class ReadData { private final String readerName; // type = xs:string ReadData(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String readerName = element.getAttribute("reader-name").intern(); if (readerName.isEmpty()) { throw new GenericEntityConfException("<read-data> element reader-name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Resource.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Resource.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Resource.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/Resource.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ public final class Resource { private final String location; // type = xs:string Resource(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String loader = element.getAttribute("loader").intern(); if (loader.isEmpty()) { throw new GenericEntityConfException("<resource> element loader attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ResourceLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ResourceLoader.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ResourceLoader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/ResourceLoader.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -37,7 +36,7 @@ public final class ResourceLoader { private final String prefix; // type = xs:string ResourceLoader(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String name = element.getAttribute("name").intern(); if (name.isEmpty()) { throw new GenericEntityConfException("<resource-loader> element name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/SqlLoadPath.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/SqlLoadPath.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/SqlLoadPath.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/SqlLoadPath.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ public final class SqlLoadPath { private final String prependEnv; // type = xs:string SqlLoadPath(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String path = element.getAttribute("path").intern(); if (path.isEmpty()) { throw new GenericEntityConfException("<sql-load-path> element path attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionFactory.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionFactory.java Tue Aug 26 09:16:52 2014 @@ -21,7 +21,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -37,7 +36,7 @@ public final class TransactionFactory { private final TransactionManagerJndi transactionManagerJndi; // <transaction-manager-jndi> TransactionFactory(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String className = element.getAttribute("class").intern(); if (className.isEmpty()) { throw new GenericEntityConfException("<transaction-factory> element class attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionManagerJndi.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionManagerJndi.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionManagerJndi.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TransactionManagerJndi.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ public final class TransactionManagerJnd private final String jndiName; // type = xs:string TransactionManagerJndi(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String jndiServerName = element.getAttribute("jndi-server-name").intern(); if (jndiServerName.isEmpty()) { throw new GenericEntityConfException("<transaction-manager-jndi> element jndi-server-name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TyrexDataSource.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TyrexDataSource.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TyrexDataSource.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/TyrexDataSource.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ public final class TyrexDataSource exten TyrexDataSource(Element element) throws GenericEntityConfException { super(element); - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String dataSourceName = element.getAttribute("dataSource-name").intern(); if (dataSourceName.isEmpty()) { throw new GenericEntityConfException("<tyrex-dataSource> element dataSource-name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/UserTransactionJndi.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/UserTransactionJndi.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/UserTransactionJndi.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/config/model/UserTransactionJndi.java Tue Aug 26 09:16:52 2014 @@ -20,7 +20,6 @@ package org.ofbiz.entity.config.model; import org.ofbiz.base.lang.ThreadSafe; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ public final class UserTransactionJndi { private final String jndiName; // type = xs:string UserTransactionJndi(Element element) throws GenericEntityConfException { - String lineNumberText = EntityConfigUtil.createConfigFileLineNumberText(element); + String lineNumberText = EntityConfig.createConfigFileLineNumberText(element); String jndiServerName = element.getAttribute("jndi-server-name").intern(); if (jndiServerName.isEmpty()) { throw new GenericEntityConfException("<user-transaction-jndi> element jndi-server-name attribute is empty" + lineNumberText); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Tue Aug 26 09:16:52 2014 @@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentHa import javax.transaction.TransactionManager; -import org.apache.commons.dbcp2.ConnectionFactory; import org.apache.commons.dbcp2.DriverConnectionFactory; import org.apache.commons.dbcp2.PoolableConnectionFactory; import org.apache.commons.dbcp2.managed.LocalXAConnectionFactory; @@ -40,18 +39,19 @@ import org.apache.commons.pool2.impl.Gen import org.ofbiz.base.util.Debug; import org.ofbiz.entity.GenericEntityConfException; import org.ofbiz.entity.GenericEntityException; -import org.ofbiz.entity.config.EntityConfigUtil; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.config.model.InlineJdbc; import org.ofbiz.entity.config.model.JdbcElement; import org.ofbiz.entity.datasource.GenericHelperInfo; -import org.ofbiz.entity.transaction.TransactionFactory; +import org.ofbiz.entity.transaction.TransactionFactoryLoader; +import org.ofbiz.entity.transaction.TransactionUtil; /** * Apache Commons DBCP connection factory. * * @see <a href="http://commons.apache.org/proper/commons-dbcp/">Apache Commons DBCP</a> */ -public class DBCPConnectionFactory implements ConnectionFactoryInterface { +public class DBCPConnectionFactory implements ConnectionFactory { public static final String module = DBCPConnectionFactory.class.getName(); protected static final ConcurrentHashMap<String, ManagedDataSource> dsCache = new ConcurrentHashMap<String, ManagedDataSource>(); @@ -60,19 +60,19 @@ public class DBCPConnectionFactory imple String cacheKey = helperInfo.getHelperFullName(); ManagedDataSource mds = dsCache.get(cacheKey); if (mds != null) { - return TransactionFactory.getCursorConnection(helperInfo, mds.getConnection()); + return TransactionUtil.getCursorConnection(helperInfo, mds.getConnection()); } if (!(abstractJdbc instanceof InlineJdbc)) { throw new GenericEntityConfException("DBCP requires an <inline-jdbc> child element in the <datasource> element"); } InlineJdbc jdbcElement = (InlineJdbc) abstractJdbc; // connection properties - TransactionManager txMgr = TransactionFactory.getTransactionManager(); + TransactionManager txMgr = TransactionFactoryLoader.getInstance().getTransactionManager(); String driverName = jdbcElement.getJdbcDriver(); String jdbcUri = helperInfo.getOverrideJdbcUri(jdbcElement.getJdbcUri()); String jdbcUsername = helperInfo.getOverrideUsername(jdbcElement.getJdbcUsername()); - String jdbcPassword = helperInfo.getOverridePassword(EntityConfigUtil.getJdbcPassword(jdbcElement)); + String jdbcPassword = helperInfo.getOverridePassword(EntityConfig.getJdbcPassword(jdbcElement)); // pool settings int maxSize = jdbcElement.getPoolMaxsize(); @@ -98,7 +98,7 @@ public class DBCPConnectionFactory imple cfProps.put("password", jdbcPassword); // create the connection factory - ConnectionFactory cf = new DriverConnectionFactory(jdbcDriver, jdbcUri, cfProps); + org.apache.commons.dbcp2.ConnectionFactory cf = new DriverConnectionFactory(jdbcDriver, jdbcUri, cfProps); // wrap it with a LocalXAConnectionFactory XAConnectionFactory xacf = new LocalXAConnectionFactory(txMgr, cf); @@ -152,7 +152,7 @@ public class DBCPConnectionFactory imple dsCache.putIfAbsent(cacheKey, mds); mds = dsCache.get(cacheKey); - return TransactionFactory.getCursorConnection(helperInfo, mds.getConnection()); + return TransactionUtil.getCursorConnection(helperInfo, mds.getConnection()); } public void closeAll() { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Tue Aug 26 09:16:52 2014 @@ -43,7 +43,6 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.EntityLockedException; import org.ofbiz.entity.GenericDataSourceException; import org.ofbiz.entity.GenericEntity; -import org.ofbiz.entity.GenericEntityConfException; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericEntityNotFoundException; import org.ofbiz.entity.GenericModelException; @@ -53,7 +52,6 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityConditionParam; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.config.model.*; -import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.jdbc.DatabaseUtil; import org.ofbiz.entity.jdbc.SQLProcessor; import org.ofbiz.entity.jdbc.SqlJdbcUtil; @@ -95,7 +93,7 @@ public class GenericDAO { public GenericDAO(GenericHelperInfo helperInfo) { this.helperInfo = helperInfo; this.modelFieldTypeReader = ModelFieldTypeReader.getModelFieldTypeReader(helperInfo.getHelperBaseName()); - this.datasource = EntityConfigUtil.getDatasource(helperInfo.getHelperBaseName()); + this.datasource = EntityConfig.getDatasource(helperInfo.getHelperBaseName()); this.executor = ExecutionPool.getScheduledExecutor(GENERIC_DAO_THREAD_GROUP, "OFBiz-entity-datasource(" + helperInfo.getHelperFullName() + ")", datasource.getMaxWorkerPoolSize(), false); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericHelperFactory.java Tue Aug 26 09:16:52 2014 @@ -24,7 +24,7 @@ import java.util.Map; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.config.model.Datasource; -import org.ofbiz.entity.config.EntityConfigUtil; +import org.ofbiz.entity.config.model.EntityConfig; /** * Generic Entity Helper Factory Class @@ -46,7 +46,7 @@ public class GenericHelperFactory { helper = helperCache.get(helperInfo.getHelperFullName()); if (helper == null) { try { - Datasource datasourceInfo = EntityConfigUtil.getDatasource(helperInfo.getHelperBaseName()); + Datasource datasourceInfo = EntityConfig.getDatasource(helperInfo.getHelperBaseName()); if (datasourceInfo == null) { throw new IllegalStateException("Could not find datasource definition with name " + helperInfo.getHelperBaseName()); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/MemoryHelper.java Tue Aug 26 09:16:52 2014 @@ -39,8 +39,8 @@ import org.ofbiz.entity.GenericNotImplem import org.ofbiz.entity.GenericPK; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.config.model.Datasource; -import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.jdbc.SqlJdbcUtil; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelField; @@ -281,7 +281,7 @@ public class MemoryHelper implements Gen public MemoryHelper(String helperName) { this.helperName = helperName; modelFieldTypeReader = ModelFieldTypeReader.getModelFieldTypeReader(helperName); - Datasource datasourceInfo = EntityConfigUtil.getDatasource(helperName); + Datasource datasourceInfo = EntityConfig.getDatasource(helperName); this.executor = ExecutionPool.getScheduledExecutor(MEMORY_HELPER_THREAD_GROUP, "OFBiz-entity-datasource(" + helperName + ")", datasourceInfo.getMaxWorkerPoolSize(), false); } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java Tue Aug 26 09:16:52 2014 @@ -22,6 +22,8 @@ import java.io.Serializable; import java.lang.reflect.Method; import java.sql.Connection; import java.sql.DatabaseMetaData; +import java.sql.Driver; +import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -33,6 +35,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.Callable; @@ -47,7 +50,7 @@ import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.config.model.Datasource; -import org.ofbiz.entity.config.EntityConfigUtil; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.datasource.GenericHelperInfo; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelField; @@ -57,6 +60,7 @@ import org.ofbiz.entity.model.ModelIndex import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.model.ModelRelation; import org.ofbiz.entity.model.ModelViewEntity; +import org.ofbiz.entity.transaction.TransactionFactoryLoader; import org.ofbiz.entity.transaction.TransactionUtil; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -91,7 +95,7 @@ public class DatabaseUtil { public DatabaseUtil(GenericHelperInfo helperInfo, ExecutorService executor) { this.helperInfo = helperInfo; this.modelFieldTypeReader = ModelFieldTypeReader.getModelFieldTypeReader(helperInfo.getHelperBaseName()); - this.datasourceInfo = EntityConfigUtil.getDatasource(helperInfo.getHelperBaseName()); + this.datasourceInfo = EntityConfig.getDatasource(helperInfo.getHelperBaseName()); this.executor = executor; } @@ -132,9 +136,9 @@ public class DatabaseUtil { protected Connection getConnection() throws SQLException, GenericEntityException { Connection connection = null; if (!isLegacy) { - connection = ConnectionFactory.getConnection(helperInfo); + connection = TransactionFactoryLoader.getInstance().getConnection(helperInfo); } else { - connection = ConnectionFactory.getConnection(driverName, connectionUrl, null, userName, password); + connection = getConnection(driverName, connectionUrl, null, userName, password); } if (connection == null) { @@ -150,6 +154,36 @@ public class DatabaseUtil { return connection; } + private Connection getConnection(String driverName, String connectionUrl, Properties props, String userName, String password) throws SQLException { + // first register the JDBC driver with the DriverManager + if (driverName != null) { + if (DriverManager.getDriver(driverName) == null) { + try { + Driver driver = (Driver) Class.forName(driverName, true, Thread.currentThread().getContextClassLoader()).newInstance(); + DriverManager.registerDriver(driver); + } catch (ClassNotFoundException e) { + Debug.logWarning(e, "Unable to load driver [" + driverName + "]", module); + } catch (InstantiationException e) { + Debug.logWarning(e, "Unable to instantiate driver [" + driverName + "]", module); + } catch (IllegalAccessException e) { + Debug.logWarning(e, "Illegal access exception [" + driverName + "]", module); + } + } + } + + try { + if (UtilValidate.isNotEmpty(userName)) + return DriverManager.getConnection(connectionUrl, userName, password); + else if (props != null) + return DriverManager.getConnection(connectionUrl, props); + else + return DriverManager.getConnection(connectionUrl); + } catch (SQLException e) { + Debug.logError(e, "SQL Error obtaining JDBC connection", module); + throw e; + } + } + protected Connection getConnectionLogged(Collection<String> messages) { try { return getConnection(); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java Tue Aug 26 09:16:52 2014 @@ -40,9 +40,10 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericDataSourceException; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.config.model.Datasource; -import org.ofbiz.entity.config.EntityConfigUtil; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.datasource.GenericHelperInfo; import org.ofbiz.entity.transaction.GenericTransactionException; +import org.ofbiz.entity.transaction.TransactionFactoryLoader; import org.ofbiz.entity.transaction.TransactionUtil; /** @@ -242,7 +243,7 @@ public class SQLProcessor { } /** - * Get a connection from the ConnectionFactory + * Get a connection from the TransactionFactoryLoader * * @return The connection created * @@ -256,7 +257,7 @@ public class SQLProcessor { _manualTX = true; try { - _connection = ConnectionFactory.getConnection(helperInfo); + _connection = TransactionFactoryLoader.getInstance().getConnection(helperInfo); if (Debug.verboseOn()) Debug.logVerbose("SQLProcessor:connection() : manualTx=" + _manualTX, module); } catch (SQLException sqle) { throw new GenericDataSourceException("Unable to esablish a connection with the database.", sqle); @@ -753,7 +754,7 @@ public class SQLProcessor { if (field != null) { _ps.setBlob(_ind, field); } else { - Datasource datasourceInfo = EntityConfigUtil.getDatasource(this.helperInfo.getHelperBaseName()); + Datasource datasourceInfo = EntityConfig.getDatasource(this.helperInfo.getHelperBaseName()); if (datasourceInfo.getUseBinaryTypeForBlob()) { _ps.setNull(_ind, Types.BINARY); } else { @@ -804,7 +805,7 @@ public class SQLProcessor { throw new SQLException(ex.getMessage()); } } else { - Datasource datasourceInfo = EntityConfigUtil.getDatasource(this.helperInfo.getHelperBaseName()); + Datasource datasourceInfo = EntityConfig.getDatasource(this.helperInfo.getHelperBaseName()); if (datasourceInfo.getUseBinaryTypeForBlob()) { _ps.setNull(_ind, Types.BINARY); } else { @@ -827,7 +828,7 @@ public class SQLProcessor { if (bytes != null) { _ps.setBytes(_ind, bytes); } else { - Datasource datasourceInfo = EntityConfigUtil.getDatasource(this.helperInfo.getHelperBaseName()); + Datasource datasourceInfo = EntityConfig.getDatasource(this.helperInfo.getHelperBaseName()); if (datasourceInfo.getUseBinaryTypeForBlob()) { _ps.setNull(_ind, Types.BINARY); } else { @@ -865,7 +866,7 @@ public class SQLProcessor { // check if the statement was called with a specific fetch size, if not grab the default from the datasource if (fetchSize < 0) { - Datasource ds = EntityConfigUtil.getDatasource(this.helperInfo.getHelperBaseName()); + Datasource ds = EntityConfig.getDatasource(this.helperInfo.getHelperBaseName()); if (ds != null) { fetchSize = ds.getResultFetchSize(); } else { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java Tue Aug 26 09:16:52 2014 @@ -47,8 +47,8 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.config.model.Datasource; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.jdbc.DatabaseUtil; import org.ofbiz.entity.model.ModelIndex.Field; import org.w3c.dom.Document; @@ -407,7 +407,7 @@ public class ModelEntity implements Comp /** The table-name of the Entity including a Schema name if specified in the datasource config */ public String getTableName(String helperName) { - return getTableName(EntityConfigUtil.getDatasource(helperName)); + return getTableName(EntityConfig.getDatasource(helperName)); } /** The table-name of the Entity including a Schema name if specified in the datasource config */ 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=1620538&r1=1620537&r2=1620538&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 Tue Aug 26 09:16:52 2014 @@ -33,8 +33,8 @@ import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.cache.UtilCache; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.config.model.Datasource; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.config.model.FieldType; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -66,7 +66,7 @@ public class ModelFieldTypeReader implem } public static ModelFieldTypeReader getModelFieldTypeReader(String helperName) { - Datasource datasourceInfo = EntityConfigUtil.getDatasource(helperName); + Datasource datasourceInfo = EntityConfig.getDatasource(helperName); if (datasourceInfo == null) { throw new IllegalArgumentException("Could not find a datasource/helper with the name " + helperName); } @@ -75,14 +75,14 @@ public class ModelFieldTypeReader implem while (reader == null) { FieldType fieldTypeInfo = null; try { - fieldTypeInfo = EntityConfigUtil.getFieldType(tempModelName); + fieldTypeInfo = EntityConfig.getInstance().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.getLoader(), fieldTypeInfo.getLocation()); + ResourceHandler fieldTypeResourceHandler = new MainResourceHandler(EntityConfig.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=1620538&r1=1620537&r2=1620538&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 Tue Aug 26 09:16:52 2014 @@ -37,8 +37,8 @@ import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.cache.UtilCache; import org.ofbiz.entity.GenericEntityConfException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.config.model.DelegatorElement; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.config.model.EntityGroupReader; import org.ofbiz.entity.config.model.Resource; import org.w3c.dom.Document; @@ -62,7 +62,7 @@ public class ModelGroupReader implements public List<ResourceHandler> entityGroupResourceHandlers = new LinkedList<ResourceHandler>(); public static ModelGroupReader getModelGroupReader(String delegatorName) throws GenericEntityConfException { - DelegatorElement delegatorInfo = EntityConfigUtil.getDelegator(delegatorName); + DelegatorElement delegatorInfo = EntityConfig.getInstance().getDelegator(delegatorName); if (delegatorInfo == null) { throw new GenericEntityConfException("Could not find a delegator with the name " + delegatorName); @@ -79,13 +79,13 @@ public class ModelGroupReader implements public ModelGroupReader(String modelName) throws GenericEntityConfException { this.modelName = modelName; - EntityGroupReader entityGroupReaderInfo = EntityConfigUtil.getEntityGroupReader(modelName); + EntityGroupReader entityGroupReaderInfo = EntityConfig.getInstance().getEntityGroupReader(modelName); if (entityGroupReaderInfo == null) { throw new GenericEntityConfException("Cound not find an entity-group-reader with the name " + modelName); } for (Resource resourceElement: entityGroupReaderInfo.getResourceList()) { - this.entityGroupResourceHandlers.add(new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, resourceElement.getLoader(), resourceElement.getLocation())); + this.entityGroupResourceHandlers.add(new MainResourceHandler(EntityConfig.ENTITY_ENGINE_XML_FILENAME, resourceElement.getLoader(), resourceElement.getLocation())); } // get all of the component resource group stuff, ie specified in each ofbiz-component.xml file @@ -171,7 +171,7 @@ public class ModelGroupReader implements if (groupName == null) { DelegatorElement delegatorInfo = null; try { - delegatorInfo = EntityConfigUtil.getDelegator(delegatorBaseName); + delegatorInfo = EntityConfig.getInstance().getDelegator(delegatorBaseName); } catch (GenericEntityConfException e) { Debug.logWarning(e, "Exception thrown while getting delegator config: ", module); } @@ -197,7 +197,7 @@ public class ModelGroupReader implements if (this.groupNames == null) return null; Set<String> newSet = new HashSet<String>(); try { - newSet.add(EntityConfigUtil.getDelegator(delegatorBaseName).getDefaultGroupName()); + newSet.add(EntityConfig.getInstance().getDelegator(delegatorBaseName).getDefaultGroupName()); } catch (GenericEntityConfException e) { Debug.logWarning(e, "Exception thrown while getting delegator config: ", module); } 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=1620538&r1=1620537&r2=1620538&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 Tue Aug 26 09:16:52 2014 @@ -42,8 +42,8 @@ import org.ofbiz.base.util.cache.UtilCac import org.ofbiz.entity.GenericEntityConfException; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericModelException; -import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.config.model.DelegatorElement; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.config.model.EntityModelReader; import org.ofbiz.entity.config.model.Resource; import org.w3c.dom.Document; @@ -80,7 +80,7 @@ public class ModelReader implements Seri protected Map<String, ResourceHandler> entityResourceHandlerMap; public static ModelReader getModelReader(String delegatorName) throws GenericEntityException { - DelegatorElement delegatorInfo = EntityConfigUtil.getDelegator(delegatorName); + DelegatorElement delegatorInfo = EntityConfig.getInstance().getDelegator(delegatorName); if (delegatorInfo == null) { throw new GenericEntityConfException("Could not find a delegator with the name " + delegatorName); @@ -104,7 +104,7 @@ public class ModelReader implements Seri resourceHandlerEntities = new HashMap<ResourceHandler, Collection<String>>(); entityResourceHandlerMap = new HashMap<String, ResourceHandler>(); - EntityModelReader entityModelReaderInfo = EntityConfigUtil.getEntityModelReader(modelName); + EntityModelReader entityModelReaderInfo = EntityConfig.getInstance().getEntityModelReader(modelName); if (entityModelReaderInfo == null) { throw new GenericEntityConfException("Cound not find an entity-model-reader with the name " + modelName); @@ -112,7 +112,7 @@ public class ModelReader implements Seri // get all of the main resource model stuff, ie specified in the entityengine.xml file for (Resource resourceElement : entityModelReaderInfo.getResourceList()) { - ResourceHandler handler = new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, resourceElement.getLoader(), resourceElement.getLocation()); + ResourceHandler handler = new MainResourceHandler(EntityConfig.ENTITY_ENGINE_XML_FILENAME, resourceElement.getLoader(), resourceElement.getLocation()); entityResourceHandlers.add(handler); } @@ -463,7 +463,7 @@ TEMP_VIEW_LOOP: } public void addEntityToResourceHandler(String entityName, String loaderName, String location) { - entityResourceHandlerMap.put(entityName, new MainResourceHandler(EntityConfigUtil.ENTITY_ENGINE_XML_FILENAME, loaderName, location)); + entityResourceHandlerMap.put(entityName, new MainResourceHandler(EntityConfig.ENTITY_ENGINE_XML_FILENAME, loaderName, location)); } public ResourceHandler getEntityResourceHandler(String entityName) { Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/test/EntityTestSuite.java Tue Aug 26 09:16:52 2014 @@ -46,8 +46,8 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityConditionList; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.config.model.Datasource; +import org.ofbiz.entity.config.model.EntityConfig; import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelField; import org.ofbiz.entity.testtools.EntityTestCase; @@ -461,7 +461,7 @@ public class EntityTestSuite extends Ent public void testForeignKeyCreate() { try { String helperName = delegator.getEntityHelper("Testing").getHelperName(); - Datasource datasourceInfo = EntityConfigUtil.getDatasource(helperName); + Datasource datasourceInfo = EntityConfig.getDatasource(helperName); if (!datasourceInfo.getUseForeignKeys()) { Debug.logInfo("Datasource " + datasourceInfo.getName() + " use-foreign-keys set to false, skipping testForeignKeyCreate", module); return; @@ -485,7 +485,7 @@ public class EntityTestSuite extends Ent public void testForeignKeyRemove() throws Exception { try { String helperName = delegator.getEntityHelper("TestingNode").getHelperName(); - Datasource datasourceInfo = EntityConfigUtil.getDatasource(helperName); + Datasource datasourceInfo = EntityConfig.getDatasource(helperName); if (!datasourceInfo.getUseForeignKeys()) { Debug.logInfo("Datasource " + datasourceInfo.getName() + " use-foreign-keys set to false, skipping testForeignKeyRemove", module); return; @@ -857,7 +857,7 @@ public class EntityTestSuite extends Ent */ /*public void testLimitOffsetOptions() throws Exception { String entityName = "Content"; - Datasource datasourceInfo = EntityConfigUtil.getDatasource(delegator.getEntityHelper(entityName).getHelperName()); + Datasource datasourceInfo = EntityConfig.getDatasource(delegator.getEntityHelper(entityName).getHelperName()); if (UtilValidate.isEmpty(datasourceInfo.offsetStyle) || datasourceInfo.offsetStyle.equals("none")) { Debug.logInfo("The offset-stype configured in datasource is " + datasourceInfo.offsetStyle + ", this test is skipped.", module); return; Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java?rev=1620538&r1=1620537&r2=1620538&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/GenericXaResource.java Tue Aug 26 09:16:52 2014 @@ -47,7 +47,7 @@ public abstract class GenericXaResource * @throws XAException */ public void enlist() throws XAException { - TransactionManager tm = TransactionFactory.getTransactionManager(); + TransactionManager tm = TransactionFactoryLoader.getInstance().getTransactionManager(); try { if (tm != null && tm.getStatus() == Status.STATUS_ACTIVE) { Transaction tx = tm.getTransaction(); |
Free forum by Nabble | Edit this page |