diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConfigurationProperties.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConfigurationProperties.java new file mode 100644 index 000000000..3edd5abdb --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConfigurationProperties.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.conf; + +import java.util.Set; + +import org.apache.openjpa.persistence.test.SingleEMFTestCase; + +/** + * Test supported configuration properties for EntityManagerFactory, + * EntityManager and Query. + * + * @author Pinaki Poddar + * + */ +public class TestConfigurationProperties + extends SingleEMFTestCase { + + public void setUp() throws Exception { + super.setUp(); + assertNotNull(emf); + } + + public void testEMFSupportedProperties() { + Set p = emf.getSupportedProperties(); + assertTrue(p.contains("javax.persistence.jdbc.driver")); + } +} diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java index 8b29b9a10..1666482b2 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java @@ -18,11 +18,13 @@ */ 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; @@ -69,6 +71,7 @@ public class EntityManagerFactoryImpl private transient Constructor _plan = null; private transient StoreCache _cache = null; private transient QueryResultCache _queryCache = null; + private Set _supportedPropertyKeys; /** * Default constructor provided for auto-instantiation. @@ -348,7 +351,22 @@ public class EntityManagerFactoryImpl } public Set getSupportedProperties() { - throw new UnsupportedOperationException( - "JPA 2.0 - Method not yet implemented"); + if (_supportedPropertyKeys != null) + return _supportedPropertyKeys; + _supportedPropertyKeys = new HashSet(); + try { + InputStream rsrc = this.getClass() + .getResourceAsStream("supported_emf.properties"); + if (rsrc == null) + return _supportedPropertyKeys; + Properties p = new Properties(); + p.load(rsrc); + for (Object key : p.keySet()) { + _supportedPropertyKeys.add(key.toString()); + } + } catch (Exception ex) { + + } + return _supportedPropertyKeys; } } diff --git a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/supported_emf.properties b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/supported_emf.properties new file mode 100644 index 000000000..99934e854 --- /dev/null +++ b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/supported_emf.properties @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# ------------------------------------------------------------------------------ +# Enumerates property keys supported by OpenJPA EntityManagerFactory. +# +# This enumeration includes both JPA Specification defined properties and +# OpenJPA-specific extension properties. +# +# Document the properties as values. Runtime, however, only reads the keys. +#------------------------------------------------------------------------------- +javax.persistence.jdbc.driver: Fully-qualified class name of JDBC Driver. \ No newline at end of file