Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 72846 invoked from network); 30 Aug 2007 20:20:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Aug 2007 20:20:10 -0000 Received: (qmail 82617 invoked by uid 500); 30 Aug 2007 20:20:05 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 82603 invoked by uid 500); 30 Aug 2007 20:20:05 -0000 Mailing-List: contact commits-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list commits@openjpa.apache.org Received: (qmail 82594 invoked by uid 99); 30 Aug 2007 20:20:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Aug 2007 13:20:05 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Aug 2007 20:20:08 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BB94A1A9832; Thu, 30 Aug 2007 13:19:47 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r571294 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/ openjpa-kernel/src/main/java/org/apache/openjpa/conf/ openjpa-kernel/src/main/java/org/apache/o... Date: Thu, 30 Aug 2007 20:19:45 -0000 To: commits@openjpa.apache.org From: ppoddar@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070830201947.BB94A1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ppoddar Date: Thu Aug 30 13:19:44 2007 New Revision: 571294 URL: http://svn.apache.org/viewvc?rev=571294&view=rev Log: Allow dynamic configuration property. Changes include 1. Add getter/setter for boolean 'dynamic' field of Value 2. Add Value.assertChangeable() that Value subclasses must invoke prior to set new internal state 3. Changes Configuration readOnly state from a boolean to a simple 3-step state variable INIT_STATE_LIQUID/FREEZING/FROZEN. This is done to allow lazy instantiation of some PluginValues after the BrokerFactory freezes configuration. 4. Removes assertNotReadOnly() check from Configuration implementations' setX() methods. 5. Removes dynamic Value related methods from Configuration API and its implementations Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/DoubleValue.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/IntValue.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/PluginValue.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringListValue.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/StringValue.java openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Value.java openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestDynamicConfiguration.java openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/JDBCConfigurationImpl.java Thu Aug 30 13:19:44 2007 @@ -328,7 +328,6 @@ } public void setSchema(String schema) { - assertNotReadOnly(); this.schema.setString(schema); } @@ -337,7 +336,6 @@ } public void setSchemas(String schemas) { - assertNotReadOnly(); this.schemas.setString(schemas); } @@ -346,7 +344,6 @@ } public void setSchemas(String[] schemas) { - assertNotReadOnly(); this.schemas.set(schemas); } @@ -355,7 +352,6 @@ } public void setTransactionIsolation(String transactionIsolation) { - assertNotReadOnly(); this.transactionIsolation.setString(transactionIsolation); } @@ -364,7 +360,6 @@ } public void setTransactionIsolation(int transactionIsolation) { - assertNotReadOnly(); this.transactionIsolation.set(transactionIsolation); } @@ -373,7 +368,6 @@ } public void setResultSetType(String resultSetType) { - assertNotReadOnly(); this.resultSetType.setString(resultSetType); } @@ -382,7 +376,6 @@ } public void setResultSetType(int resultSetType) { - assertNotReadOnly(); this.resultSetType.set(resultSetType); } @@ -391,7 +384,6 @@ } public void setFetchDirection(String fetchDirection) { - assertNotReadOnly(); this.fetchDirection.setString(fetchDirection); } @@ -400,7 +392,6 @@ } public void setFetchDirection(int fetchDirection) { - assertNotReadOnly(); this.fetchDirection.set(fetchDirection); } @@ -409,7 +400,6 @@ } public void setEagerFetchMode(String eagerFetchMode) { - assertNotReadOnly(); this.eagerFetchMode.setString(eagerFetchMode); } @@ -418,7 +408,6 @@ } public void setEagerFetchMode(int eagerFetchMode) { - assertNotReadOnly(); this.eagerFetchMode.set(eagerFetchMode); } @@ -427,7 +416,6 @@ } public void setSubclassFetchMode(String subclassFetchMode) { - assertNotReadOnly(); this.subclassFetchMode.setString(subclassFetchMode); } @@ -436,7 +424,6 @@ } public void setSubclassFetchMode(int subclassFetchMode) { - assertNotReadOnly(); this.subclassFetchMode.set(subclassFetchMode); } @@ -445,7 +432,6 @@ } public void setLRSSize(String lrsSize) { - assertNotReadOnly(); this.lrsSize.setString(lrsSize); } @@ -454,7 +440,6 @@ } public void setLRSSize(int lrsSize) { - assertNotReadOnly(); this.lrsSize.set(lrsSize); } @@ -463,7 +448,6 @@ } public void setSynchronizeMappings(String synchronizeMappings) { - assertNotReadOnly(); this.synchronizeMappings.set(synchronizeMappings); } @@ -472,7 +456,6 @@ } public void setJDBCListeners(String jdbcListeners) { - assertNotReadOnly(); jdbcListenerPlugins.setString(jdbcListeners); } @@ -481,7 +464,6 @@ } public void setJDBCListeners(JDBCListener[] listeners) { - assertNotReadOnly(); jdbcListenerPlugins.set(listeners); } @@ -492,7 +474,6 @@ } public void setConnectionDecorators(String connectionDecorators) { - assertNotReadOnly(); connectionDecoratorPlugins.setString(connectionDecorators); } @@ -501,7 +482,6 @@ } public void setConnectionDecorators(ConnectionDecorator[] decorators) { - assertNotReadOnly(); connectionDecoratorPlugins.set(decorators); } @@ -514,7 +494,6 @@ } public void setDBDictionary(String dbdictionary) { - assertNotReadOnly(); dbdictionaryPlugin.setString(dbdictionary); } @@ -529,7 +508,6 @@ || connectionFactory2.get() != null) throw new IllegalStateException(); - assertNotReadOnly(); dbdictionaryPlugin.set(dbdictionary); } @@ -576,7 +554,6 @@ } public void setUpdateManager(String updateManager) { - assertNotReadOnly(); updateManagerPlugin.setString(updateManager); } @@ -585,7 +562,6 @@ } public void setUpdateManager(UpdateManager updateManager) { - assertNotReadOnly(); updateManagerPlugin.set(updateManager); } @@ -596,7 +572,6 @@ } public void setDriverDataSource(String driverDataSource) { - assertNotReadOnly(); driverDataSourcePlugin.setString(driverDataSource); } @@ -610,7 +585,6 @@ } public void setSchemaFactory(String schemaFactory) { - assertNotReadOnly(); schemaFactoryPlugin.setString(schemaFactory); } @@ -619,7 +593,6 @@ } public void setSchemaFactory(SchemaFactory schemaFactory) { - assertNotReadOnly(); schemaFactoryPlugin.set(schemaFactory); } @@ -630,7 +603,6 @@ } public void setSQLFactory(String sqlFactory) { - assertNotReadOnly(); sqlFactoryPlugin.setString(sqlFactory); } @@ -639,7 +611,6 @@ } public void setSQLFactory(SQLFactory sqlFactory) { - assertNotReadOnly(); sqlFactoryPlugin.set(sqlFactory); } @@ -654,7 +625,6 @@ } public void setMappingFactory(String mapping) { - assertNotReadOnly(); mappingFactoryPlugin.setString(mapping); } @@ -664,7 +634,6 @@ } public void setMappingDefaults(String mapping) { - assertNotReadOnly(); this.mappingDefaultsPlugin.setString(mapping); } @@ -673,7 +642,6 @@ } public void setMappingDefaults(MappingDefaults mapping) { - assertNotReadOnly(); mappingDefaultsPlugin.set(mapping); } @@ -719,7 +687,6 @@ return; // override to configure data source - assertNotReadOnly(); if (factory != null) { // need to ensure it is decorated before we set the dict DecoratingDataSource ds = @@ -779,7 +746,6 @@ return; // override to configure data source - assertNotReadOnly(); if (factory != null) { // need to ensure it is decorated before we set the dict DecoratingDataSource ds = setupConnectionFactory((DataSource) Modified: openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java (original) +++ openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java Thu Aug 30 13:19:44 2007 @@ -23,6 +23,7 @@ import org.apache.openjpa.conf.OpenJPAConfiguration; import org.apache.openjpa.conf.OpenJPAConfigurationImpl; +import org.apache.openjpa.lib.conf.Configuration; import org.apache.openjpa.lib.conf.Configurations; import org.apache.openjpa.lib.util.J2DoPrivHelper; import org.apache.openjpa.lib.util.Options; @@ -108,7 +109,7 @@ return tmpLoader; } }); - conf.setReadOnly(true); + conf.setReadOnly(Configuration.INIT_STATE_FREEZING); conf.instantiateAll(); // avoid threading issues PCClassFileTransformer transformer = new PCClassFileTransformer Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java Thu Aug 30 13:19:44 2007 @@ -211,6 +211,7 @@ dataCacheTimeout = addInt("DataCacheTimeout"); dataCacheTimeout.setDefault("-1"); dataCacheTimeout.set(-1); + dataCacheTimeout.setDynamic(true); queryCachePlugin = addPlugin("QueryCache", true); aliases = new String[] { @@ -304,6 +305,12 @@ connectionFactory2 = addObject("ConnectionFactory2"); connectionFactory2.setInstantiatingGetter("getConnectionFactory2"); + // This is done because this plug-in may get initialized very lazily + // when the runtime needs it for flush or a sequence. To keep it + // dynamic allows it to be set even when the configuration is frozen + connectionFactory.setDynamic(true); + connectionFactory2.setDynamic(true); + connectionUserName = addString("ConnectionUserName"); connectionPassword = addString("ConnectionPassword"); @@ -384,6 +391,7 @@ fetchBatchSize = addInt("FetchBatchSize"); fetchBatchSize.setDefault("-1"); fetchBatchSize.set(-1); + fetchBatchSize.setDynamic(true); maxFetchDepth = addInt("MaxFetchDepth"); maxFetchDepth.setDefault("-1"); @@ -407,7 +415,8 @@ lockTimeout = addInt("LockTimeout"); lockTimeout.setDefault("-1"); lockTimeout.set(-1); - + lockTimeout.setDynamic(true); + readLockLevel = addInt("ReadLockLevel"); aliases = new String[] { @@ -541,7 +550,6 @@ } public void setClassResolver(String classResolver) { - assertNotReadOnly(); classResolverPlugin.setString(classResolver); } @@ -550,7 +558,6 @@ } public void setClassResolver(ClassResolver classResolver) { - assertNotReadOnly(); classResolverPlugin.set(classResolver); } @@ -561,7 +568,6 @@ } public void setBrokerFactory(String factory) { - assertNotReadOnly(); brokerFactoryPlugin.setString(factory); } @@ -570,7 +576,6 @@ } public void setBrokerImpl(String broker) { - assertNotReadOnly(); brokerPlugin.setString(broker); } @@ -587,7 +592,6 @@ } public void setDataCacheManager(String mgr) { - assertNotReadOnly(); dataCacheManagerPlugin.setString(mgr); } @@ -596,7 +600,6 @@ } public void setDataCacheManager(DataCacheManager dcm) { - assertNotReadOnly(); if (dcm != null) dcm.initialize(this, dataCachePlugin, queryCachePlugin); dataCacheManagerPlugin.set(dcm); @@ -614,7 +617,6 @@ } public void setDataCache(String dataCache) { - assertNotReadOnly(); dataCachePlugin.setString(dataCache); } @@ -623,7 +625,6 @@ } public void setDataCacheTimeout(int dataCacheTimeout) { - assertNotReadOnly(); this.dataCacheTimeout.set(dataCacheTimeout); } @@ -637,7 +638,6 @@ } public void setQueryCache(String queryCache) { - assertNotReadOnly(); queryCachePlugin.setString(queryCache); } @@ -658,7 +658,6 @@ } public void setLockManager(String lockManager) { - assertNotReadOnly(); lockManagerPlugin.setString(lockManager); } @@ -675,7 +674,6 @@ } public void setInverseManager(String inverseManager) { - assertNotReadOnly(); inverseManagerPlugin.setString(inverseManager); } @@ -689,7 +687,6 @@ } public void setSavepointManager(String savepointManager) { - assertNotReadOnly(); savepointManagerPlugin.setString(savepointManager); } @@ -704,7 +701,6 @@ } public void setOrphanedKeyAction(String action) { - assertNotReadOnly(); orphanedKeyPlugin.setString(action); } @@ -719,12 +715,10 @@ } public void setOrphanedKeyAction(OrphanedKeyAction action) { - assertNotReadOnly(); orphanedKeyPlugin.set(action); } public void setRemoteCommitProvider(String remoteCommitProvider) { - assertNotReadOnly(); remoteProviderPlugin.setString(remoteCommitProvider); } @@ -738,7 +732,6 @@ public void setRemoteCommitEventManager( RemoteCommitEventManager remoteEventManager) { - assertNotReadOnly(); this.remoteEventManager = remoteEventManager; remoteProviderPlugin.configureEventManager(remoteEventManager); } @@ -752,7 +745,6 @@ } public void setTransactionMode(String transactionMode) { - assertNotReadOnly(); this.transactionMode.setString(transactionMode); } @@ -761,7 +753,6 @@ } public void setTransactionModeManaged(boolean managed) { - assertNotReadOnly(); transactionMode.set(managed); } @@ -770,7 +761,6 @@ } public void setManagedRuntime(String managedRuntime) { - assertNotReadOnly(); managedRuntimePlugin.setString(managedRuntime); } @@ -779,7 +769,6 @@ } public void setManagedRuntime(ManagedRuntime managedRuntime) { - assertNotReadOnly(); managedRuntimePlugin.set(managedRuntime); } @@ -790,7 +779,6 @@ } public void setProxyManager(String proxyManager) { - assertNotReadOnly(); proxyManagerPlugin.setString(proxyManager); } @@ -799,7 +787,6 @@ } public void setProxyManager(ProxyManager proxyManager) { - assertNotReadOnly(); proxyManagerPlugin.set(proxyManager); } @@ -810,7 +797,6 @@ } public void setMapping(String mapping) { - assertNotReadOnly(); this.mapping.setString(mapping); } @@ -819,7 +805,6 @@ } public void setMetaDataFactory(String meta) { - assertNotReadOnly(); this.metaFactoryPlugin.setString(meta); } @@ -833,7 +818,6 @@ } public void setMetaDataRepository(String meta) { - assertNotReadOnly(); this.metaRepositoryPlugin.setString(meta); } @@ -842,7 +826,6 @@ } public void setMetaDataRepository(MetaDataRepository meta) { - assertNotReadOnly(); metaRepository = meta; } @@ -858,7 +841,6 @@ } public void setConnectionUserName(String connectionUserName) { - assertNotReadOnly(); this.connectionUserName.setString(connectionUserName); } @@ -867,7 +849,6 @@ } public void setConnectionPassword(String connectionPassword) { - assertNotReadOnly(); this.connectionPassword.setString(connectionPassword); } @@ -876,7 +857,6 @@ } public void setConnectionURL(String connectionURL) { - assertNotReadOnly(); this.connectionURL.setString(connectionURL); } @@ -885,7 +865,6 @@ } public void setConnectionDriverName(String driverName) { - assertNotReadOnly(); this.connectionDriverName.setString(driverName); } @@ -894,7 +873,6 @@ } public void setConnectionProperties(String connectionProperties) { - assertNotReadOnly(); this.connectionProperties.setString(connectionProperties); } @@ -904,7 +882,6 @@ public void setConnectionFactoryProperties( String connectionFactoryProperties) { - assertNotReadOnly(); this.connectionFactoryProperties.setString(connectionFactoryProperties); } @@ -917,7 +894,6 @@ } public void setConnectionFactoryMode(String mode) { - assertNotReadOnly(); connectionFactoryMode.setString(mode); } @@ -926,12 +902,10 @@ } public void setConnectionFactoryModeManaged(boolean managed) { - assertNotReadOnly(); connectionFactoryMode.set(managed); } public void setConnectionFactoryName(String connectionFactoryName) { - assertNotReadOnly(); this.connectionFactoryName.setString(connectionFactoryName); } @@ -940,7 +914,6 @@ } public void setConnectionFactory(Object factory) { - assertNotReadOnly(); connectionFactory.set(factory); } @@ -962,7 +935,6 @@ } public void setConnection2UserName(String connection2UserName) { - assertNotReadOnly(); this.connection2UserName.setString(connection2UserName); } @@ -971,7 +943,6 @@ } public void setConnection2Password(String connection2Password) { - assertNotReadOnly(); this.connection2Password.setString(connection2Password); } @@ -980,7 +951,6 @@ } public void setConnection2URL(String connection2URL) { - assertNotReadOnly(); this.connection2URL.setString(connection2URL); } @@ -989,7 +959,6 @@ } public void setConnection2DriverName(String driverName) { - assertNotReadOnly(); this.connection2DriverName.setString(driverName); } @@ -998,7 +967,6 @@ } public void setConnection2Properties(String connection2Properties) { - assertNotReadOnly(); this.connection2Properties.setString(connection2Properties); } @@ -1008,7 +976,6 @@ public void setConnectionFactory2Properties( String connectionFactory2Properties) { - assertNotReadOnly(); this.connectionFactory2Properties .setString(connectionFactory2Properties); } @@ -1018,7 +985,6 @@ } public void setConnectionFactory2Name(String connectionFactory2Name) { - assertNotReadOnly(); this.connectionFactory2Name.setString(connectionFactory2Name); } @@ -1027,7 +993,6 @@ } public void setConnectionFactory2(Object factory) { - assertNotReadOnly(); connectionFactory2.set(factory); } @@ -1039,7 +1004,6 @@ } public void setOptimistic(boolean optimistic) { - assertNotReadOnly(); this.optimistic.set(optimistic); } @@ -1053,7 +1017,6 @@ } public void setAutoClear(String clear) { - assertNotReadOnly(); autoClear.setString(clear); } @@ -1062,7 +1025,6 @@ } public void setAutoClear(int clear) { - assertNotReadOnly(); autoClear.set(clear); } @@ -1071,7 +1033,6 @@ } public void setRetainState(boolean retainState) { - assertNotReadOnly(); this.retainState.set(retainState); } @@ -1085,7 +1046,6 @@ } public void setRestoreState(String restoreState) { - assertNotReadOnly(); this.restoreState.setString(restoreState); } @@ -1094,7 +1054,6 @@ } public void setRestoreState(int restoreState) { - assertNotReadOnly(); this.restoreState.set(restoreState); } @@ -1103,7 +1062,6 @@ } public void setAutoDetach(String autoDetach) { - assertNotReadOnly(); this.autoDetach.setString(autoDetach); } @@ -1120,7 +1078,6 @@ } public void setDetachState(String detachState) { - assertNotReadOnly(); detachStatePlugin.setString(detachState); } @@ -1129,7 +1086,6 @@ } public void setDetachState(DetachOptions detachState) { - assertNotReadOnly(); detachStatePlugin.set(detachState); } @@ -1140,7 +1096,6 @@ } public void setIgnoreChanges(boolean ignoreChanges) { - assertNotReadOnly(); this.ignoreChanges.set(ignoreChanges); } @@ -1154,7 +1109,6 @@ } public void setNontransactionalRead(boolean nontransactionalRead) { - assertNotReadOnly(); this.nontransactionalRead.set(nontransactionalRead); } @@ -1168,7 +1122,6 @@ } public void setNontransactionalWrite(boolean nontransactionalWrite) { - assertNotReadOnly(); this.nontransactionalWrite.set(nontransactionalWrite); } @@ -1182,7 +1135,6 @@ } public void setMultithreaded(boolean multithreaded) { - assertNotReadOnly(); this.multithreaded.set(multithreaded); } @@ -1196,7 +1148,6 @@ } public void setFetchBatchSize(int fetchBatchSize) { - assertNotReadOnly(); this.fetchBatchSize.set(fetchBatchSize); } @@ -1210,7 +1161,6 @@ } public void setMaxFetchDepth(int maxFetchDepth) { - assertNotReadOnly(); this.maxFetchDepth.set(maxFetchDepth); } @@ -1224,7 +1174,6 @@ } public void setFetchGroups(String fetchGroups) { - assertNotReadOnly(); this.fetchGroups.setString(fetchGroups); } @@ -1241,7 +1190,6 @@ } public void setFlushBeforeQueries(String flush) { - assertNotReadOnly(); flushBeforeQueries.setString(flush); } @@ -1250,7 +1198,6 @@ } public void setFlushBeforeQueries(int flush) { - assertNotReadOnly(); flushBeforeQueries.set(flush); } @@ -1259,7 +1206,6 @@ } public void setLockTimeout(int timeout) { - assertNotReadOnly(); lockTimeout.set(timeout); } @@ -1273,7 +1219,6 @@ } public void setReadLockLevel(String level) { - assertNotReadOnly(); readLockLevel.setString(level); } @@ -1282,7 +1227,6 @@ } public void setReadLockLevel(int level) { - assertNotReadOnly(); readLockLevel.set(level); } @@ -1291,7 +1235,6 @@ } public void setWriteLockLevel(String level) { - assertNotReadOnly(); writeLockLevel.setString(level); } @@ -1300,7 +1243,6 @@ } public void setWriteLockLevel(int level) { - assertNotReadOnly(); writeLockLevel.set(level); } @@ -1309,7 +1251,6 @@ } public void setSequence(String sequence) { - assertNotReadOnly(); seqPlugin.setString(sequence); } @@ -1318,7 +1259,6 @@ } public void setSequence(Seq seq) { - assertNotReadOnly(); seqPlugin.set(seq); } @@ -1329,7 +1269,6 @@ } public void setConnectionRetainMode(String connectionRetainMode) { - assertNotReadOnly(); this.connectionRetainMode.setString(connectionRetainMode); } @@ -1338,7 +1277,6 @@ } public void setConnectionRetainMode(int connectionRetainMode) { - assertNotReadOnly(); this.connectionRetainMode.set(connectionRetainMode); } @@ -1347,7 +1285,6 @@ } public void setFilterListeners(String filterListeners) { - assertNotReadOnly(); filterListenerPlugins.setString(filterListeners); } @@ -1356,7 +1293,6 @@ } public void setFilterListeners(FilterListener[] listeners) { - assertNotReadOnly(); filterListenerPlugins.set(listeners); } @@ -1367,7 +1303,6 @@ } public void setAggregateListeners(String aggregateListeners) { - assertNotReadOnly(); aggregateListenerPlugins.setString(aggregateListeners); } @@ -1376,7 +1311,6 @@ } public void setAggregateListeners(AggregateListener[] listeners) { - assertNotReadOnly(); aggregateListenerPlugins.set(listeners); } @@ -1387,7 +1321,6 @@ } public void setRetryClassRegistration(boolean retry) { - assertNotReadOnly(); retryClassRegistration.set(retry); } @@ -1445,7 +1378,6 @@ } public void setRuntimeUnenhancedClasses(int mode) { - assertNotReadOnly(); runtimeUnenhancedClasses.set(mode); } @@ -1482,9 +1414,5 @@ public Log getConfigurationLog() { return getLog(LOG_RUNTIME); - } - - public Value[] getDynamicValues() { - return new Value[] { dataCacheTimeout, fetchBatchSize, lockTimeout }; } } Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java (original) +++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java Thu Aug 30 13:19:44 2007 @@ -43,6 +43,7 @@ import org.apache.openjpa.enhance.PersistenceCapable; import org.apache.openjpa.event.RemoteCommitEventManager; import org.apache.openjpa.event.BrokerFactoryEvent; +import org.apache.openjpa.lib.conf.Configuration; import org.apache.openjpa.lib.log.Log; import org.apache.openjpa.lib.util.J2DoPrivHelper; import org.apache.openjpa.lib.util.Localizer; @@ -197,7 +198,7 @@ loadPersistentTypes(broker.getClassLoader()); } _brokers.add(broker); - + _conf.setReadOnly(Configuration.INIT_STATE_FROZEN); return broker; } catch (OpenJPAException ke) { throw ke; @@ -632,7 +633,7 @@ // freeze underlying configuration and eagerly initialize to // avoid synchronization - _conf.setReadOnly(true); + _conf.setReadOnly(Configuration.INIT_STATE_FREEZING); _conf.instantiateAll(); // fire an event for all the broker factory listeners Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java (original) +++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/BooleanValue.java Thu Aug 30 13:19:44 2007 @@ -26,7 +26,7 @@ public class BooleanValue extends Value { private boolean value; - + public BooleanValue(String prop) { super(prop); setAliasListComprehensive(true); @@ -40,6 +40,7 @@ * The internal value. */ public void set(boolean value) { + assertChangeable(); boolean oldValue = this.value; this.value = value; if (oldValue != value) Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java (original) +++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configuration.java Thu Aug 30 13:19:44 2007 @@ -74,6 +74,11 @@ * the property's name in XML format (i.e. two-words instead of TwoWords). */ public static final String ATTRIBUTE_XML = "xmlName"; + + public static final int INIT_STATE_LIQUID = 0; + public static final int INIT_STATE_FREEZING = 1; + public static final int INIT_STATE_FROZEN = 2; + /** * Return the product name. Defaults to openjpa. @@ -200,7 +205,7 @@ * Lock down the configuration's state. Attempting to set state on a * read-only configuration results in an exception. */ - public void setReadOnly(boolean readOnly); + public void setReadOnly(int readOnly); /** * Return true if this configuration is immutable. @@ -230,21 +235,21 @@ * * @since 1.0.0 */ - public void modifyDynamic(String property, Object newValue); - - /** - * Affirms if the given property can be modified dynamically i.e. - * even after the receiver is {@link #setReadOnly(boolean) frozen}. - * - * @since 1.0.0 - */ - public boolean isDynamic(String property); - - /** - * Gets the values that can be modified dynamically i.e. - * even after the receiver is {@link #setReadOnly(boolean) frozen}. - * - * @since 1.0.0 - */ - public Value[] getDynamicValues(); +// public void modifyDynamic(String property, Object newValue); +// +// /** +// * Affirms if the given property can be modified dynamically i.e. +// * even after the receiver is {@link #setReadOnly(boolean) frozen}. +// * +// * @since 1.0.0 +// */ +// public boolean isDynamic(String property); +// +// /** +// * Gets the values that can be modified dynamically i.e. +// * even after the receiver is {@link #setReadOnly(boolean) frozen}. +// * +// * @since 1.0.0 +// */ +// public Value[] getDynamicValues(); } Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java (original) +++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java Thu Aug 30 13:19:44 2007 @@ -111,7 +111,7 @@ public StringValue id; private String _product = null; - private boolean _readOnly = false; + private int _readOnlyState = INIT_STATE_LIQUID; private Map _props = null; private boolean _globals = false; private String _auto = null; @@ -208,7 +208,6 @@ } public void setLogFactory(LogFactory logFactory) { - assertNotReadOnly(); logFactoryPlugin.set(logFactory); } @@ -217,7 +216,6 @@ } public void setLog(String log) { - assertNotReadOnly(); logFactoryPlugin.setString(log); } @@ -230,7 +228,6 @@ } public void setId(String id) { - assertNotReadOnly(); this.id.set(id); } @@ -260,8 +257,10 @@ return null; } - public void setReadOnly(boolean readOnly) { - _readOnly = readOnly; + public void setReadOnly(int newState) { + if (newState >= _readOnlyState) { + _readOnlyState = newState; + } } public void instantiateAll() { @@ -305,7 +304,7 @@ } public boolean isReadOnly() { - return _readOnly; + return _readOnlyState==INIT_STATE_FROZEN; } public void addPropertyChangeListener(PropertyChangeListener listener) { @@ -611,7 +610,8 @@ public void fromProperties(Map map) { if (map == null || map.isEmpty()) return; - assertNotReadOnly(); + if (isReadOnly()) + throw new IllegalStateException(_loc.get("read-only").getMessage()); // if the only previous call was to load defaults, forget them. // this way we preserve the original formatting of the user's props @@ -778,16 +778,6 @@ ///////////// /** - * Checks if the configuration is read only and if so throws an - * exception, otherwise returns silently. - * Implementations should call this method before setting any state. - */ - public void assertNotReadOnly() { - if (isReadOnly()) - throw new IllegalStateException(_loc.get("read-only").getMessage()); - } - - /** * Performs an equality check based on the properties returned from * {@link #toProperties}. */ @@ -989,33 +979,14 @@ return val; } - public void modifyDynamic(String property, Object newValue) { - if (!isDynamic(property)) - throw new RuntimeException(_loc.get("not-dynamic", property) - .toString()); - Value value = getValue(property); - value.setObject(newValue); - } - - public boolean isDynamic(String property) { - Value[] dynamicValues = getDynamicValues(); - for (int i=0; imust invoke this method before changing its + * internal state. + * + * This receiver can not be changed if all of the following is true + *
  • this receiver is not dynamic + *
  • ValueListener attached to this receiver is a Configuration + *
  • Configuration is read-only + */ + protected void assertChangeable() { + if (!isDynamic() && listen instanceof Configuration && + ((Configuration)listen).isReadOnly()) { + throw new RuntimeException(s_loc.get("veto-change", + this.getProperty()).toString()); + } + } + + /** + * Sets if this receiver can be mutated even when the configuration it + * belongs to has been {@link Configuration#isReadOnly() frozen}. + * + */ + public void setDynamic(boolean flag) { + isDynamic = flag; + } + + /** + * Affirms if this receiver can be mutated even when the configuration it + * belongs to has been {@link Configuration#isReadOnly() frozen}. + * + */ + public boolean isDynamic() { + return isDynamic; } public int hashCode() { Modified: openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties (original) +++ openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/conf/localizer.properties Thu Aug 30 13:19:44 2007 @@ -111,4 +111,5 @@ Id-displayorder: 50 Id-expert: true -not-dynamic: Can not modify "{0}" to "{1}" because the property is not dynamic. +veto-change: Can not modify "{0}" because the property is not dynamic and the \ + current configuration is read-only. Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java (original) +++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/conf/test/TestConfigurationImpl.java Thu Aug 30 13:19:44 2007 @@ -196,7 +196,7 @@ */ public void testFreezing() { assertTrue(!_conf.isReadOnly()); - _conf.setReadOnly(true); + _conf.setReadOnly(Configuration.INIT_STATE_FROZEN); assertTrue(_conf.isReadOnly()); try { _conf.setTestKey("bar"); @@ -276,7 +276,6 @@ } public void setTestKey(String val) { - assertNotReadOnly(); _testKey.set(val); } @@ -285,8 +284,7 @@ } public void setSysKey(String val) { - assertNotReadOnly(); - _sysKey.set(val); + _sysKey.set(val); } public String getPluginKey() { @@ -294,7 +292,6 @@ } public void setPluginKey(String val) { - assertNotReadOnly(); _pluginKey.setString(val); } @@ -305,7 +302,6 @@ } public void setPluginKey(Object val) { - assertNotReadOnly(); _pluginKey.set(val); } @@ -314,7 +310,6 @@ } public void setObjectKey(Object val) { - assertNotReadOnly(); _objectKey.set(val); } Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestDynamicConfiguration.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestDynamicConfiguration.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestDynamicConfiguration.java (original) +++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestDynamicConfiguration.java Thu Aug 30 13:19:44 2007 @@ -55,44 +55,40 @@ assertTrue(conf.isReadOnly()); } - public void testDynamicValuesCanNotBeChangedDirectly() { + public void testNonDynamicValuesCanNotBeChanged() { emf.createEntityManager(); OpenJPAConfiguration conf = emf.getConfiguration(); - Value[] dynamicValues = conf.getDynamicValues(); - assertTrue(dynamicValues.length>0); - assertTrue(conf.isDynamic("LockTimeout")); - - int oldValue = conf.getLockTimeout(); - int newValue = oldValue + 10; + String oldValue = conf.getConnectionURL(); + String newValue = "jdbc://mydb:8087/DBDoesNotExist"; try { - conf.setLockTimeout(newValue); - fail("Expected exception to modify configuration directly"); + conf.setConnectionURL(newValue); + fail("Expected exception to modify configuration"); } catch (Exception ex) { // good - assertEquals(oldValue, conf.getLockTimeout()); + assertEquals(oldValue, conf.getConnectionURL()); } } public void testDynamicValuesCanBeChanged() { OpenJPAConfiguration conf = emf.getConfiguration(); - Value[] dynamicValues = conf.getDynamicValues(); - assertTrue(dynamicValues.length>0); - assertTrue(conf.isDynamic("LockTimeout")); - int oldValue = conf.getLockTimeout(); int newValue = oldValue + 10; - conf.modifyDynamic("LockTimeout", newValue); + conf.setLockTimeout(newValue); assertEquals(newValue, conf.getLockTimeout()); } public void testDynamicValuesAreCorrectlySet() { OpenJPAConfiguration conf = emf.getConfiguration(); - Value[] dynamicValues = conf.getDynamicValues(); - assertTrue(dynamicValues.length>0); - assertTrue(conf.isDynamic("LockTimeout")); + Value lockTimeoutValue = conf.getValue("LockTimeout"); + assertNotNull(lockTimeoutValue); + assertTrue(lockTimeoutValue.isDynamic()); + + Value connectionURLValue = conf.getValue("ConnectionURL"); + assertNotNull(connectionURLValue); + assertFalse(connectionURLValue.isDynamic()); } public void testDynamicChangeDoesNotChangeHashCode() { @@ -101,7 +97,7 @@ int oldValue = conf1.getLockTimeout(); int newValue = oldValue+10; int oldHash = conf1.hashCode(); - conf1.modifyDynamic("LockTimeout", newValue); + conf1.setLockTimeout(newValue); int newHash = conf1.hashCode(); assertEquals(oldHash, newHash); Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java?rev=571294&r1=571293&r2=571294&view=diff ============================================================================== --- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java (original) +++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java Thu Aug 30 13:19:44 2007 @@ -33,6 +33,7 @@ import org.apache.openjpa.enhance.PCClassFileTransformer; import org.apache.openjpa.kernel.Bootstrap; import org.apache.openjpa.kernel.BrokerFactory; +import org.apache.openjpa.lib.conf.Configuration; import org.apache.openjpa.lib.conf.ConfigurationProvider; import org.apache.openjpa.lib.conf.Configurations; import org.apache.openjpa.lib.log.Log; @@ -162,7 +163,7 @@ return tmpLoader; } }); - conf.setReadOnly(true); + conf.setReadOnly(Configuration.INIT_STATE_FREEZING); MetaDataRepository repos = conf.getMetaDataRepositoryInstance(); repos.setResolve(MetaDataModes.MODE_MAPPING, false);