Author: pcl Date: Tue Nov 14 16:30:24 2006 New Revision: 475084 URL: http://svn.apache.org/viewvc?view=rev&rev=475084 Log: added openjpa.Id property, and put logic in PersistenceUnitInfoImpl to set the openjpa.Id property to the persistence unit name if no openjpa.Id property is discovered.
Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java?view=diff&rev=475084&r1=475083&r2=475084 ============================================================================== --- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java (original) +++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java Tue Nov 14 16:30:24 2006 @@ -1383,4 +1383,22 @@ * configuration. */ public StoreFacadeTypeRegistry getStoreFacadeTypeRegistry(); + + /** + * An environment-specific identifier for this configuration. This + * might correspond to a JPA persistence-unit name, or to some other + * more-unique value available in the current environment. + * + * @since 0.9.7 + */ + public String getId(); + + /** + * An environment-specific identifier for this configuration. This + * might correspond to a JPA persistence-unit name, or to some other + * more-unique value available in the current environment. + * + * @since 0.9.7 + */ + public void setId(String id); } Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java?view=diff&rev=475084&r1=475083&r2=475084 ============================================================================== --- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java (original) +++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java Tue Nov 14 16:30:24 2006 @@ -127,6 +127,7 @@ public ObjectValue orphanedKeyPlugin; public ObjectValue compatibilityPlugin; public QueryCompilationCacheValue queryCompilationCachePlugin; + public StringValue id; // custom values public BrokerFactoryValue brokerFactoryPlugin; @@ -465,6 +466,8 @@ queryCompilationCachePlugin.setInstantiatingGetter( "getQueryCompilationCacheInstance"); addValue(queryCompilationCachePlugin); + + addString("Id"); // initialize supported options that some runtimes may not support supportedOptions.add(OPTION_NONTRANS_READ); @@ -1403,6 +1406,15 @@ public StoreFacadeTypeRegistry getStoreFacadeTypeRegistry() { return _storeFacadeRegistry; + } + + public String getId() { + return id.get(); + } + + public void setId(String id) { + assertNotReadOnly(); + this.id.set(id); } public void instantiateAll() { Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties?view=diff&rev=475084&r1=475083&r2=475084 ============================================================================== --- incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties (original) +++ incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/conf/localizer.properties Tue Nov 14 16:30:24 2006 @@ -557,6 +557,15 @@ QueryCompilationCache-expert: true QueryCompilationCache-interface: java.util.Map +Id-name: Configuration ID +Id-desc: An environment-specific identifier for this configuration. This \ + might correspond to a JPA persistence-unit name, or to some other \ + more-unique value available in the current environment. +Id-type: General +Id-cat: Persistence +Id-displayorder: 50 +Id-expert: true + no-named-cf: use a DataSource bound to JNDI diff-specs: Attempt to configure for multiple specifications. Was configured \ for "{0}". Attempt to now configure for "{1}". This attempt will be \ Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java?view=diff&rev=475084&r1=475083&r2=475084 ============================================================================== --- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java (original) +++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java Tue Nov 14 16:30:24 2006 @@ -357,6 +357,9 @@ map.remove(PersistenceProviderImpl.CLASS_TRANSFORMER_OPTIONS); } + if (!map.containsKey("openjpa.Id")) + map.put("openjpa.Id", info.getPersistenceUnitName()); + Properties metaFactoryProps = new Properties(); if (info.getManagedClassNames() != null && !info.getManagedClassNames().isEmpty()) { @@ -416,7 +419,7 @@ } map.put("openjpa.MetaDataFactory", factory); } - + // always record provider name for product derivations to access if (info.getPersistenceProviderClassName() != null) map.put(KEY_PROVIDER, info.getPersistenceProviderClassName());