summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2008-02-29 02:25:40 (EST)
committerMartin Taal2008-02-29 02:25:40 (EST)
commitab577552c92ee4094e0f0d4fbbb23b42f01d436a (patch)
tree842fe7f5ee615fb5e048a868e3e2826afddc02f9
parenta90a6720f8e935ac6125f68ee0ab546753d02637 (diff)
downloadcdo-ab577552c92ee4094e0f0d4fbbb23b42f01d436a.zip
cdo-ab577552c92ee4094e0f0d4fbbb23b42f01d436a.tar.gz
cdo-ab577552c92ee4094e0f0d4fbbb23b42f01d436a.tar.bz2
Read properties from the store properties instead of separate properties
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java25
5 files changed, 41 insertions, 58 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java
index 1f68894..1545af1 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/hibernate/CDOHibernateUtil.java
@@ -13,8 +13,6 @@ package org.eclipse.emf.cdo.server.hibernate;
import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore;
-import java.util.Properties;
-
/**
* @author Eike Stepper
* @author Martin Taal
@@ -25,8 +23,8 @@ public final class CDOHibernateUtil
{
}
- public static IHibernateStore createStore(IHibernateMappingProvider mappingProvider, Properties properties)
+ public static IHibernateStore createStore(IHibernateMappingProvider mappingProvider)
{
- return new HibernateStore(mappingProvider, properties);
+ return new HibernateStore(mappingProvider);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
index 7c5a341..fc9df34 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
@@ -35,7 +35,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Properties;
/**
* Delegate which stores and retrieves cdo packages.
@@ -57,8 +56,6 @@ public class HibernatePackageHandler
private int nextFeatureID;
- private Properties properties;
-
private Collection<CDOPackageInfo> cdoPackageInfos = null;
private Collection<CDOPackage> cdoPackages = null;
@@ -68,18 +65,9 @@ public class HibernatePackageHandler
/**
* TODO Necessary to pass/store/dump the properties from the store?
*/
- public HibernatePackageHandler(HibernateStore store, Properties properties)
+ public HibernatePackageHandler(HibernateStore store)
{
hibernateStore = store;
- this.properties = properties;
- // if (TRACER.isEnabled())
- // {
- // TRACER.format("Created {0} with properties:", getClass().getName());
- // for (Entry<Object, Object> property : properties.entrySet())
- // {
- // TRACER.format("Property: {0} = {1}", property.getKey(), property.getValue());
- // }
- // }
}
public void writePackages(CDOPackage... cdoPackages)
@@ -280,7 +268,7 @@ public class HibernatePackageHandler
in = OM.BUNDLE.getInputStream("mappings/meta.hbm.xml");
configuration = new Configuration();
configuration.addInputStream(in);
- configuration.setProperties(properties);
+ configuration.setProperties(HibernateUtil.getInstance().getPropertiesFromStore(hibernateStore));
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java
index fd8425e..9040e49 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStore.java
@@ -23,7 +23,6 @@ import org.eclipse.emf.cdo.server.internal.hibernate.id.CDOIDHibernateFactoryImp
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.io.IOUtil;
import org.hibernate.SessionFactory;
@@ -33,8 +32,6 @@ import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Properties;
-import java.util.Map.Entry;
/**
* @author Eike Stepper
@@ -61,36 +58,15 @@ public class HibernateStore extends Store implements IHibernateStore
private IHibernateMappingProvider mappingProvider;
- // Exclude from dump due to contained db password
- // TODO Can't the properties of Store.java be used?
- @ExcludeFromDump
- private Properties properties;
-
- public HibernateStore(IHibernateMappingProvider mappingProvider, Properties properties)
+ public HibernateStore(IHibernateMappingProvider mappingProvider)
{
super(TYPE);
this.mappingProvider = mappingProvider;
- this.properties = properties;
- packageHandler = new HibernatePackageHandler(this, properties);
- if (TRACER.isEnabled())
- {
- TRACER.format("Created {0} with properties:", getClass().getName());
- for (Entry<Object, Object> property : properties.entrySet())
- {
- Object key = property.getKey();
- Object value = property.getValue();
- if (key instanceof String && ((String)key).contains("password"))
- {
- value = "****************";
- }
+ packageHandler = new HibernatePackageHandler(this);
- TRACER.format("Property: {0} = {1}", key, value);
- }
-
- if (mappingProvider != null)
- {
- TRACER.trace("With mappingProvider " + mappingProvider.getClass().getName());
- }
+ if (mappingProvider != null)
+ {
+ TRACER.trace("With mappingProvider " + mappingProvider.getClass().getName());
}
}
@@ -297,7 +273,7 @@ public class HibernateStore extends Store implements IHibernateStore
hibernateConfiguration.addXML(mapping);
}
- hibernateConfiguration.setProperties(properties);
+ hibernateConfiguration.setProperties(HibernateUtil.getInstance().getPropertiesFromStore(this));
}
catch (Exception ex)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
index 1101a82..1c3b362 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateUtil.java
@@ -14,11 +14,15 @@ import org.eclipse.emf.cdo.internal.protocol.id.CDOIDNullImpl;
import org.eclipse.emf.cdo.protocol.id.CDOID;
import org.eclipse.emf.cdo.protocol.id.CDOIDTemp;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.IStoreWriter.CommitContext;
import org.eclipse.emf.cdo.server.hibernate.CDOIDHibernate;
import org.hibernate.Session;
+import java.util.Map;
+import java.util.Properties;
+
/**
* @author Martin Taal
*/
@@ -43,6 +47,18 @@ public class HibernateUtil
HibernateUtil.instance = instance;
}
+ /** Converts from a Map<String, String> to a Properties */
+ public Properties getPropertiesFromStore(IStore store)
+ {
+ final Properties props = new Properties();
+ final Map<String, String> storeProps = store.getRepository().getProperties();
+ for (String key : storeProps.keySet())
+ {
+ props.setProperty(key, storeProps.get(key));
+ }
+ return props;
+ }
+
public String getEntityName(CDORevision cdoRevision)
{
return cdoRevision.getCDOClass().getName();
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java
index c920252..112a66b 100644
--- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateTest.java
@@ -54,7 +54,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
/**
* @author Eike Stepper
@@ -162,10 +161,13 @@ public class HibernateTest extends AbstractOMTest
props.put(Props.PROP_VERIFYING_REVISIONS, "false");
props.put(Props.PROP_CURRENT_LRU_CAPACITY, "10000");
props.put(Props.PROP_REVISED_LRU_CAPACITY, "10000");
+
+ addHibernateTeneoProperties(props);
+
return CDOServerUtil.createRepository(REPOSITORY_NAME, createStore(), props);
}
- private static IStore createStore() throws Exception
+ private static void addHibernateTeneoProperties(Map<String, String> props) throws Exception
{
DriverManager.setLogWriter(new PrintWriter(System.out));
Driver driver = new com.mysql.jdbc.Driver();
@@ -173,17 +175,20 @@ public class HibernateTest extends AbstractOMTest
String driverName = driver.getClass().getName();
String dialectName = MySQLInnoDBDialect.class.getName();
- Properties props = new Properties();
- props.setProperty(Environment.DRIVER, driverName);
- props.setProperty(Environment.URL, "jdbc:mysql://localhost/cdohibernate");
- props.setProperty(Environment.USER, "cdo");
+ props.put(Environment.DRIVER, driverName);
+ props.put(Environment.URL, "jdbc:mysql://localhost/cdohibernate");
+ props.put(Environment.USER, "cdo");
// props.setProperty(Environment.PASS, "root");
- props.setProperty(Environment.DIALECT, dialectName);
- props.setProperty(Environment.SHOW_SQL, "true");
- props.setProperty("hibernate.hbm2ddl.auto", "create-drop");
+ props.put(Environment.DIALECT, dialectName);
+ props.put(Environment.SHOW_SQL, "true");
+ props.put("hibernate.hbm2ddl.auto", "create-drop");
+ }
+
+ private static IStore createStore() throws Exception
+ {
// IHibernateMappingProvider mappingProvider = new TeneoHibernateMappingProvider();
// return new HibernateStore(props, mappingProvider);
- return new HibernateStore(null, props);
+ return new HibernateStore(null);
}
private static EObject getInputModel()