details: /erp/devel/pi/rev/3f9501eac1f6
changeset: 10977:3f9501eac1f6
user: Martin Taal <martin.taal <at> openbravo.com>
date: Wed Mar 02 17:48:52 2011 +0100
summary: Solve read of Openbravo.properties from source location
diffstat:
src-core/src/org/openbravo/database/ConnectionProviderImpl.java | 46 ++++++---
src/org/openbravo/base/model/ModelProvider.java | 4 +-
2 files changed, 29 insertions(+), 21 deletions(-)
diffs (84 lines):
diff -r 35c0b3d1c79c -r 3f9501eac1f6
src-core/src/org/openbravo/database/ConnectionProviderImpl.java
--- a/src-core/src/org/openbravo/database/ConnectionProviderImpl.java Wed Mar
02 17:03:33 2011 +0100
+++ b/src-core/src/org/openbravo/database/ConnectionProviderImpl.java Wed Mar
02 17:48:52 2011 +0100
@@ -40,6 +40,10 @@
String rdbms = "";
String contextName = "openbravo";
+ public ConnectionProviderImpl(Properties properties) throws
PoolNotFoundException {
+ create(properties, false, "openbravo");
+ }
+
public ConnectionProviderImpl(String file) throws PoolNotFoundException {
this(file, false, "openbravo");
}
@@ -55,6 +59,18 @@
private void create(String file, boolean isRelative, String _context)
throws PoolNotFoundException {
+ Properties properties = new Properties();
+ try {
+ properties.load(new FileInputStream(file));
+ create(properties, isRelative, _context);
+ } catch (IOException e) {
+ log4j.error("Error loading properties", e);
+ }
+ }
+
+ private void create(Properties properties, boolean isRelative, String
_context)
+ throws PoolNotFoundException {
+
log4j.debug("Creating ConnectionProviderImpl");
if (_context != null && !_context.equals(""))
contextName = _context;
@@ -70,24 +86,18 @@
String dbSessionConfig = null;
String rdbms = null;
- Properties properties = new Properties();
- try {
- properties.load(new FileInputStream(file));
- poolName = properties.getProperty("bbdd.poolName", "myPool");
- dbDriver = properties.getProperty("bbdd.driver");
- dbServer = properties.getProperty("bbdd.url");
- dbLogin = properties.getProperty("bbdd.user");
- dbPassword = properties.getProperty("bbdd.password");
- minConns = new Integer(properties.getProperty("bbdd.minConns", "1"));
- maxConns = new Integer(properties.getProperty("bbdd.maxConns", "10"));
- maxConnTime = new Double(properties.getProperty("maxConnTime", "0.5"));
- dbSessionConfig = properties.getProperty("bbdd.sessionConfig");
- rdbms = properties.getProperty("bbdd.rdbms");
- if (rdbms.equalsIgnoreCase("POSTGRE"))
- dbServer += "/" + properties.getProperty("bbdd.sid");
- } catch (IOException e) {
- log4j.error("Error loading properties", e);
- }
+ poolName = properties.getProperty("bbdd.poolName", "myPool");
+ dbDriver = properties.getProperty("bbdd.driver");
+ dbServer = properties.getProperty("bbdd.url");
+ dbLogin = properties.getProperty("bbdd.user");
+ dbPassword = properties.getProperty("bbdd.password");
+ minConns = new Integer(properties.getProperty("bbdd.minConns", "1"));
+ maxConns = new Integer(properties.getProperty("bbdd.maxConns", "10"));
+ maxConnTime = new Double(properties.getProperty("maxConnTime", "0.5"));
+ dbSessionConfig = properties.getProperty("bbdd.sessionConfig");
+ rdbms = properties.getProperty("bbdd.rdbms");
+ if (rdbms.equalsIgnoreCase("POSTGRE"))
+ dbServer += "/" + properties.getProperty("bbdd.sid");
if (log4j.isDebugEnabled()) {
log4j.debug("poolName: " + poolName);
diff -r 35c0b3d1c79c -r 3f9501eac1f6
src/org/openbravo/base/model/ModelProvider.java
--- a/src/org/openbravo/base/model/ModelProvider.java Wed Mar 02 17:03:33
2011 +0100
+++ b/src/org/openbravo/base/model/ModelProvider.java Wed Mar 02 17:48:52
2011 +0100
@@ -292,9 +292,7 @@
ConnectionProviderImpl con = null;
Connection connection = null;
try {
- con = new
ConnectionProviderImpl(OBPropertiesProvider.getInstance().getOpenbravoProperties()
- .getProperty("source.path")
- + "/config/Openbravo.properties");
+ con = new
ConnectionProviderImpl(OBPropertiesProvider.getInstance().getOpenbravoProperties());
connection = con.getConnection();
PreparedStatement ps = connection
.prepareStatement("select distinct model_impl from ad_reference
where model_impl is not null");
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits