Author: ppoddar
Date: Mon Jan 19 09:47:19 2009
New Revision: 735760

URL: http://svn.apache.org/viewvc?rev=735760&view=rev
Log:
OPENJPA-849: Load supported properties from resource.

Added:
    
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConfigurationProperties.java
    
openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/supported_emf.properties
Modified:
    
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java

Added: 
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConfigurationProperties.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConfigurationProperties.java?rev=735760&view=auto
==============================================================================
--- 
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConfigurationProperties.java
 (added)
+++ 
openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestConfigurationProperties.java
 Mon Jan 19 09:47:19 2009
@@ -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<String> p = emf.getSupportedProperties();
+        assertTrue(p.contains("javax.persistence.jdbc.driver"));
+    }
+}

Modified: 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java?rev=735760&r1=735759&r2=735760&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
 (original)
+++ 
openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
 Mon Jan 19 09:47:19 2009
@@ -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 @@
     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.
@@ -348,7 +351,22 @@
     }
 
     public Set<String> getSupportedProperties() {
-        throw new UnsupportedOperationException(
-            "JPA 2.0 - Method not yet implemented");
+        if (_supportedPropertyKeys != null)
+            return _supportedPropertyKeys;
+        _supportedPropertyKeys = new HashSet<String>();
+        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;
     }
 }

Added: 
openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/supported_emf.properties
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/supported_emf.properties?rev=735760&view=auto
==============================================================================
--- 
openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/supported_emf.properties
 (added)
+++ 
openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/supported_emf.properties
 Mon Jan 19 09:47:19 2009
@@ -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


Reply via email to