OPENJPA-849 Committing code and corresponding tests contributed by Dianne Richards

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@740991 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeremy Bauer 2009-02-05 03:31:15 +00:00
parent fa86624289
commit c3691f5e88
3 changed files with 35 additions and 18 deletions

View File

@ -18,23 +18,18 @@
*/
package org.apache.openjpa.persistence;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.persistence.Cache;
import javax.persistence.EntityManagerFactory;
import javax.persistence.QueryBuilder;
import org.apache.openjpa.conf.OpenJPAConfiguration;
import org.apache.openjpa.enhance.Reflection;
import org.apache.openjpa.kernel.AutoDetach;
@ -71,7 +66,6 @@ public class EntityManagerFactoryImpl
private transient Constructor<FetchPlan> _plan = null;
private transient StoreCache _cache = null;
private transient QueryResultCache _queryCache = null;
private Set<String> _supportedPropertyKeys;
/**
* Default constructor provided for auto-instantiation.
@ -104,9 +98,20 @@ public class EntityManagerFactoryImpl
public OpenJPAConfiguration getConfiguration() {
return _factory.getConfiguration();
}
public Properties getProperties() {
return _factory.getProperties();
/*
* @see javax.persistence.EntityManagerFactory#getProperties()
*
* This does not return the password property.
*/
public Map getProperties() {
Map properties = _factory.getAllProperties();
// Remove the password property
properties.remove("javax.persistence.jdbc.password");
properties.remove("openjpa.ConnectionPassword");
return properties;
}
public Object putUserObject(Object key, Object val) {
@ -350,7 +355,6 @@ public class EntityManagerFactoryImpl
}
public Set<String> getSupportedProperties() {
throw new UnsupportedOperationException(
"JPA 2.0 - Method not yet implemented");
return _factory.getSupportedProperties();
}
}

View File

@ -31,6 +31,7 @@ import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Set;
@ -964,7 +965,7 @@ public class EntityManagerImpl
return _broker.getCachePreparedQuery() ?
getConfiguration().getQuerySQLCacheInstance() : null;
}
/**
* Gets the prepared query cached by the given key.
*
@ -975,7 +976,6 @@ public class EntityManagerImpl
return (cache == null) ? null : cache.get(id);
}
public void setFlushMode(FlushModeType flushMode) {
assertNotCloseInvoked();
_broker.assertOpen();
@ -1442,9 +1442,23 @@ public class EntityManagerImpl
"JPA 2.0 - Method not yet implemented");
}
/*
* @see javax.persistence.EntityManager#getProperties()
*
* This does not return the password property.
*/
public Map<String, Object> getProperties() {
throw new UnsupportedOperationException(
"JPA 2.0 - Method not yet implemented");
Map<String, String> currentProperties = _broker.getProperties();
// Convert the <String, String> map into a <String, Object> map
Map<String, Object> finalMap =
new HashMap<String, Object>(currentProperties);
// Remove the password property
finalMap.remove("javax.persistence.jdbc.password");
finalMap.remove("openjpa.ConnectionPassword");
return finalMap;
}
public OpenJPAQueryBuilder getQueryBuilder() {
@ -1452,8 +1466,7 @@ public class EntityManagerImpl
}
public Set<String> getSupportedProperties() {
throw new UnsupportedOperationException(
"JPA 2.0 - Method not yet implemented");
return _broker.getSupportedProperties();
}
public void lock(Object entity, LockModeType lockMode, Map<String,

View File

@ -36,7 +36,7 @@ public interface OpenJPAEntityManagerFactory
/**
* Return properties describing this runtime.
*/
public Properties getProperties();
public Map<String, Object> getProperties();
/**
* Put the specified key-value pair into the map of user objects.