/**********************************************************************
Copyright (c) 2004 Erik Bengtson and others. All rights reserved.
Licensed 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.
Contributors:
2004 Andy Jefferson - added description of addition process.
2004 Andy Jefferson - added constructor, and try-catch on initialisation
2006 Andy Jefferson - renamed to PersistenceConfiguration so that it is API agnostic
...
**********************************************************************/
package org.jpox;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TimeZone;
import javax.jdo.JDOUserException;
import org.jpox.exceptions.JPOXUserException;
import org.jpox.metadata.TransactionType;
import org.jpox.plugin.PluginRegistry;
import org.jpox.store.AutoStartMechanism;
import org.jpox.transaction.TransactionUtils;
import org.jpox.util.JPOXLogger;
import org.jpox.util.Localiser;
import org.jpox.util.StringUtils;
/**
* Class providing configuration for persistence.
* Can be extended by PersistenceManagerFactory/EntityManagerFactory to provide their own additions if required.
* All properties should have setter/getter, and should have a "PropertySetter"
* to allow loading of the property from the persistence factory Properties.
*
* @version $Revision: 1.52 $
*/
public abstract class PersistenceConfiguration
{
/** Localisation of messages. */
protected static final Localiser LOCALISER = Localiser.getInstance("org.jpox.Localisation",
ObjectManager.class.getClassLoader());
// ------------------------------ JDO standard properties ---------------------------------
/** JDO PMF class property. */
public static final String JDO_PMF_CLASS_PROPERTY = "javax.jdo.PersistenceManagerFactoryClass";
/** Datastore driver name property. */
public static final String JDO_DATASTORE_DRIVERNAME_PROPERTY = "javax.jdo.option.ConnectionDriverName";
/** Datastore URL property. */
public static final String JDO_DATASTORE_URL_PROPERTY = "javax.jdo.option.ConnectionURL";
/** Datastore connection username property. */
public static final String JDO_DATASTORE_USERNAME_PROPERTY = "javax.jdo.option.ConnectionUserName";
/** Datastore connection password property. */
public static final String JDO_DATASTORE_PASSWORD_PROPERTY = "javax.jdo.option.ConnectionPassword";
/** Datastore connection factory name property. */
public static final String JDO_CONNECTION_FACTORY_NAME_PROPERTY = "javax.jdo.option.ConnectionFactoryName";
/** Datastore connection factory 2 name property. */
public static final String JDO_CONNECTION_FACTORY2_NAME_PROPERTY = "javax.jdo.option.ConnectionFactory2Name";
/** Datastore connection factory property. */
public static final String JDO_CONNECTION_FACTORY_PROPERTY = "javax.jdo.option.ConnectionFactory";
/** Datastore connection factory 2 property. */
public static final String JDO_CONNECTION_FACTORY2_PROPERTY = "javax.jdo.option.ConnectionFactory2";
/** Ignore Cache property. */
public static final String JDO_IGNORECACHE_PROPERTY = "javax.jdo.option.IgnoreCache";
/** Optimistic transaction property. */
public static final String JDO_OPTIMISTIC_PROPERTY = "javax.jdo.option.Optimistic";
/** Multithreaded property. */
public static final String JDO_MULTITHREADED_PROPERTY = "javax.jdo.option.Multithreaded";
/** Retain values property. */
public static final String JDO_RETAINVALUES_PROPERTY = "javax.jdo.option.RetainValues";
/** Restore values property. */
public static final String JDO_RESTOREVALUES_PROPERTY = "javax.jdo.option.RestoreValues";
/** Non-transactional Read property. */
public static final String JDO_NONTRANSACTIONAL_READ_PROPERTY = "javax.jdo.option.NontransactionalRead";
/** Non-transactional Write property. */
public static final String JDO_NONTRANSACTIONAL_WRITE_PROPERTY = "javax.jdo.option.NontransactionalWrite";
/** Mapping suffix property. */
public static final String JDO_MAPPING_PROPERTY = "javax.jdo.option.Mapping";
/** Catalog name property. */
public static final String JDO_MAPPING_CATALOG_PROPERTY = "javax.jdo.mapping.Catalog";
/** Schema name property. */
public static final String JDO_MAPPING_SCHEMA_PROPERTY = "javax.jdo.mapping.Schema";
/** Detach-all-on-commit property */
public static final String JDO_DETACHALLONCOMMIT_PROPERTY = "javax.jdo.option.DetachAllOnCommit";
/** Copy-on-attach property */
public static final String JDO_COPYONATTACH_PROPERTY = "javax.jdo.option.CopyOnAttach";
/** JDO Transaction type property. */
public static final String JDO_TRANSACTION_TYPE_PROPERTY = "javax.jdo.option.TransactionType";
/** Property representing the name of the persistence factory. */
public static final String JDO_NAME_PROPERTY = "javax.jdo.option.Name";
/** "persistence-unit" name property. */
public static final String JDO_PERSISTENCE_UNIT_NAME_PROPERTY = "javax.jdo.option.PersistenceUnitName";
/** Server timezone "id". */
public static final String JDO_SERVER_TIMEZONE_ID_PROPERTY = "javax.jdo.option.ServerTimeZoneID";
// ------------------------------ JPA standard properties ---------------------------------
/** JPA Transaction type property. */
public static final String JPA_TRANSACTION_TYPE_PROPERTY = "javax.persistence.TransactionType";
/** JPA persistence provider property. */
public static final String JPA_PERSISTENCE_PROVIDER_PROPERTY = "javax.persistence.provider";
/** Name of property to use to define if we should support 1-N uni FK relations. */
public static final String JPA_ONE_TO_MANY_UNI_FK_PROPERTY = "org.jpox.jpa.oneToManyUniFkRelations";
// ------------------------------ JPOX extension properties ---------------------------------
/** Property defining whether to include codes in messages. */
public static final String MESSAGES_INCLUDE_CODES_PROPERTY = "org.jpox.messageCodesIncluded";
/** Property defining the StoreManager to use. Only used when we dont have a datastore URL. */
public static final String STORE_MANAGER_TYPE = "org.jpox.storeManagerType";
/** Property defining whether to register MBeans for use as part of a managed runtime system. */
public static final String MANAGED_RUNTIME_PROPERTY = "org.jpox.managedRuntime";
/** The API name to use for persistence. Defaults to JDO, but can also be JPA. */
public static final String PERSISTENCE_API_NAME = "org.jpox.persistenceApiName";
/** ClassLoaderResolver name property. */
public static final String CLASS_LOADER_RESOLVER_NAME_PROPERTY = "org.jpox.classLoaderResolverName";
/** Implementation Creator name property. */
public static final String IMPLEMENTATION_CREATOR_NAME_PROPERTY = "org.jpox.implementationCreatorName";
/** datastore-identity class name property. */
public static final String DATASTORE_IDENTITY_CLASS_NAME_PROPERTY = "org.jpox.datastoreIdentityClassName";
/** Property for whether to manage relationships. */
public static final String MANAGE_RELATIONSHIPS_PROPERTY = "org.jpox.manageRelationships";
/** Property for whether to check managed relationships. */
public static final String MANAGE_RELATIONSHIPS_CHECKS_PROPERTY = "org.jpox.manageRelationshipsChecks";
/** Detach-on-close property. */
public static final String DETACH_ON_CLOSE_PROPERTY = "org.jpox.DetachOnClose";
/** Property defining if attach operations should assume that detached objects are from the same datastore. */
public static final String ATTACH_SAME_DATASTORE_PROPERTY = "org.jpox.attachSameDatastore";
/** Property for whether to check inheritance on findObject requests. */
public static final String FIND_OBJECT_CHECK_INHERITANCE_PROPERTY = "org.jpox.findObjectCheckInheritance";
/** Property defining the classname of the datastore adapter to use. */
public static final String DATASTORE_ADAPTER_CLASSNAME_PROPERTY = "org.jpox.datastoreAdapterClassName";
/** Property for whether to validate the tables upon loading. */
public static final String VALIDATE_TABLES_PROPERTY = "org.jpox.validateTables";
/** Property for whether to validate the columns upon loading. */
public static final String VALIDATE_COLUMNS_PROPERTY = "org.jpox.validateColumns";
/** Property for whether the validate the constraints upon loading */
public static final String VALIDATE_CONSTRAINTS_PROPERTY = "org.jpox.validateConstraints";
/** Property for whether to warn only when receiving an error on auto creation. */
public static final String AUTO_CREATE_WARN_ON_ERROR_PROPERTY = "org.jpox.autoCreateWarnOnError";
/** Property for whether to auto create the schema upon loading. */
public static final String AUTO_CREATE_SCHEMA_PROPERTY = "org.jpox.autoCreateSchema";
/** Property for whether to auto create the tables upon loading. */
public static final String AUTO_CREATE_TABLES_PROPERTY = "org.jpox.autoCreateTables";
/** Property for whether to auto create the columns upon loading. */
public static final String AUTO_CREATE_COLUMNS_PROPERTY = "org.jpox.autoCreateColumns";
/** The system property that selects the default value for the AutoCreateConstraints setting. */
public static final String AUTO_CREATE_CONSTRAINTS_PROPERTY = "org.jpox.autoCreateConstraints";
/** Whether the datastore schema is read-only and so writes should not be performed. */
public static final String READ_ONLY_DATASTORE_PROPERTY = "org.jpox.readOnlyDatastore";
/** What should happen when using a read-only datastore and an update is attempted. */
public static final String READ_ONLY_DATASTORE_ACTION_PROPERTY = "org.jpox.readOnlyDatastoreAction";
/** Whether the datastore schema is read-only and so writes should not be performed. */
public static final String FIXED_DATASTORE_PROPERTY = "org.jpox.fixedDatastore";
/** The system property that defines the process for deletions. */
public static final String DELETION_POLICY_PROPERTY = "org.jpox.deletionPolicy";
/** Property defining the default strategy for inheritance, allowing change of behaviour from JDO2. */
public static final String DEFAULT_INHERITANCE_STRATEGY_PROPERTY = "org.jpox.defaultInheritanceStrategy";
/** Property defining the transaction isolation mode to use. */
public static final String TRANSACTION_ISOLATION_PROPERTY = "org.jpox.transactionIsolation";
/** Property defining the JTA locator to use. */
public static final String JTA_LOCATOR_PROPERTY = "org.jpox.jtaLocator";
/** Property defining the JTA JNDI location to use (if known). */
public static final String JTA_JNDI_LOCATION_PROPERTY = "org.jpox.jtaJndiLocation";
/** Property defining if we should delay operations til commit/flush with datastore txns. */
public static final String DATASTORE_TXN_DELAY_OPERATIONS_PROPERTY = "org.jpox.datastoreTransactionDelayOperations";
/** Property defining the limit on number of dirty objects before flush occurs with datastore txns. */
public static final String DATASTORE_TXN_FLUSH_LIMIT_PROPERTY = "org.jpox.datastoreTransactionFlushLimit";
/** Property defining the transaction isolation to use when obtaining POIDs. */
public static final String POID_TRANSACTION_ISOLATION_PROPERTY = "org.jpox.poid.transactionIsolation";
/** Property defining how to obtain a datastore connection when generating POIDs */
public static final String POID_TRANSACTION_ATTRIBUTE_PROPERTY = "org.jpox.poid.transactionAttribute";
/** Property defining the auto-start mechanism to use (if any). */
public static final String AUTO_START_MECHANISM_PROPERTY = "org.jpox.autoStartMechanism";
/** Property defining the mode of operation of any auto-start mechanism. */
public static final String AUTO_START_MECHANISM_MODE_PROPERTY = "org.jpox.autoStartMechanismMode";
/** Property defining the name of the file used when using the XML AutoStartMechanism. */
public static final String AUTO_START_MECHANISM_XML_FILE_PROPERTY = "org.jpox.autoStartMechanismXmlFile";
/** Property defining the names of the classes whose MetaData is to be loaded at startup. */
public static final String AUTO_START_CLASS_NAMES_PROPERTY = "org.jpox.autoStartClassNames";
/** Property defining whether PBR is run at commit time (JDO default is true). */
public static final String PERSISTENCE_BY_REACHABILITY_AT_COMMIT = "org.jpox.persistenceByReachabilityAtCommit";
/** Property defining the maximum fetch depth to use by default. */
public static final String MAX_FETCH_DEPTH_PROPERTY = "org.jpox.maxFetchDepth";
/** Property defining the identifier factory to use. */
public static final String IDENTIFIER_FACTORY_PROPERTY = "org.jpox.identifierFactory";
/** Property defining the identifier case to be used. */
public static final String IDENTIFIER_CASE_PROPERTY = "org.jpox.identifier.case";
/** Property defining the word separator for use in identifiers (if supported by the factory). */
public static final String IDENTIFIER_WORD_SEPARATOR_PROPERTY = "org.jpox.identifier.wordSeparator";
/** Property defining the table prefix for use in identifiers (if supported by the factory). */
public static final String IDENTIFIER_TABLE_PREFIX_PROPERTY = "org.jpox.identifier.tablePrefix";
/** Property defining the table suffix for use in identifiers (if supported by the factory). */
public static final String IDENTIFIER_TABLE_SUFFIX_PROPERTY = "org.jpox.identifier.tableSuffix";
/** Property defining a file that contains properties that will be loaded by JPOX. */
public static final String PROPERTIES_FILE = "org.jpox.propertiesFile";
/** Property defining how to pool connections. */
public static final String CONNECTION_POOLING_TYPE_PROPERTY = "org.jpox.connectionPoolingType";
/** Property defining the configuration file for connection pooling. */
public static final String CONNECTION_POOLING_CONFIGURATION_FILE_PROPERTY = "org.jpox.connectionPoolingConfigurationFile";
/** Property defining the type of Level 1 Cache to use. */
public static final String CACHE_LEVEL_1_TYPE_PROPERTY = "org.jpox.cache.level1.type";
/** Property defining whether to use a Level 2 Cache. */
public static final String CACHE_LEVEL_2_PROPERTY = "org.jpox.cache.level2";
/** Property defining the type of Level 2 Cache to use. */
public static final String CACHE_LEVEL_2_TYPE_PROPERTY = "org.jpox.cache.level2.type";
/** Property defining the symbolic name of the cache to use for Level 2. */
public static final String CACHE_LEVEL_2_CACHE_NAME_PROPERTY = "org.jpox.cache.level2.cacheName";
/** Property defining the configuration file of the cache to use for Level 2. */
public static final String CACHE_LEVEL_2_CONFIGURATION_FILE_PROPERTY = "org.jpox.cache.level2.configurationFile";
/** Property defining whether to cache collections. */
public static final String CACHE_COLLECTIONS_PROPERTY = "org.jpox.cache.collections";
/** Property defining whether to lazy load collections (when cached). */
public static final String CACHE_COLLECTIONS_LAZY_PROPERTY = "org.jpox.cache.collections.lazy";
/** Property defining whether to validate the metadata files.*/
public static final String METADATA_VALIDATE_PROPERTY = "org.jpox.metadata.validate";
/** Property defining the file extension for the JDO metadata files. */
public static final String METADATA_JDO_FILE_EXTENSION_PROPERTY = "org.jpox.metadata.jdoFileExtension";
/** Property defining the file extension for the ORM metadata files. */
public static final String METADATA_ORM_FILE_EXTENSION_PROPERTY = "org.jpox.metadata.ormFileExtension";
/** Property defining the file extension for the JDO Query metadata files.*/
public static final String METADATA_JDOQUERY_FILE_EXTENSION_PROPERTY = "org.jpox.metadata.jdoqueryFileExtension";
/** Property defining the name of the class that will manage annoations. */
public static final String METADATA_ANNOTATIONS_MANAGER_PROPERTY = "org.jpox.metadata.annotationManager";
/** Plugin registry class name */
public static final String PLUGIN_REGISTRY_CLASS_NAME = "org.jpox.plugin.pluginRegistryClassName";
/** Plugin registry bundle check */
public static final String PLUGIN_REGISTRY_BUNDLE_CHECK = "org.jpox.plugin.pluginRegistryBundleCheck";
/** Property defining whether to flush all changes before executing the query. */
public static final String QUERY_FLUSH_BEFORE_EXECUTION_PROPERTY = "org.jpox.query.flushBeforeExecution";
/** Property defining whether to use the FetchPlan when executing the query. */
public static final String QUERY_USE_FETCH_PLAN_PROPERTY = "org.jpox.query.useFetchPlan";
/** Property defining the timeout (seconds) for any queries. */
public static final String QUERY_TIMEOUT_PROPERTY = "org.jpox.query.timeout";
/** Property defining the direction in which a result set will be navigated. */
public static final String QUERY_FETCH_DIRECTION_PROPERTY = "org.jpox.rdbms.query.fetchDirection";
/** Property for allow/disallow all SQL statements. */
public static final String QUERY_ALLOW_ALL_SQL_STATEMENTS = "org.jpox.rdbms.sql.allowAllSQLStatements";
/** Property for how many times to retry the addition of a class to the store management. */
public static final String DATASTORE_CLASS_ADDITION_MAX_RETRIES_PROPERTY = "org.jpox.rdbms.classAdditionMaxRetries";
/** Property for name of the registered connection provider. */
public static final String CONNECTION_PROVIDER_NAME_PROPERTY = "org.jpox.store.connectionProvider.Name";
/** Property for failOnError setting. */
public static final String CONNECTION_PROVIDER_FAILONERROR_PROPERTY = "org.jpox.store.connectionProvider.FailOnError";
/** Property for a primary ClassLoader setting. */
public static final String PRIMARY_CLASS_LOADER_PROPERTY = "org.jpox.primaryClassLoader";
/** Property defining the resource type for the connection. */
public static final String CONNECTION_RESOURCE_TYPE = "org.jpox.connection.resourceType";
/** Property defining the resource type for the connection 2. */
public static final String CONNECTION2_RESOURCE_TYPE = "org.jpox.connection2.resourceType";
// ----------------------------------- RDBMS-specific properties --------------------------------------------
/** Property defining the type of joins to use on a query/queries. */
public static final String QUERY_JOIN_TYPE_PROPERTY = "org.jpox.rdbms.jdoql.joinType";
/** Property defining the whether to apply constraints to the exists clause. */
public static final String QUERY_EXISTS_INCLUDES_PROPERTY = "org.jpox.rdbms.jdoql.existsIncludesConstraints";
/** Property defining the whether to use EXISTS with contains clause. */
public static final String QUERY_CONTAINS_EXISTS_ALWAYS_PROPERTY = "org.jpox.rdbms.query.containsUsesExistsAlways";
/** Property defining the type of result set to create (RDBMS datastores). */
public static final String QUERY_RESULT_SET_TYPE_PROPERTY = "org.jpox.rdbms.query.resultSetType";
/** Property defining the concurrency of the result set (RDBMS datastores). */
public static final String QUERY_RESULT_SET_CONCURRENCY_PROPERTY = "org.jpox.rdbms.query.resultSetConcurrency";
/** Property for the maximum number of statements that can be batched (0 = no batching) RDBMS datastores. */
public static final String STATEMENT_BATCH_LIMIT_PROPERTY = "org.jpox.rdbms.statementBatchLimit";
/** Property defining whether to use "SELECT ... FOR UPDATE" to fetch objects when using READ COMMITTED or lower (RDBMS datastores). */
public static final String USE_UPDATE_LOCK_PROPERTY = "org.jpox.rdbms.useUpdateLock";
/** The system property that defines the mode of creation of RDBMS constraints. */
public static final String RDBMS_CONSTRAINT_CREATE_MODE_PROPERTY = "org.jpox.rdbms.constraintCreateMode";
/** Property defining whether to add unique constraints to the element table for a map inverse field (RDBMS datastores). */
public static final String ADD_UNIQUE_CONSTRAINT_MAP_INVERSE_PROPERTY = "org.jpox.rdbms.uniqueConstraints.mapInverse";
/** Property defining to what level to initialise column info when validating. */
public static final String INITIALIZE_COLUMN_INFO_PROPERTY = "org.jpox.rdbms.initializeColumnInfo";
/** Property for whether to check if the table/view exists. */
public static final String CHECK_EXIST_TABLES_VIEWS_PROPERTY = "org.jpox.rdbms.CheckExistTablesOrViews";
/** Property defining the default string length when storing a String type in the datastore and no length given (RDBMS datastores). */
public static final String STRING_DEFAULT_LENGTH_PROPERTY = "org.jpox.rdbms.stringDefaultLength";
/** Property defining the action when persisting a String too long for the datastore column (RDBMS datastores). */
public static final String STRING_LENGTH_ACTION_PROPERTY = "org.jpox.rdbms.stringLengthExceededAction";
/** Property defining if we should persist an empty string as null in the datastore. */
public static final String PERSIST_EMPTY_STRING_AS_NULL_PROPERTY = "org.jpox.rdbms.persistEmptyStringAsNull";
/** Property defining if we should have a discriminator col per subclass (backwards compatibility only). */
public static final String DISCRIMINATOR_PER_SUBCLASSTABLE_PROPERTY = "org.jpox.rdbms.discriminatorPerSubclassTable";
/** Property defining the sort order for Oracle datastores. */
public static final String ORACLE_SORT_ORDER_PROPERTY = "org.jpox.rdbms.oracleNlsSortOrder";
// ----------------------------------- DB4O-specific properties --------------------------------------------
/** Property defining the DB4O output file. */
public static final String DB4O_OUTPUT_FILE_PROPERTY = "org.jpox.db4o.outputFile";
/** Property defining whether to flush DB4O file buffers on commit. */
public static final String DB4O_FLUSH_BUFFERS_PROPERTY = "org.jpox.db4o.flushFileBuffers";
/** Property defining whether to generate UUIDs for all classes. */
public static final String DB4O_GENERATE_UUIDS_PROPERTY = "org.jpox.db4o.generateUUIDs";
/** Interface allowing setting properties on a persistence factory with String property values. */
protected interface StringPropertySetter
{
/**
* Set this property on the given PersistenceManagerFactoryImpl to the String value.
* @param configuration The PersistenceConfiguration to set the value on.
* @param value The String value to set.
*/
void set(PersistenceConfiguration configuration, String value);
}
/** Interface allowing setting properties on a persistence factory with Object property values. */
protected interface ObjectPropertySetter
{
/**
* Set this property on the given PersistenceManagerFactoryImpl to the Object value.
* @param configuration The PersistenceConfiguration to set the value on.
* @param value The Object value to set.
*/
void set(PersistenceConfiguration configuration, Object value);
}
/** A Map mapping property name to the corresponding PropertySetter. */
private final Map PROPERTY_SETTERS = initPropertySetters();
/** options given when this configuration was constructed */
private Map options;
private Calendar dateTimezoneCalendar = null;
// JDO standard properties
private String driverName = null;
private String url = null;
private String userName = null;
private String password = null;
private Object connectionFactory = null;
private String connectionFactoryName = null;
private Object connectionFactory2 = null;
private String connectionFactory2Name = null;
private boolean multithreaded = false;
private boolean optimistic = false;
private boolean retainValues = false;
private boolean restoreValues = false;
private boolean nontransactionalRead = false;
private boolean nontransactionalWrite = false;
private boolean ignoreCache = false;
private boolean detachAllOnCommit = false;
private boolean copyOnAttach = true;
private String catalogName = null;
private String schemaName = null;
private String mapping = null;
private String transactionType = null;
private Boolean jca = null; //whether running using JCA connector
private String serverTimeZoneID = null;
// JPA properties
private boolean jpaOneToManyUniFkRelations = false;
/** Name of the persistence factory (if any). */
private String name = null;
/** Name of the persistence unit being managed here. */
private String persistenceUnitName = null;
/** Persistence API */
private String persistenceApiName = "JDO";
/** Whether to provide a managed runtime. */
private Boolean managedRuntime = Boolean.FALSE;
/** StoreManager type (jdbc, db4o etc) */
private String storeManagerType = null;
// Query
private boolean queryFlushBeforeExecution = false;
private boolean queryUseFetchPlan = true;
private int queryTimeout = 0;
private String queryFetchDirection = "forward";
private String queryResultSetType = "forward-only";
private String queryResultSetConcurrency = "read-only";
private boolean queryAllowAllSQLStatements = false;
private String queryJoinType = null;
private boolean queryExistsIncludesConstraints = true;
private boolean queryContainsUsesExistsAlways = false;
private String oracleNlsSortOrder = "LATIN";
// Types
private final static int JDO2_STRING_DEFAULT_LENGTH = 256;
private int stringDefaultLength = JDO2_STRING_DEFAULT_LENGTH;
private String stringLengthExceededAction = "EXCEPTION";
private boolean persistEmptyStringAsNull = false;
private boolean discriminatorPerSubclassTable = false;
// Persistence control
private boolean manageRelationships = true;
private boolean manageRelationshipsChecks = true;
private boolean detachOnClose = false;
private boolean findObjectCheckInheritance = true;
private boolean attachSameDatastore = false;
private boolean persistenceByReachabilityAtCommit = true;
private int maxFetchDepth = 1; // JDO2 default is 1
private String classLoaderResolverName = "jdo";
private ClassLoader primaryClassLoader = null;
private String implementationCreatorName = "asm";
private String datastoreIdentityClassName = "jpox";
// Schema
private String datastoreAdapterClassName = null;
private boolean useUpdateLock = false;
private int datastoreClassAdditionMaxRetries = 3;
private boolean uniqueConstraintsMapInverse = true;
private String defaultInheritanceStrategy = "JDO2";
private String identifierFactory = "jpox";
private String identifierCase = "UpperCase";
private String identifierWordSeparator = null;
private String identifierTablePrefix = null;
private String identifierTableSuffix = null;
private boolean readOnlyDatastore = false;
private String readOnlyDatastoreAction = "EXCEPTION";
private boolean fixedDatastore = false;
private String rdbmsConstraintCreateMode = "JPOX";
private String deletionPolicy = "JDO2";
private boolean checkExistTablesOrViews = true;
private boolean validateTables = true;
private boolean validateColumns = true;
private boolean validateConstraints = true;
private boolean autoCreateTables = false;
private boolean autoCreateColumns = false;
private boolean autoCreateConstraints = false;
private boolean autoCreateWarnOnError = false;
private String initializeColumnInfo = "ALL";
private int statementBatchLimit = 50;
// Autostart
private String autoStartMechanism = null; // Let StoreManager decide the default if not specified by user
private String autoStartMechanismXmlFile = "jpoxAutoStart.xml";
private String autoStartMechanismMode = AutoStartMechanism.MODE_QUIET;
private String autoStartClassNames = null;
// Transactions/Connections
private int isolationLevel = UserTransaction.TRANSACTION_READ_COMMITTED;
private String jtaLocator = null;
private String jtaJndiLocation = null;
private int poidIsolationLevel = UserTransaction.TRANSACTION_READ_COMMITTED;
private String poidTransactionAttribute = "New";
private int datastoreTransactionFlushLimit = 1;
private boolean datastoreTransactionDelayOperations = false;
private String connectionPoolingType = "None";
private String connectionPoolingConfigurationFile = null;
// Cache
private boolean cacheCollections = true;
private Boolean cacheCollectionsLazy;
private String cacheLevel1Type = "weak";
private boolean cacheLevel2 = false; // L2 cache defaults to OFF
private String cacheLevel2Type = "default";
private String cacheLevel2CacheName = null;
private String cacheLevel2ConfigurationFile = null;
// MetaData
private String jdoMetaDataFileExtension = "jdo";
private String ormMetaDataFileExtension = "orm";
private String jdoqueryMetaDataFileExtension = "jdoquery";
private boolean metadataValidate = true;
private String metadataAnnotationsManager = "org.jpox.metadata.annotations.AnnotationManagerImpl";
// Properties
private String propertiesFileName = null;
// Plug-in
private String pluginRegistryClassName = null;
private String pluginRegistryBundleCheck = "EXCEPTION";
protected transient boolean configurable=true;
// ConnectionProvider
private String connectionProviderName = "PriorityList";
private boolean connectionProviderFailOnError = false;
// Connection
private String connectionResourceType = null;
private String connection2ResourceType = null;
// DB4O
private String db4oOutputFile = null;
private boolean db4oFlushFileBuffers = true;
private boolean db4oGenerateUUIDs = false;
/** Whether to include codes in messages. */
private boolean messagesIncludeCodes = true;
/**
* Constructor.
* Initialises all properties using the System property values. This behaviour
* is not specified by the JDO spec(s) but is a nice to have capability allowing
* users to define command line args to set up their (single) persistence factory.
*/
public PersistenceConfiguration()
{
try
{
// Schema Management
datastoreAdapterClassName = System.getProperty(DATASTORE_ADAPTER_CLASSNAME_PROPERTY);
validateTables = new Boolean(System.getProperty(VALIDATE_TABLES_PROPERTY, "true")).booleanValue();
validateColumns = new Boolean(System.getProperty(VALIDATE_COLUMNS_PROPERTY, "true")).booleanValue();
validateConstraints = new Boolean(System.getProperty(VALIDATE_CONSTRAINTS_PROPERTY, "true")).booleanValue();
initializeColumnInfo = System.getProperty(INITIALIZE_COLUMN_INFO_PROPERTY, "ALL");
if (!validateTables)
{
// Can't validate columns if not validating the table!
validateColumns = false;
}
autoCreateTables = new Boolean(System.getProperty(AUTO_CREATE_TABLES_PROPERTY, "false")).booleanValue();
autoCreateColumns = new Boolean(System.getProperty(AUTO_CREATE_COLUMNS_PROPERTY, "false")).booleanValue();
autoCreateConstraints = new Boolean(System.getProperty(AUTO_CREATE_CONSTRAINTS_PROPERTY, "false")).booleanValue();
setAutoCreateSchema(new Boolean(System.getProperty(AUTO_CREATE_SCHEMA_PROPERTY, "false")).booleanValue());
autoCreateWarnOnError = new Boolean(System.getProperty(AUTO_CREATE_WARN_ON_ERROR_PROPERTY, "false")).booleanValue();
setReadOnlyDatastore(readOnlyDatastore = new Boolean(System.getProperty(READ_ONLY_DATASTORE_PROPERTY, "false")).booleanValue());
if (System.getProperty(READ_ONLY_DATASTORE_ACTION_PROPERTY) != null)
{
setReadOnlyDatastoreAction(System.getProperty(READ_ONLY_DATASTORE_ACTION_PROPERTY));
}
setFixedDatastore(new Boolean(System.getProperty(FIXED_DATASTORE_PROPERTY, "false")).booleanValue());
String datastoreClassAdditionMaxRetriesString = System.getProperty(DATASTORE_CLASS_ADDITION_MAX_RETRIES_PROPERTY);
if (datastoreClassAdditionMaxRetriesString != null)
{
try
{
datastoreClassAdditionMaxRetries = (new Integer(datastoreClassAdditionMaxRetriesString)).intValue();
}
catch (NumberFormatException nfe)
{
// Do nothing and use default.
}
}
mapping = System.getProperty(JDO_MAPPING_PROPERTY);
catalogName = System.getProperty(JDO_MAPPING_CATALOG_PROPERTY);
schemaName = System.getProperty(JDO_MAPPING_SCHEMA_PROPERTY);
setTransactionType(System.getProperty(JDO_TRANSACTION_TYPE_PROPERTY, transactionType));
name = System.getProperty(JDO_NAME_PROPERTY);
persistenceUnitName = System.getProperty(JDO_PERSISTENCE_UNIT_NAME_PROPERTY);
persistenceApiName = System.getProperty(PERSISTENCE_API_NAME, "JDO");
storeManagerType = System.getProperty(STORE_MANAGER_TYPE);
String propValue = System.getProperty(MANAGED_RUNTIME_PROPERTY);
if (propValue != null)
{
if (propValue.equalsIgnoreCase("true"))
{
managedRuntime = Boolean.TRUE;
}
}
if (readOnlyDatastore || fixedDatastore)
{
if (autoCreateTables)
{
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008011","autoCreateTables"));
autoCreateTables = false;
}
if (autoCreateColumns)
{
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008011","autoCreateColumns"));
autoCreateColumns = false;
}
if (autoCreateConstraints)
{
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008011","autoCreateConstraints"));
autoCreateConstraints = false;
}
}
if (System.getProperty(RDBMS_CONSTRAINT_CREATE_MODE_PROPERTY) != null)
{
setRDBMSConstraintCreateMode(System.getProperty(RDBMS_CONSTRAINT_CREATE_MODE_PROPERTY));
}
deletionPolicy = System.getProperty(DELETION_POLICY_PROPERTY, "JDO2");
identifierFactory = System.getProperty(IDENTIFIER_FACTORY_PROPERTY, "jpox");
identifierCase = System.getProperty(IDENTIFIER_CASE_PROPERTY, "UpperCase");
if (System.getProperty(IDENTIFIER_WORD_SEPARATOR_PROPERTY) != null)
{
setIdentifierWordSeparator(System.getProperty(IDENTIFIER_WORD_SEPARATOR_PROPERTY));
}
if (System.getProperty(IDENTIFIER_TABLE_PREFIX_PROPERTY) != null)
{
setIdentifierTablePrefix(System.getProperty(IDENTIFIER_TABLE_PREFIX_PROPERTY));
}
if (System.getProperty(IDENTIFIER_TABLE_SUFFIX_PROPERTY) != null)
{
setIdentifierTableSuffix(System.getProperty(IDENTIFIER_TABLE_SUFFIX_PROPERTY));
}
// JDO operation
classLoaderResolverName = System.getProperty(CLASS_LOADER_RESOLVER_NAME_PROPERTY, "jdo");
datastoreIdentityClassName = System.getProperty(DATASTORE_IDENTITY_CLASS_NAME_PROPERTY, "jpox");
connectionPoolingType = System.getProperty(CONNECTION_POOLING_TYPE_PROPERTY, "None");
connectionPoolingConfigurationFile = System.getProperty(CONNECTION_POOLING_CONFIGURATION_FILE_PROPERTY);
defaultInheritanceStrategy = System.getProperty(DEFAULT_INHERITANCE_STRATEGY_PROPERTY, "JDO2");
autoStartMechanism = System.getProperty(AUTO_START_MECHANISM_PROPERTY);
autoStartMechanismXmlFile = System.getProperty(AUTO_START_MECHANISM_XML_FILE_PROPERTY, "jpoxAutoStart.xml");
autoStartMechanismMode = System.getProperty(AUTO_START_MECHANISM_MODE_PROPERTY, AutoStartMechanism.MODE_QUIET);
autoStartClassNames = System.getProperty(AUTO_START_CLASS_NAMES_PROPERTY);
poidTransactionAttribute = System.getProperty(POID_TRANSACTION_ATTRIBUTE_PROPERTY, "New");
// Schema identifiers
if (System.getProperty(IDENTIFIER_CASE_PROPERTY) != null)
{
setIdentifierCase(System.getProperty(IDENTIFIER_CASE_PROPERTY));
}
// MetaData files
String extension = System.getProperty(METADATA_JDO_FILE_EXTENSION_PROPERTY);
if (!StringUtils.isWhitespace(extension))
{
jdoMetaDataFileExtension = extension;
}
extension = System.getProperty(METADATA_ORM_FILE_EXTENSION_PROPERTY);
if (!StringUtils.isWhitespace(extension))
{
ormMetaDataFileExtension = extension;
}
extension = System.getProperty(METADATA_JDOQUERY_FILE_EXTENSION_PROPERTY);
if (!StringUtils.isWhitespace(extension))
{
jdoqueryMetaDataFileExtension = extension;
}
metadataValidate = new Boolean(System.getProperty(METADATA_VALIDATE_PROPERTY,"true")).booleanValue();
extension = System.getProperty(METADATA_ANNOTATIONS_MANAGER_PROPERTY);
if (!StringUtils.isWhitespace(extension))
{
metadataAnnotationsManager = extension;
}
// Caching
cacheCollections = new Boolean(System.getProperty(CACHE_COLLECTIONS_PROPERTY,"true")).booleanValue();
if (System.getProperty(CACHE_COLLECTIONS_LAZY_PROPERTY) != null)
{
cacheCollectionsLazy = new Boolean(System.getProperty(CACHE_COLLECTIONS_LAZY_PROPERTY));
}
cacheLevel1Type = System.getProperty(CACHE_LEVEL_1_TYPE_PROPERTY, "weak");
cacheLevel2 = new Boolean(System.getProperty(CACHE_LEVEL_2_PROPERTY,"false")).booleanValue();
cacheLevel2Type = System.getProperty(CACHE_LEVEL_2_TYPE_PROPERTY, "default");
cacheLevel2CacheName = System.getProperty(CACHE_LEVEL_2_CACHE_NAME_PROPERTY);
cacheLevel2ConfigurationFile = System.getProperty(CACHE_LEVEL_2_CONFIGURATION_FILE_PROPERTY);
// Queries
queryFlushBeforeExecution = new Boolean(System.getProperty(QUERY_FLUSH_BEFORE_EXECUTION_PROPERTY, "false")).booleanValue();
queryUseFetchPlan = new Boolean(System.getProperty(QUERY_USE_FETCH_PLAN_PROPERTY, "true")).booleanValue();
String queryTimeoutString = System.getProperty(QUERY_TIMEOUT_PROPERTY);
if (queryTimeoutString != null)
{
try
{
queryTimeout = (new Integer(queryTimeoutString)).intValue();
}
catch (NumberFormatException nfe)
{
// Do nothing and use default.
}
}
queryFetchDirection = System.getProperty(QUERY_FETCH_DIRECTION_PROPERTY, "forward");
queryResultSetType = System.getProperty(QUERY_RESULT_SET_TYPE_PROPERTY, "forward-only");
queryResultSetConcurrency = System.getProperty(QUERY_RESULT_SET_CONCURRENCY_PROPERTY, "read-only");
queryAllowAllSQLStatements = new Boolean(System.getProperty(QUERY_ALLOW_ALL_SQL_STATEMENTS, "false")).booleanValue();
queryJoinType = System.getProperty(QUERY_JOIN_TYPE_PROPERTY);
queryExistsIncludesConstraints = new Boolean(System.getProperty(QUERY_EXISTS_INCLUDES_PROPERTY, "true")).booleanValue();
queryContainsUsesExistsAlways = new Boolean(System.getProperty(QUERY_CONTAINS_EXISTS_ALWAYS_PROPERTY, "false")).booleanValue();
// Types
String stringLengthTemp = System.getProperty(STRING_DEFAULT_LENGTH_PROPERTY);
if (stringLengthTemp != null)
{
try
{
stringDefaultLength = (new Integer(stringLengthTemp)).intValue();
}
catch (NumberFormatException nfe)
{
stringDefaultLength = JDO2_STRING_DEFAULT_LENGTH;
}
}
stringLengthExceededAction = System.getProperty(STRING_LENGTH_ACTION_PROPERTY, "EXCEPTION");
persistEmptyStringAsNull = new Boolean(System.getProperty(PERSIST_EMPTY_STRING_AS_NULL_PROPERTY, "false")).booleanValue();
discriminatorPerSubclassTable = new Boolean(System.getProperty(DISCRIMINATOR_PER_SUBCLASSTABLE_PROPERTY, "false")).booleanValue();
oracleNlsSortOrder = System.getProperty(ORACLE_SORT_ORDER_PROPERTY, "LATIN");
//ConnectionProvider
connectionProviderName = System.getProperty(CONNECTION_PROVIDER_NAME_PROPERTY,"PriorityList");
connectionProviderFailOnError = new Boolean(System.getProperty(CONNECTION_PROVIDER_FAILONERROR_PROPERTY,"false")).booleanValue();
setPropertiesFile(System.getProperty(PROPERTIES_FILE));
// Connection properties
connectionResourceType = System.getProperty(CONNECTION_RESOURCE_TYPE);
connection2ResourceType = System.getProperty(CONNECTION2_RESOURCE_TYPE);
// DB4O properties
db4oOutputFile = System.getProperty(DB4O_OUTPUT_FILE_PROPERTY);
db4oFlushFileBuffers = new Boolean(System.getProperty(DB4O_FLUSH_BUFFERS_PROPERTY, "true")).booleanValue();
db4oGenerateUUIDs = new Boolean(System.getProperty(DB4O_GENERATE_UUIDS_PROPERTY, "false")).booleanValue();
// Plugin resources
pluginRegistryClassName = System.getProperty(PLUGIN_REGISTRY_CLASS_NAME);
pluginRegistryBundleCheck = System.getProperty(PLUGIN_REGISTRY_BUNDLE_CHECK, "EXCEPTION");
}
catch (Exception e)
{
// May arrive here if the server throws a SecurityException
JPOXLogger.PERSISTENCE.error(e);
}
}
/**
* Equality operator.
* @param obj Object to compare against.
* @return Whether the objects are equal.
**/
public synchronized boolean equals(Object obj)
{
if (obj == this)
{
return true;
}
if (!(obj instanceof PersistenceConfiguration))
{
return false;
}
PersistenceConfiguration config = (PersistenceConfiguration)obj;
boolean isEquals = true;
isEquals = isEquals & equalsVariable(driverName, config.driverName);
isEquals = isEquals & equalsVariable(url, config.url);
isEquals = isEquals & equalsVariable(userName, config.userName);
isEquals = isEquals & equalsVariable(password, config.password);
isEquals = isEquals & equalsVariable(connectionFactory, config.connectionFactory);
isEquals = isEquals & equalsVariable(connectionFactoryName, config.connectionFactoryName);
isEquals = isEquals & equalsVariable(connectionFactory2, config.connectionFactory2);
isEquals = isEquals & equalsVariable(connectionFactory2Name, config.connectionFactory2Name);
isEquals = isEquals & equalsVariable(mapping, config.mapping);
isEquals = isEquals & equalsVariable(catalogName, config.catalogName);
isEquals = isEquals & equalsVariable(schemaName, config.schemaName);
isEquals = isEquals & equalsVariable(transactionType, config.transactionType);
isEquals = isEquals & equalsVariable(serverTimeZoneID, config.serverTimeZoneID);
isEquals = isEquals & equalsVariable(name, config.name);
isEquals = isEquals & equalsVariable(persistenceUnitName, config.persistenceUnitName);
isEquals = isEquals & equalsVariable(storeManagerType, config.storeManagerType);
isEquals = isEquals & equalsVariable(managedRuntime, config.managedRuntime);
isEquals = isEquals & equalsVariable(persistenceApiName, config.persistenceApiName);
isEquals = isEquals & equalsVariable(cacheLevel1Type, config.cacheLevel1Type);
isEquals = isEquals & equalsVariable(cacheLevel2Type, config.cacheLevel2Type);
isEquals = isEquals & equalsVariable(cacheLevel2CacheName, config.cacheLevel2CacheName);
isEquals = isEquals & equalsVariable(cacheLevel2ConfigurationFile, config.cacheLevel2ConfigurationFile);
isEquals = isEquals & (cacheLevel2 == config.cacheLevel2);
isEquals = isEquals & (cacheCollections == config.cacheCollections);
isEquals = isEquals & (cacheCollectionsLazy == config.cacheCollectionsLazy);
isEquals = isEquals & equalsVariable(datastoreAdapterClassName, config.datastoreAdapterClassName);
isEquals = isEquals & equalsVariable(autoStartMechanism, config.autoStartMechanism);
isEquals = isEquals & equalsVariable(autoStartMechanismXmlFile, config.autoStartMechanismXmlFile);
isEquals = isEquals & equalsVariable(autoStartMechanismMode, config.autoStartMechanismMode);
isEquals = isEquals & equalsVariable(autoStartClassNames, config.autoStartClassNames);
isEquals = isEquals & equalsVariable(poidTransactionAttribute,config.poidTransactionAttribute);
isEquals = isEquals & (checkExistTablesOrViews == config.checkExistTablesOrViews);
isEquals = isEquals & equalsVariable(defaultInheritanceStrategy, config.defaultInheritanceStrategy);
isEquals = isEquals & (stringDefaultLength == config.stringDefaultLength);
isEquals = isEquals & equalsVariable(stringLengthExceededAction, config.stringLengthExceededAction);
isEquals = isEquals & (persistEmptyStringAsNull == config.persistEmptyStringAsNull);
isEquals = isEquals & (discriminatorPerSubclassTable == config.discriminatorPerSubclassTable);
isEquals = isEquals & (statementBatchLimit == config.statementBatchLimit);
isEquals = isEquals & equalsVariable(oracleNlsSortOrder, config.oracleNlsSortOrder);
// MetaData
isEquals = isEquals & equalsVariable(jdoMetaDataFileExtension, config.jdoMetaDataFileExtension);
isEquals = isEquals & equalsVariable(ormMetaDataFileExtension, config.ormMetaDataFileExtension);
isEquals = isEquals & equalsVariable(jdoqueryMetaDataFileExtension, config.jdoqueryMetaDataFileExtension);
isEquals = isEquals & (metadataValidate == config.metadataValidate);
isEquals = isEquals & equalsVariable(metadataAnnotationsManager, config.metadataAnnotationsManager);
// query
isEquals = isEquals & (queryFlushBeforeExecution == config.queryFlushBeforeExecution);
isEquals = isEquals & (queryUseFetchPlan == config.queryUseFetchPlan);
isEquals = isEquals & (queryAllowAllSQLStatements == config.queryAllowAllSQLStatements);
isEquals = isEquals & (queryTimeout == config.queryTimeout);
isEquals = isEquals & equalsVariable(queryFetchDirection, config.queryFetchDirection);
isEquals = isEquals & equalsVariable(queryResultSetConcurrency, config.queryResultSetConcurrency);
isEquals = isEquals & equalsVariable(queryResultSetType, config.queryResultSetType);
isEquals = isEquals & (queryJoinType == config.queryJoinType);
isEquals = isEquals & (queryExistsIncludesConstraints == config.queryExistsIncludesConstraints);
isEquals = isEquals & (queryContainsUsesExistsAlways == config.queryContainsUsesExistsAlways);
isEquals = isEquals & (persistenceByReachabilityAtCommit == config.persistenceByReachabilityAtCommit);
isEquals = isEquals & (maxFetchDepth == config.maxFetchDepth);
isEquals = isEquals & (primaryClassLoader == config.primaryClassLoader);
isEquals = isEquals & equalsVariable(classLoaderResolverName, config.classLoaderResolverName);
isEquals = isEquals & equalsVariable(implementationCreatorName, config.implementationCreatorName);
isEquals = isEquals & equalsVariable(datastoreIdentityClassName, config.datastoreIdentityClassName);
isEquals = isEquals & equalsVariable(connectionPoolingType, config.connectionPoolingType);
isEquals = isEquals & equalsVariable(connectionPoolingConfigurationFile, config.connectionPoolingConfigurationFile);
isEquals = isEquals & (datastoreClassAdditionMaxRetries == config.datastoreClassAdditionMaxRetries);
isEquals = isEquals & (isolationLevel == config.isolationLevel);
isEquals = isEquals & equalsVariable(jtaLocator, config.jtaLocator);
isEquals = isEquals & equalsVariable(jtaJndiLocation, config.jtaJndiLocation);
isEquals = isEquals & (datastoreTransactionDelayOperations == config.datastoreTransactionDelayOperations);
isEquals = isEquals & (datastoreTransactionFlushLimit == config.datastoreTransactionFlushLimit);
isEquals = isEquals & (poidIsolationLevel == config.poidIsolationLevel);
isEquals = isEquals & (multithreaded == config.multithreaded);
isEquals = isEquals & (optimistic == config.optimistic);
isEquals = isEquals & (retainValues == config.retainValues);
isEquals = isEquals & (restoreValues == config.restoreValues);
isEquals = isEquals & (nontransactionalRead == config.nontransactionalRead);
isEquals = isEquals & (nontransactionalWrite == config.nontransactionalWrite);
isEquals = isEquals & (ignoreCache == config.ignoreCache);
isEquals = isEquals & (detachAllOnCommit == config.detachAllOnCommit);
isEquals = isEquals & (copyOnAttach == config.copyOnAttach);
isEquals = isEquals & (manageRelationships == config.manageRelationships);
isEquals = isEquals & (manageRelationshipsChecks == config.manageRelationshipsChecks);
isEquals = isEquals & (detachOnClose == config.detachOnClose);
isEquals = isEquals & (findObjectCheckInheritance == config.findObjectCheckInheritance);
isEquals = isEquals & (attachSameDatastore == config.attachSameDatastore);
isEquals = isEquals & (jpaOneToManyUniFkRelations == config.jpaOneToManyUniFkRelations);
//schema
isEquals = isEquals & (validateTables == config.validateTables);
isEquals = isEquals & (validateColumns == config.validateColumns);
isEquals = isEquals & (validateConstraints == config.validateConstraints);
isEquals = isEquals & (autoCreateTables == config.autoCreateTables);
isEquals = isEquals & (autoCreateColumns == config.autoCreateColumns);
isEquals = isEquals & (autoCreateConstraints == config.autoCreateConstraints);
isEquals = isEquals & (autoCreateWarnOnError == config.autoCreateWarnOnError);
isEquals = isEquals & equalsVariable(initializeColumnInfo, config.initializeColumnInfo);
isEquals = isEquals & (readOnlyDatastore == config.readOnlyDatastore);
isEquals = isEquals & (fixedDatastore == config.fixedDatastore);
isEquals = isEquals & equalsVariable(rdbmsConstraintCreateMode, config.rdbmsConstraintCreateMode);
isEquals = isEquals & equalsVariable(deletionPolicy, config.deletionPolicy);
isEquals = isEquals & (uniqueConstraintsMapInverse == config.uniqueConstraintsMapInverse);
isEquals = isEquals & equalsVariable(propertiesFileName, config.propertiesFileName);
//ConnectionProvider
isEquals = isEquals & equalsVariable(connectionProviderName, config.connectionProviderName);
isEquals = isEquals & (connectionProviderFailOnError == config.connectionProviderFailOnError);
// Connection
isEquals = isEquals & equalsVariable(connectionResourceType, config.connectionResourceType);
isEquals = isEquals & equalsVariable(connection2ResourceType, config.connection2ResourceType);
// DB4O
isEquals = isEquals & equalsVariable(db4oOutputFile, config.db4oOutputFile);
isEquals = isEquals & (db4oFlushFileBuffers == config.db4oFlushFileBuffers);
isEquals = isEquals & (db4oGenerateUUIDs == config.db4oGenerateUUIDs);
return isEquals;
}
/**
* Equals two variables testing for nulls
* @param var1 the first variable
* @param var2 the second variable
* @return true if equals
*/
private boolean equalsVariable(Object var1, Object var2)
{
if (var1 == null)
{
if (var2 != null)
{
return false;
}
}
else if (!var1.equals(var2))
{
return false;
}
return true;
}
// ------------------------------ JDO Standard Getters/Setters --------------------------------
/**
* Set the user name for the data store connection.
* @param userName the user name for the data store connection.
*/
public synchronized void setConnectionUserName(String userName)
{
assertConfigurable();
this.userName = userName;
}
/**
* Get the user name for the data store connection.
* @return the user name for the data store connection.
*/
public String getConnectionUserName()
{
return userName;
}
/**
* Set the password for the data store connection.
* @param password the password for the data store connection.
*/
public synchronized void setConnectionPassword(String password)
{
assertConfigurable();
this.password = password;
}
/**
* Set the URL for the data store connection.
* @param url the URL for the data store connection.
*/
public synchronized void setConnectionURL(String url)
{
assertConfigurable();
this.url = url;
}
/**
* Get the URL for the data store connection.
* @return the URL for the data store connection.
*/
public String getConnectionURL()
{
return url;
}
/**
* Set the driver name for the data store connection.
* @param driverName the driver name for the data store connection.
*/
public synchronized void setConnectionDriverName(String driverName)
{
assertConfigurable();
this.driverName = driverName;
}
/**
* Get the driver name for the data store connection.
* @return the driver name for the data store connection.
*/
public String getConnectionDriverName()
{
return driverName;
}
/**
* Get the password for the data store connection.
* @return the password for the data store connection.
*/
public String getConnectionPassword()
{
return password;
}
/**
* Set the name for the data store connection factory.
* @param connectionFactoryName name of the data store connection factory.
*/
public synchronized void setConnectionFactoryName(String connectionFactoryName)
{
assertConfigurable();
this.connectionFactoryName = connectionFactoryName;
}
/**
* Get the name for the data store connection factory.
* @return the name of the data store connection factory.
*/
public String getConnectionFactoryName()
{
return connectionFactoryName;
}
/**
* Set the data store connection factory. JDO implementations
* will support specific connection factories. The connection
* factory interfaces are not part of the JDO specification.
* @param connectionFactory the data store connection factory.
*/
public synchronized void setConnectionFactory(Object connectionFactory)
{
assertConfigurable();
this.connectionFactory = connectionFactory;
}
/**
* Get the data store connection factory.
* @return the data store connection factory.
*/
public Object getConnectionFactory()
{
return connectionFactory;
}
/**
* Set the name for the second data store connection factory. This is
* needed for managed environments to get nontransactional connections for
* optimistic transactions.
* @param connectionFactoryName name of the data store connection factory.
*/
public synchronized void setConnectionFactory2Name(String connectionFactoryName)
{
assertConfigurable();
this.connectionFactory2Name = connectionFactoryName;
}
/**
* Get the name for the second data store connection factory. This is
* needed for managed environments to get nontransactional connections for
* optimistic transactions.
* @return the name of the data store connection factory.
*/
public String getConnectionFactory2Name()
{
return connectionFactory2Name;
}
/**
* Set the second data store connection factory. This is
* needed for managed environments to get nontransactional connections for
* optimistic transactions. JDO implementations
* will support specific connection factories. The connection
* factory interfaces are not part of the JDO specification.
* @param connectionFactory the data store connection factory.
*/
public synchronized void setConnectionFactory2(Object connectionFactory)
{
assertConfigurable();
this.connectionFactory2 = connectionFactory;
}
/**
* Get the second data store connection factory. This is
* needed for managed environments to get nontransactional connections for
* optimistic transactions.
* @return the data store connection factory.
*/
public Object getConnectionFactory2()
{
return connectionFactory2;
}
/**
* Set the default Multithreaded setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @param flag the default Multithreaded setting.
*/
public synchronized void setMultithreaded(boolean flag)
{
assertConfigurable();
multithreaded = flag;
}
/**
* Get the default Multithreaded setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @return the default Multithreaded setting.
*/
public boolean getMultithreaded()
{
return multithreaded;
}
/**
* Set the default Optimistic setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @param flag the default Optimistic setting.
*/
public synchronized void setOptimistic(boolean flag)
{
assertConfigurable();
optimistic = flag;
}
/**
* Get the default Optimistic setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @return the default Optimistic setting.
*/
public boolean getOptimistic()
{
return optimistic;
}
/**
* Set the default RetainValues setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @param flag the default RetainValues setting.
*/
public synchronized void setRetainValues(boolean flag)
{
assertConfigurable();
retainValues = flag;
}
/**
* Get the default RetainValues setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @return the default RetainValues setting.
*/
public boolean getRetainValues()
{
return retainValues;
}
/**
* Set the default RestoreValues setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @param flag the default RestoreValues setting.
*/
public synchronized void setRestoreValues(boolean flag)
{
assertConfigurable();
restoreValues = flag;
}
/**
* Get the default RestoreValues setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @return the default RestoreValues setting.
*/
public boolean getRestoreValues()
{
return restoreValues;
}
/**
* Set the default NontransactionalRead setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default NontransactionalRead setting.
*/
public synchronized void setNontransactionalRead(boolean flag)
{
assertConfigurable();
nontransactionalRead = flag;
}
/**
* Get the default NontransactionalRead setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default NontransactionalRead setting.
*/
public boolean getNontransactionalRead()
{
return nontransactionalRead;
}
/**
* Set the default NontransactionalWrite setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default NontransactionalWrite setting.
*/
public synchronized void setNontransactionalWrite(boolean flag)
{
assertConfigurable();
nontransactionalWrite = flag;
}
/**
* Get the default NontransactionalWrite setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default NontransactionalWrite setting.
*/
public boolean getNontransactionalWrite()
{
return nontransactionalWrite;
}
/**
* Set the default IgnoreCache setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @param flag the default IgnoreCache setting.
*/
public synchronized void setIgnoreCache(boolean flag)
{
assertConfigurable();
ignoreCache = flag;
}
/**
* Get the default IgnoreCache setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @return the IgnoreCache setting.
*/
public boolean getIgnoreCache()
{
return ignoreCache;
}
/**
* Mutator for the DetachAllOnCommit setting.
* @param flag the default DetachAllOnCommit setting.
* @since 1.1
*/
public synchronized void setDetachAllOnCommit(boolean flag)
{
assertConfigurable();
detachAllOnCommit = flag;
}
/**
* Accessor for the DetachAllOnCommit setting.
* @return the DetachAllOnCommit setting.
* @since 1.1
*/
public boolean getDetachAllOnCommit()
{
return detachAllOnCommit;
}
/**
* Mutator for the CopyOnAttach setting.
* @param flag the default CopyOnAttach setting.
* @since 1.2
*/
public synchronized void setCopyOnAttach(boolean flag)
{
assertConfigurable();
copyOnAttach = flag;
}
/**
* Accessor for the CopyOnAttach setting.
* @return the CopyOnAttach setting.
* @since 1.2
*/
public boolean getCopyOnAttach()
{
return copyOnAttach;
}
/**
* Set the name for any mapping, used in searching for ORM/Query metadata
* files.
* @param mapping the mapping name
*/
public synchronized void setMapping(String mapping)
{
assertConfigurable();
this.mapping = mapping;
}
/**
* Get the name for any mapping, used in retrieving metadata files for
* ORM/Query data.
* @return the name for the mapping.
*/
public String getMapping()
{
return mapping;
}
/**
* Mutator for the catalog to use for this persistence factory.
* @param catalog Name of the catalog
* @since 1.1
*/
public synchronized void setCatalog(String catalog)
{
assertConfigurable();
this.catalogName = catalog;
}
/**
* Accessor for the catalog to use for this persistence factory.
* @return the name of the catalog
* @since 1.1
*/
public String getCatalog()
{
return catalogName;
}
/**
* Mutator for the schema to use for this persistence factory.
* @param schema Name of the schema
* @since 1.1
*/
public synchronized void setSchema(String schema)
{
assertConfigurable();
this.schemaName = schema;
}
/**
* Accessor for the schema to use for this persistence factory.
* @return the name of the schema
* @since 1.1
*/
public String getSchema()
{
return schemaName;
}
/**
* Mutator for the transaction type to use for this persistence factory.
* @param type Transaction type
*/
public synchronized void setTransactionType(String type)
{
assertConfigurable();
if (type == null)
{
return;
}
if (type.equalsIgnoreCase(TransactionType.JTA.toString()) ||
type.equalsIgnoreCase(TransactionType.RESOURCE_LOCAL.toString()))
{
this.transactionType = type;
}
else
{
throw new IllegalArgumentException(LOCALISER.msg("008012", JDO_TRANSACTION_TYPE_PROPERTY, type));
}
}
/**
* Accessor for the transaction type to use with this persistence factory.
* @return transaction type
*/
public String getTransactionType()
{
return transactionType;
}
/**
* Mutator for the timezone id of the datastore server.
* If not set assumes that it is running in the same timezone as this JVM.
* @param id Timezone Id to use
*/
public void setServerTimeZoneID(String id)
{
String[] availableIDs = TimeZone.getAvailableIDs();
boolean validZone = false;
for (int i=0; i<availableIDs.length;i++)
{
if (availableIDs[i].equals(id))
{
validZone = true;
break;
}
}
if (!validZone)
{
// TODO Really should be a JPOXException but only called by JDO anyway currently
throw new JDOUserException("Invalid TimeZone ID specified");
}
serverTimeZoneID = id;
}
/**
* Accessor for the timezone "id" of the datastore server (if any).
* If not set assumes the same as the JVM JPOX is running in.
* @return Server timezone id
*/
public String getServerTimeZoneID()
{
return serverTimeZoneID;
}
/**
* Accessor for the Calendar to be used in handling all timezone issues with the datastore.
* Utilises the "serverTimeZoneID" in providing this Calendar used in time/date conversions.
* @return The calendar to use for dateTimezone issues.
*/
public Calendar getCalendarForDateTimezone()
{
if (dateTimezoneCalendar == null)
{
TimeZone tz;
if (serverTimeZoneID != null)
{
tz = TimeZone.getTimeZone(serverTimeZoneID);
}
else
{
tz = TimeZone.getDefault();
}
dateTimezoneCalendar = new GregorianCalendar(tz);
}
return dateTimezoneCalendar;
}
/**
* Mutator for the name of the persistence factory.
* @param name Name of the persistence factory (if any)
*/
public synchronized void setName(String name)
{
assertConfigurable();
this.name = name;
}
/**
* Accessor for the name of the persistence factory (if any).
* @return the name of the persistence factory
*/
public String getName()
{
return name;
}
/**
* Mutator for the name of the persistence unit.
* @param name Name of the persistence unit
*/
public synchronized void setPersistenceUnitName(String name)
{
assertConfigurable();
this.persistenceUnitName = name;
}
/**
* Accessor for the name of the persistence unit
* @return the name of the persistence unit
*/
public String getPersistenceUnitName()
{
return persistenceUnitName;
}
// ------------------------------ JPA Standard Getters/Setters --------------------------------
/**
* Mutator for whether to allow 1-N unidir FK relations when using JPA.
* @param flag Whether to support 1-N uni FK relations
*/
public synchronized void setJpaOneToManyUniFkRelations(boolean flag)
{
assertConfigurable();
jpaOneToManyUniFkRelations = flag;
}
/**
* Accessor for whether to allow 1-N uni FK relations
* @return Whether to allow 1-N uni FK relations
*/
public boolean getJpaOneToManyUniFkRelations()
{
return jpaOneToManyUniFkRelations;
}
// --------------------------- JPOX Extension Getters/Setters ---------------------
/**
* Mutator for the JCA mode.
* @param jca true if using JCA connector
*/
public synchronized void setJCAMode(Boolean jca)
{
assertConfigurable();
this.jca = jca;
}
/**
* Accessor for the JCA mode.
* @return true if using JCA connector.
*/
public boolean isJcaMode()
{
return jca != null && jca.booleanValue();
}
/**
* Set the Connection ResourceType
* @param resourceType The Connection ResourceType
*/
public synchronized void setConnectionResourceType(String resourceType)
{
assertConfigurable();
connectionResourceType = ResourceType.getValue(resourceType).toString();
}
/**
* Get the Connection ResourceType
* @return The Connection ResourceType
*/
public String getConnectionResourceType()
{
return connectionResourceType;
}
/**
* Set the Connection2 ResourceType
* @param resourceType The Connection2 ResourceType
*/
public synchronized void setConnection2ResourceType(String resourceType)
{
assertConfigurable();
connection2ResourceType = ResourceType.getValue(resourceType).toString();
}
/**
* Get the Connection2 ResourceType
* @return The Connection2 ResourceType
*/
public String getConnection2ResourceType()
{
return connection2ResourceType;
}
/**
* Mutator for whether to manage (bidirectional) relationships at flush/commit.
* @param flag Whether to manage relationships
*/
public synchronized void setManageRelationships(boolean flag)
{
assertConfigurable();
manageRelationships = flag;
}
/**
* Accessor for whether to manage (bidirectional) relationships at flush/commit.
* @return Whether to manage bidir relationships
*/
public boolean getManageRelationships()
{
return manageRelationships;
}
/**
* Mutator for whether to check manage (bidirectional) relationships at flush/commit.
* @param flag Whether to check manage relationships
*/
public synchronized void setManageRelationshipsChecks(boolean flag)
{
assertConfigurable();
manageRelationshipsChecks = flag;
}
/**
* Accessor for whether to check manage (bidirectional) relationships at flush/commit.
* @return Whether to check manage bidir relationships
*/
public boolean getManageRelationshipsChecks()
{
return manageRelationshipsChecks;
}
/**
* Mutator for whether we should check inheritance when finding an object by its id.
* @param flag Whether to check the inheritance
*/
public synchronized void setFindObjectCheckInheritance(boolean flag)
{
assertConfigurable();
findObjectCheckInheritance = flag;
}
/**
* Accessor for whether we should check the inheritance on find object by id.
* @return Whether we check the inheritance
*/
public boolean getFindObjectCheckInheritance()
{
return findObjectCheckInheritance;
}
/**
* Mutator for whether when attaching we can assume that any detached objects are from this same datastore.
* @param flag Whether to assume the same datastore
*/
public synchronized void setAttachSameDatastore(boolean flag)
{
assertConfigurable();
attachSameDatastore = flag;
}
/**
* Accessor for whether we can assume that when attaching any detached objects are detached from the same datastore.
* @return Whether we assume same datastore
*/
public boolean getAttachSameDatastore()
{
return attachSameDatastore;
}
/**
* Set the default DetachOnClose setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @param flag the default DetachOnClose setting.
* @since 1.1
*/
public synchronized void setDetachOnClose(boolean flag)
{
assertConfigurable();
if (flag)
{
JPOXLogger.PERSISTENCE.warn("Use of org.jpox.detachOnClose is deprecated and likely to be removed in a later release. " +
"Please use javax.jdo.option.DetachAllOnCommit");
}
detachOnClose = flag;
}
/**
* Get the default DetachOnClose setting for all <tt>PersistenceManager</tt>
* instances obtained from this factory.
* @return the DetachOnClose setting.
* @since 1.1
*/
public boolean getDetachOnClose()
{
return detachOnClose;
}
/**
* Set the connection provider name.
* @param name the connection provider name.
*/
public synchronized void setConnectionProviderName(String name)
{
assertConfigurable();
this.connectionProviderName = name;
}
/**
* Get the connection provider name.
* @return the connection provider name.
*/
public String getConnectionProviderName()
{
return connectionProviderName;
}
/**
* Set the connection provider failOnError.
* @param flag the connection provider failOnError.
*/
public synchronized void setConnectionProviderFailOnError(boolean flag)
{
assertConfigurable();
this.connectionProviderFailOnError = flag;
}
/**
* Get the connection provider failOnError.
* @return the connection provider failOnError.
*/
public boolean getConnectionProviderFailOnError()
{
return connectionProviderFailOnError;
}
/**
* Mutator for the store manager type.
* @param type StoreManager type
*/
public synchronized void setStoreManagerType(String type)
{
assertConfigurable();
this.storeManagerType = type;
}
/**
* Accessor for the StoreManager type to use.
* @return the StoreManager type
*/
public String getStoreManagerType()
{
return storeManagerType;
}
/**
* Mutator for whether to provide a managed runtime.
* @param managed Whether to provide a managed runtime
*/
public synchronized void setManagedRuntime(Boolean managed)
{
assertConfigurable();
this.managedRuntime = managed;
}
/**
* Accessor for whether to provide a managed runtime (MBeans).
* @return whether to provide a managed runtime
*/
public Boolean getManagedRuntime()
{
return managedRuntime;
}
/**
* Mutator for the persistence API
* @param name Persistence API
*/
public synchronized void setPersistenceApiName(String name)
{
assertConfigurable();
this.persistenceApiName = name;
}
/**
* Accessor for the persistence API being used
* @return the persistence API being used
*/
public String getPersistenceApiName()
{
return persistenceApiName;
}
/**
* Set the name of the datastore adapter to use.
* @param adapterClassName Name of the class of the datastore adapter to use.
* @since 1.1
*/
public synchronized void setDatastoreAdapterClassName(String adapterClassName)
{
assertConfigurable();
datastoreAdapterClassName = adapterClassName;
}
/**
* Accessor for the datastore adapter class name (null implies autodetect)
* @return the datastore adapter class name to use.
* @since 1.1
*/
public String getDatastoreAdapterClassName()
{
return datastoreAdapterClassName;
}
/**
* Set the connection pooling type.
* @param type The connection pooling type
* @since 1.1
*/
public synchronized void setConnectionPoolingType(String type)
{
assertConfigurable();
if (type == null)
{
type = "None";
}
this.connectionPoolingType = type;
}
/**
* Get the connection pooling type.
* @return the connection pooling type to be used.
* @since 1.1
*/
public String getConnectionPoolingType()
{
return connectionPoolingType;
}
/**
* Set the connection pooling configuration file to use.
* @param file The connection pooling configuration file
* @since 1.1
*/
public synchronized void setConnectionPoolingConfigurationFile(String file)
{
assertConfigurable();
this.connectionPoolingConfigurationFile = file;
}
/**
* Get the connection pooling configuration file.
* @return the connection pooling configuration file to be used.
* @since 1.1
*/
public String getConnectionPoolingConfigurationFile()
{
return connectionPoolingConfigurationFile;
}
/**
* Set the limit on number of SQL statements that can be batched in one go.
* This supports values of 0 for no batching and -1 for unlimited batching.
* @param limit Max number of statements to batch
*/
public synchronized void setStatementBatchLimit(int limit)
{
assertConfigurable();
statementBatchLimit = limit;
}
/**
* Accessor for the limit on number of SQL statements that can be batched in one go.
* @return Max number of statements to batch
*/
public int getStatementBatchLimit()
{
return statementBatchLimit;
}
/**
* Set the default CheckExistTablesOrViews setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default CheckExistTablesOrViews setting.
*/
public synchronized void setCheckExistTablesOrViews(boolean flag)
{
assertConfigurable();
checkExistTablesOrViews = flag;
}
/**
* Get the default CheckExistTablesOrViews setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default CheckExistTablesOrViews setting.
*/
public boolean getCheckExistTablesOrViews()
{
return checkExistTablesOrViews;
}
/**
* Set the default ValidateTables setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default ValidateTables setting.
*/
public synchronized void setValidateTables(boolean flag)
{
assertConfigurable();
validateTables = flag;
if (!validateTables)
{
// Can't validate the columns if we aren't validating the table
setValidateColumns(false);
}
}
/**
* Get the default ValidateTables setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default ValidateTables setting.
*/
public boolean getValidateTables()
{
return validateTables;
}
/**
* Set the default InitializeColumnInfo setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* Takes values of "ALL", "NONE" or "PK" for which columns to initialise.
* @param flag the default InitializePrimaryKeyColumnInfo setting.
*/
public synchronized void setInitializeColumnInfo(String flag)
{
assertConfigurable();
if (flag != null &&
(flag.equalsIgnoreCase("ALL") || flag.equalsIgnoreCase("NONE") || flag.equalsIgnoreCase("PK")))
{
initializeColumnInfo = flag;
}
}
/**
* Get the default InitializeColumnInfo setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default InitializeColumnInfo setting.
*/
public String getInitializeColumnInfo()
{
return initializeColumnInfo;
}
/**
* Set the default ValidateColumns setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default ValidateColumns setting.
* @since 1.1
*/
public synchronized void setValidateColumns(boolean flag)
{
assertConfigurable();
validateColumns = flag;
}
/**
* Get the default ValidateColumns setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default ValidateColumns setting.
* @since 1.1
*/
public boolean getValidateColumns()
{
return validateColumns;
}
/**
* Set the default ValidateConstraints setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default ValidateConstraints setting.
*/
public synchronized void setValidateConstraints(boolean flag)
{
assertConfigurable();
validateConstraints = flag;
}
/**
* Get the default ValidateConstraints setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default ValidateConstraints setting.
*/
public boolean getValidateConstraints()
{
return validateConstraints;
}
/**
* Set whether this datastore is readOnly
* @param flag the readOnly setting.
*/
public synchronized void setReadOnlyDatastore(boolean flag)
{
assertConfigurable();
readOnlyDatastore = flag;
if (flag)
{
setAutoCreateTables(false);
setAutoCreateColumns(false);
setAutoCreateConstraints(false);
}
}
/**
* Accessor for whether the datastore is read-only (no structural or content changes allowed).
* @return the readOnly setting.
*/
public boolean getReadOnlyDatastore()
{
return readOnlyDatastore;
}
/**
* Set the action when we have a read-only datastore and an update is attempted.
* @param action the readOnly action setting.
*/
public synchronized void setReadOnlyDatastoreAction(String action)
{
assertConfigurable();
readOnlyDatastoreAction = action;
}
/**
* Accessor for the action when we have a read-only datastore and an update is attempted.
* @return the readOnly action setting.
*/
public String getReadOnlyDatastoreAction()
{
return readOnlyDatastoreAction;
}
/**
* Set whether this datastore schema is fixed
* @param flag the fixed setting.
*/
public synchronized void setFixedDatastore(boolean flag)
{
assertConfigurable();
fixedDatastore = flag;
if (flag)
{
setAutoCreateTables(false);
setAutoCreateColumns(false);
setAutoCreateConstraints(false);
}
}
/**
* Accessor for whether the datastore is read-only (no structural changes allowed).
* @return the fixed setting.
*/
public boolean getFixedDatastore()
{
return fixedDatastore;
}
/**
* Mutator for the RDBMS constraint creation mode
* @param mode the RDBMS constraint create mode
* @since 1.2
*/
public synchronized void setRDBMSConstraintCreateMode(String mode)
{
assertConfigurable();
if (mode.equalsIgnoreCase("JPOX") || mode.equalsIgnoreCase("JDO2"))
{
rdbmsConstraintCreateMode = mode;
}
}
/**
* Accessor for the RDBMS constraint creation mode.
* @return the RDBMS constraint creation mode
* @since 1.2
*/
public String getRDBMSConstraintCreateMode()
{
return rdbmsConstraintCreateMode;
}
/**
* Mutator for the deletion policy
* @param policy the FK create mode
* @since 1.1
*/
public synchronized void setDeletionPolicy(String policy)
{
assertConfigurable();
if (policy.equalsIgnoreCase("JPOX") || policy.equalsIgnoreCase("JDO2"))
{
deletionPolicy = policy;
}
}
/**
* Accessor for the deletion policy.
* @return the deletion policy
* @since 1.1
*/
public String getDeletionPolicy()
{
return deletionPolicy;
}
/**
* Mutator for the identifier factory
* @param factory the identifier factory
*/
public synchronized void setIdentifierFactory(String factory)
{
assertConfigurable();
identifierFactory = factory;
}
/**
* Accessor for the identifier factory
* @return the identifier factory
*/
public String getIdentifierFactory()
{
return identifierFactory;
}
/**
* Mutator for the identifier case
* @param idCase the identifier case
*/
public synchronized void setIdentifierCase(String idCase)
{
assertConfigurable();
if (idCase.equalsIgnoreCase("UpperCase") || idCase.equalsIgnoreCase("LowerCase") || idCase.equalsIgnoreCase("PreserveCase"))
{
identifierCase = idCase;
}
}
/**
* Accessor for the identifier case
* @return the identifier case
*/
public String getIdentifierCase()
{
return identifierCase;
}
/**
* Mutator for the identifier word separator
* @param word the identifier word separator
*/
public synchronized void setIdentifierWordSeparator(String word)
{
assertConfigurable();
identifierWordSeparator = word;
}
/**
* Accessor for the identifier word separator
* @return the identifier word separator
*/
public String getIdentifierWordSeparator()
{
return identifierWordSeparator;
}
/**
* Mutator for the identifier table prefix
* @param prefix the identifier table prefix
*/
public synchronized void setIdentifierTablePrefix(String prefix)
{
assertConfigurable();
identifierTablePrefix = prefix;
}
/**
* Accessor for the identifier table prefix
* @return the identifier table prefix
*/
public String getIdentifierTablePrefix()
{
return identifierTablePrefix;
}
/**
* Mutator for the identifier table suffix
* @param suffix the identifier table suffix
*/
public synchronized void setIdentifierTableSuffix(String suffix)
{
assertConfigurable();
identifierTableSuffix = suffix;
}
/**
* Accessor for the identifier table suffix
* @return the identifier table suffix
*/
public String getIdentifierTableSuffix()
{
return identifierTableSuffix;
}
/**
* Set the default UniqueConstraintsMapInverse setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default UniqueConstraintsMapInverse setting.
*/
public synchronized void setUniqueConstraintsMapInverse(boolean flag)
{
assertConfigurable();
uniqueConstraintsMapInverse = flag;
}
/**
* Get the default UniqueConstraintsMapInverse setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default UniqueConstraintsMapInverse setting.
*/
public boolean getUniqueConstraintsMapInverse()
{
return uniqueConstraintsMapInverse;
}
/**
* Get the use update lock flag for fetches.
* @return the default useUpdateLock setting.
*/
public boolean getUseUpdateLock()
{
return useUpdateLock;
}
/**
* Set whether to use the update lock for fetches.
* @param flag the useUpdateLock setting.
*/
public synchronized void setUseUpdateLock(boolean flag)
{
assertConfigurable();
useUpdateLock = flag;
}
/**
* Accessor for the maximum number of retries for adding a class to the store manager.
* @return The max number of retries
* @since 1.1
*/
public int getDatastoreClassAdditionMaxRetries()
{
return datastoreClassAdditionMaxRetries;
}
/**
* Set the max number of times to retry adding a class to the store manager.
* @param max The max number of retries
* @since 1.1
*/
public void setDatastoreClassAdditionMaxRetries(int max)
{
this.datastoreClassAdditionMaxRetries = max;
}
/**
* Accessor for whether "persistence-by-reachability" is run at commit time.
* @return Whether to run PBR at commit time
*/
public boolean getPersistenceByReachabilityAtCommit()
{
return persistenceByReachabilityAtCommit;
}
/**
* Mutator for whether to run "persistence-by-reachability" at commit time.
* @param flag Whether to run PBR at commit time
*/
public synchronized void setPersistenceByReachabilityAtCommit(boolean flag)
{
assertConfigurable();
persistenceByReachabilityAtCommit = flag;
}
/**
* Accessor for the maximum fetch depth to use by default.
* @return Max fetch depth to use
*/
public int getMaxFetchDepth()
{
return maxFetchDepth;
}
/**
* Mutator for the default max fetch depth
* @param value Max fetch depth to use
*/
public synchronized void setMaxFetchDepth(int value)
{
assertConfigurable();
maxFetchDepth = value;
}
/**
* Accessor for the name of the class loader resolver.
* @return Name of the class loader resolver to use.
*/
public String getClassLoaderResolverName()
{
return classLoaderResolverName;
}
/**
* Mutator for the class loader resolver name to use.
* @param clrName Class Loader resolver name to use
*/
public synchronized void setClassLoaderResolverName(String clrName)
{
assertConfigurable();
classLoaderResolverName = clrName;
}
/**
* Accessor for the primary class loader.
* @return the primary class loader resolver.
*/
public ClassLoader getPrimaryClassLoader()
{
return primaryClassLoader;
}
/**
* Mutator for the primary class loader.
* @param clr primary Class Loader
*/
public synchronized void setPrimaryClassLoaderResolver(ClassLoader clr)
{
assertConfigurable();
primaryClassLoader = clr;
}
/**
* Accessor for the name of datastore identity class
* @return Name of the datastore identity class
*/
public String getDatastoreIdentityClassName()
{
return datastoreIdentityClassName;
}
/**
* Mutator for the name to use for datastore-identity
* @param name Datastore-identity class name
*/
public synchronized void setDatastoreIdentityClassName(String name)
{
assertConfigurable();
datastoreIdentityClassName = name;
}
/**
* Accessor for the name of the implementation creator.
* @return Name of the implementation creator to use.
*/
public String getImplementationCreatorName()
{
return implementationCreatorName;
}
/**
* Mutator for the implementation creator name to use.
* @param implCreatorName Name of implementation creator to use
*/
public synchronized void setImplementationCreatorName(String implCreatorName)
{
assertConfigurable();
implementationCreatorName = implCreatorName;
}
/**
* Accessor for the default inheritance strategy to use.
* @return the default inheritance strategy
* @since 1.1
*/
public String getDefaultInheritanceStrategy()
{
return defaultInheritanceStrategy;
}
/**
* Mutator for the default inheritance strategy.
* @param strategy the default inheritance strategy
* @since 1.1
*/
public synchronized void setDefaultInheritanceStrategy(String strategy)
{
assertConfigurable();
if (strategy == null)
{
return;
}
else if (!strategy.equalsIgnoreCase("JDO2") && !strategy.equalsIgnoreCase("JPOX"))
{
// Illegal value
return;
}
defaultInheritanceStrategy = strategy;
}
/**
* Set the default AutoCreateSchema setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default AutoCreateSchema setting.
*/
public synchronized void setAutoCreateSchema(boolean flag)
{
assertConfigurable();
if (flag)
{
// This flag is a shortcut to set the tables and constraints
setAutoCreateTables(true);
setAutoCreateConstraints(true);
}
if ((readOnlyDatastore || fixedDatastore) && flag)
{
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008011","autoCreateSchema"));
}
}
/**
* Get the default AutoCreateSchema setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default AutoCreateSchema setting.
*/
public boolean getAutoCreateSchema()
{
return (autoCreateTables && autoCreateConstraints);
}
/**
* Set the default AutoCreateTables setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default AutoCreateTables setting.
*/
public synchronized void setAutoCreateTables(boolean flag)
{
assertConfigurable();
autoCreateTables = flag;
if ((readOnlyDatastore || fixedDatastore) && flag)
{
autoCreateTables = false;
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008011","autoCreateTables"));
}
}
/**
* Get the default AutoCreateTables setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default AutoCreateTables setting.
*/
public boolean getAutoCreateTables()
{
return autoCreateTables;
}
/**
* Set the default AutoCreateColumns setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default AutoCreateColumns setting.
* @since 1.1
*/
public synchronized void setAutoCreateColumns(boolean flag)
{
assertConfigurable();
autoCreateColumns = flag;
if ((readOnlyDatastore || fixedDatastore) && flag)
{
autoCreateTables = false;
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008011","autoCreateColumns"));
}
}
/**
* Get the default AutoCreateColumns setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default AutoCreateColumns setting.
* @since 1.1
*/
public boolean getAutoCreateColumns()
{
return autoCreateColumns;
}
/**
* Set the default AutoCreateConstraints setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default AutoCreateConstraints setting.
*/
public synchronized void setAutoCreateConstraints(boolean flag)
{
assertConfigurable();
autoCreateConstraints = flag;
if ((readOnlyDatastore || fixedDatastore) && flag)
{
autoCreateConstraints = false;
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008011","autoCreateConstraints"));
}
}
/**
* Get the default AutoCreateConstraints setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default AutoCreateConstraints setting.
*/
public boolean getAutoCreateConstraints()
{
return autoCreateConstraints;
}
/**
* Set the default AutoCreateWarnOnError setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param flag the default AutoCreateWarnOnError setting.
*/
public synchronized void setAutoCreateWarnOnError(boolean flag)
{
assertConfigurable();
autoCreateWarnOnError = flag;
}
/**
* Get the default AutoCreateWarnOnError setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default AutoCreateWarnOnError setting.
*/
public boolean getAutoCreateWarnOnError()
{
return autoCreateWarnOnError;
}
/**
* Accessor for the Auto-Start Mechanism for management of which classes
* are supported in this data store.
* @return the Auto-Start Mechanism setting.
*/
public String getAutoStartMechanism()
{
return autoStartMechanism;
}
/**
* Set the AutoStartMechanism setting to this persistence factory.
* @param mechanism The autostart mechanism plugin name
*/
public synchronized void setAutoStartMechanism(String mechanism)
{
assertConfigurable();
autoStartMechanism = mechanism;
}
/**
* Accessor for the name of the XML file to use when using the XML AutoStarter
* @return The XML file name
*/
public String getAutoStartMechanismXmlFile()
{
return autoStartMechanismXmlFile;
}
/**
* Mutator for the XML filename when using the XML AutoStarter.
* @param xmlFile Name of the XML file
*/
public synchronized void setAutoStartMechanismXmlFile(String xmlFile)
{
autoStartMechanismXmlFile = xmlFile;
}
/**
* Accessor for the Auto-Start Mechanism Mode for how the auto start
* mechanism operates. Currently supports 3 possible values for this
* parameter "Checked", "Ignored", and "Quiet" (default).
* @return the Auto-Start Mechanism Mode setting.
*/
public String getAutoStartMechanismMode()
{
if (autoStartMechanismMode != null &&
autoStartMechanismMode.equalsIgnoreCase(AutoStartMechanism.MODE_CHECKED))
{
return AutoStartMechanism.MODE_CHECKED;
}
else if (autoStartMechanismMode != null &&
autoStartMechanismMode.equalsIgnoreCase(AutoStartMechanism.MODE_IGNORED))
{
return AutoStartMechanism.MODE_IGNORED;
}
else // Default
{
return AutoStartMechanism.MODE_QUIET;
}
}
/**
* Set the default AutoStartMechanismMode setting for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param mode Checked = raise exceptions on errors
* Ignored = proceed without corrections
* Quiet = correct errors and proceed (default)
*/
public synchronized void setAutoStartMechanismMode(String mode)
{
assertConfigurable();
if (!mode.equals(AutoStartMechanism.MODE_CHECKED) &&
!mode.equals(AutoStartMechanism.MODE_IGNORED) &&
!mode.equals(AutoStartMechanism.MODE_QUIET))
{
throw new IllegalArgumentException(LOCALISER.msg("008012", AUTO_START_MECHANISM_MODE_PROPERTY, mode));
}
autoStartMechanismMode = mode;
}
/**
* Accessor for the names of the classes to be loaded at startup.
* @return Names of classes to load
* @since 1.1
*/
public String getAutoStartClassNames()
{
return autoStartClassNames;
}
/**
* Mutator for the names of classes to load at startup.
* @param classNames Name of the classes to load.
* @since 1.1
*/
public synchronized void setAutoStartClassNames(String classNames)
{
autoStartClassNames = classNames;
}
/**
* Get the default transaction isolation level for all
* <tt>PoidGenerator</tt> instances.
*
* @return the default transaction isolation level for
* <tt>PoidGenerator</tt> instances.
*/
public int getPoidTransactionIsolationLevel()
{
return poidIsolationLevel;
}
/**
* Set the default transaction isolation level for all
* <tt>PoidGenerator</tt> instances.
* @param isolationLevelName
* One of the values "read uncommitted", "read committed", "repeatable
* read", or "serializable". The name is case-insensitive, and spaces
* and underscores are equivalent.
*/
protected synchronized void setPoidTransactionIsolation(String isolationLevelName)
{
String iln = isolationLevelName.trim().replace(' ', '_').toUpperCase();
poidIsolationLevel = TransactionUtils.getTransactionIsolationLevelForName(iln);
if (poidIsolationLevel < 0)
{
throw new IllegalArgumentException(LOCALISER.msg("008012", POID_TRANSACTION_ISOLATION_PROPERTY, isolationLevelName));
}
}
/**
* Set the default transaction isolation level for all
* <tt>PoidGenerator</tt> instances.
* @param isolationLevel the default transaction isolation level.
*/
public synchronized void setPoidTransactionIsolation(int isolationLevel)
{
switch (isolationLevel)
{
case UserTransaction.TRANSACTION_READ_UNCOMMITTED:
case UserTransaction.TRANSACTION_READ_COMMITTED:
case UserTransaction.TRANSACTION_REPEATABLE_READ:
case UserTransaction.TRANSACTION_SERIALIZABLE:
break;
default:
throw new IllegalArgumentException(LOCALISER.msg("008012", POID_TRANSACTION_ISOLATION_PROPERTY, "" + isolationLevel));
}
this.poidIsolationLevel = isolationLevel;
}
/**
* Whether to use the PM connection or open a new connection
* @return Returns the poidTransactionAttribute.
*/
public String getPoidTransactionAttribute()
{
return poidTransactionAttribute;
}
/**
* Set whether to use the PM connection or open a new connection
* @param poidTransactionAttribute The poidTransactionAttribute to set.
*/
public void setPoidTransactionAttribute(String poidTransactionAttribute)
{
if (poidTransactionAttribute == null)
{
throw new IllegalArgumentException(LOCALISER.msg("008012",
"org.jpox.poid.transactionAttribute", poidTransactionAttribute));
}
if (!poidTransactionAttribute.equals("New") &&
!poidTransactionAttribute.equals("UsePM"))
{
throw new IllegalArgumentException(LOCALISER.msg("008012",
"org.jpox.poid.transactionAttribute", poidTransactionAttribute));
}
this.poidTransactionAttribute = poidTransactionAttribute;
}
/**
* Accessor for whether to flush before executing queries.
* @return Whether to flush before execution
* @since 1.2
*/
public boolean getQueryFlushBeforeExecution()
{
return queryFlushBeforeExecution;
}
/**
* Set whether to flush before executing queries
* @param flush Whether to flush before executing queries
* @since 1.2
*/
public void setQueryFlushBeforeExecution(boolean flush)
{
queryFlushBeforeExecution = flush;
}
/**
* Accessor for whether to use the FetchPlan in queries.
* @return Whether to use the FetchPlan in queries
* @since 1.1
*/
public boolean getQueryUseFetchPlan()
{
return queryUseFetchPlan;
}
/**
* Set whether to use the FetchPlan in queries
* @param useFetchPlan Whether to use the FetchPlan in queries
* @since 1.1
*/
public void setQueryUseFetchPlan(boolean useFetchPlan)
{
queryUseFetchPlan = useFetchPlan;
}
/**
* Whether to allow running any SQL statement in SQL queries.
* @return true if allowed to execute any SQL stament in SQL queries
* @since 1.1
*/
public boolean isQueryAllowAllSQLStatements()
{
return queryAllowAllSQLStatements;
}
/**
* Whether to allow running any SQL statement in SQL queries.
* @param allow true if allowed to execute any SQL stament in SQL queries
* @since 1.1
*/
public void setQueryAllowAllSQLStatements(boolean allow)
{
this.queryAllowAllSQLStatements = allow;
}
/**
* Accessor for the timeout for queries.
* @return The timeout
* @since 1.1
*/
public int getQueryTimeout()
{
return queryTimeout;
}
/**
* Set the timeout for queries
* @param timeout The timeout to use
* @since 1.1
*/
public void setQueryTimeout(int timeout)
{
this.queryTimeout = timeout;
}
/**
* Accessor for the fetch direction to use for ResultSet's.
* @return The fetch direction.
* @since 1.1
*/
public String getQueryFetchDirection()
{
return queryFetchDirection;
}
/**
* Set the fetch direction to use for ResultSet's.
* @param dir The fetch direction to use
* @since 1.1
*/
public void setQueryFetchDirection(String dir)
{
if (dir == null ||
!dir.equals("forward") ||
!dir.equals("reverse") ||
!dir.equals("unknown"))
{
return;
}
queryFetchDirection = dir;
}
/**
* Accessor for the type of ResultSet
* @return The ResultSet type.
* @since 1.1
*/
public String getQueryResultSetType()
{
return queryResultSetType;
}
/**
* Set the type of the ResultSet
* @param type The ResultSet type
* @since 1.1
*/
public void setQueryResultSetType(String type)
{
if (type == null ||
(!type.equals("forward-only") &&
!type.equals("scroll-sensitive") &&
!type.equals("scroll-insensitive")))
{
return;
}
queryResultSetType = type;
}
/**
* Accessor for the concurrency of ResultSet
* @return The ResultSet concurrency.
* @since 1.1
*/
public String getQueryResultSetConcurrency()
{
return queryResultSetConcurrency;
}
/**
* Set the concurrency of the ResultSet
* @param concur The ResultSet concurrency
* @since 1.1
*/
public void setQueryResultSetConcurrency(String concur)
{
if (concur == null ||
(!concur.equals("read-only") &&
!concur.equals("updateable")))
{
return;
}
queryResultSetConcurrency = concur;
}
/**
* Accessor for join type to use with queries.
* @return Join type for queries
* @since 1.2
*/
public String getQueryJoinType()
{
return queryJoinType;
}
/**
* Set the join type to use on queries.
* @param type Join type to use on queries
* @since 1.2
*/
public void setQueryJoinType(String type)
{
if (type.toUpperCase().equals("INNER") || type.toUpperCase().equals("LEFT OUTER"))
{
queryJoinType = type.toUpperCase();
}
}
/**
* Accessor for whether to apply constraints to exists inner expression.
* @return Whether to apply constraints to exists inner expression
* @since 1.2
*/
public boolean getQueryExistsIncludesConstraints()
{
return queryExistsIncludesConstraints;
}
/**
* Set whether to apply constraints to exists inner expression.
* @param includes Whether to apply constraints to exists inner expression.
* @since 1.2
*/
public void setQueryExistsIncludesConstraints(boolean includes)
{
queryExistsIncludesConstraints = includes;
}
/**
* Accessor for whether to always use EXISTS with contains().
* @return Whether to always use EXISTS with contains()
* @since 1.2
*/
public boolean getQueryContainsUsesExistsAlways()
{
return queryContainsUsesExistsAlways;
}
/**
* Set whether to always use EXISTS with any contains().
* @param always Whether to always use EXISTS with contains()
* @since 1.2
*/
public void setQueryContainsUsesExistsAlways(boolean always)
{
queryContainsUsesExistsAlways = always;
}
/**
* Accessor for the default max length for strings.
* @return The default length for strings
*/
public int getStringDefaultLength()
{
return stringDefaultLength;
}
/**
* Set the default length for strings.
* @param len Default length for strings
*/
public void setStringDefaultLength(int len)
{
this.stringDefaultLength = len;
}
/**
* Accessor for the action when persisting a string that exceeds the datastore column length.
* @return Action when persisting String longer than the datastore can handle
*/
public String getStringLengthExceededAction()
{
return stringLengthExceededAction;
}
/**
* Set the action when persisting a string too long for the datastore.
* Valid values are EXCEPTION and TRUNCATE.
* @param action action when persisting a string too long for the datastore.
*/
public void setStringLengthExceededAction(String action)
{
if (action == null)
{
return;
}
if (action.equalsIgnoreCase("EXCEPTION") || action.equalsIgnoreCase("TRUNCATE"))
{
this.stringLengthExceededAction = action.toUpperCase();
}
}
/**
* Accessor for whether to persist an empty string as null in the datastore (RDBMS).
* @return Whether to persist an empty string as null
*/
public boolean getPersistEmptyStringAsNull()
{
return persistEmptyStringAsNull;
}
/**
* Mutator for whether to persist an empty string as null in the datastore (RDBMS).
* @param flag whether an empty string should be treated as null
*/
public void setPersistEmptyStringAsNull(boolean flag)
{
persistEmptyStringAsNull = flag;
}
/**
* Accessor for whether to have a discriminator column on all subclass tables.
* This is for backwards compatibility only and will be removed later.
* TODO Remove this when people have changed over
* @return Whether to persist an empty string as null
*/
public boolean getDiscriminatorPerSubclassTable()
{
return discriminatorPerSubclassTable;
}
/**
* Mutator for whether to have a discriminator column added to all subclass tables.
* This is for backwards compatibility only and will be removed later.
* TODO Remove this when people have changed over
* @param flag whether to have discrim per subclass table
*/
public void setDiscriminatorPerSubclassTable(boolean flag)
{
discriminatorPerSubclassTable = flag;
}
/**
* Accessor for the NLS sort order for Oracle.
* @return The NLS sort order for Oracle.
*/
public String getOracleNlsSortOrder()
{
return oracleNlsSortOrder;
}
/**
* Set the NLS sort order for oracle.
* @param order NLS sort order for oracle.
*/
public void setOracleNlsSortOrder(String order)
{
this.oracleNlsSortOrder = order;
}
/**
* Accessor for whether to cache collections.
* @return whether to cache collections.
*/
public boolean getCacheCollections()
{
return cacheCollections;
}
/**
* Set whether to cache collections for this persistence factory.
* @param cache Whether to cache collections.
*/
public synchronized void setCacheCollections(boolean cache)
{
assertConfigurable();
cacheCollections = cache;
}
/**
* Accessor for whether to lazy load any cached collections.
* @return whether to lazy load any cache collections.
*/
public Boolean getCacheCollectionsLazy()
{
return cacheCollectionsLazy;
}
/**
* Set whether to lazy load any cached collections for this persistence factory.
* @param lazy Whether to lazy load any cache collections.
*/
public synchronized void setCacheCollectionsLazy(Boolean lazy)
{
assertConfigurable();
if (lazy != null)
{
cacheCollectionsLazy = lazy;
}
}
/**
* Accessor for the Level 1 Cache Type
* @return the Level 1 Cache Type
* @since 1.1
*/
public String getCacheLevel1Type()
{
return cacheLevel1Type;
}
/**
* Set the default Level 1 Cache Type for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param type the Level 1 Cache Type
* @since 1.1
*/
public synchronized void setCacheLevel1Type(String type)
{
assertConfigurable();
cacheLevel1Type = type;
}
/**
* Accessor for whether to use a level 2 Cache.
* @return whether to use a level 2 Cache.
* @since 1.1
*/
public boolean getCacheLevel2()
{
return cacheLevel2;
}
/**
* Set whether to use a Level 2 Cache for this persistence factory.
* @param cache Whether to use a level 2 Cache
* @since 1.1
*/
public synchronized void setCacheLevel2(boolean cache)
{
assertConfigurable();
cacheLevel2 = cache;
}
/**
* Accessor for the Level 2 Cache Type
* @return the Level 2 Cache Type
* @since 1.1
*/
public String getCacheLevel2Type()
{
return cacheLevel2Type;
}
/**
* Set the default Level 2 Cache Type for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param type the Level 2 Cache Type
* @since 1.1
*/
public synchronized void setCacheLevel2Type(String type)
{
assertConfigurable();
cacheLevel2Type = type;
}
/**
* Accessor for the Level 2 Cache Name
* @return the Level 2 Cache Name
* @since 1.1
*/
public String getCacheLevel2CacheName()
{
return cacheLevel2CacheName;
}
/**
* Set the default Level 2 Cache Name for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param name Name of the cache
* @since 1.1
*/
public synchronized void setCacheLevel2CacheName(String name)
{
assertConfigurable();
cacheLevel2CacheName = name;
}
/**
* Accessor for the JDO Level 2 Configuration File
* @return the JDO Level 2 Configuration File
* @since 1.1
*/
public String getCacheLevel2ConfigurationFile()
{
return cacheLevel2ConfigurationFile;
}
/**
* Set the default Level 2 Configuration File for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param confFile The File Name of the configuration file
* @since 1.1
*/
public synchronized void setCacheLevel2ConfigurationFile(String confFile)
{
assertConfigurable();
cacheLevel2ConfigurationFile = confFile;
}
/**
* Set the default transaction isolation level for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param isolationLevelName
* One of the values "none", "read uncommitted", "read committed", "repeatable
* read", or "serializable". The name is case-insensitive, and spaces
* and underscores are equivalent.
*/
protected synchronized void setTransactionIsolation(String isolationLevelName)
{
assertConfigurable();
String iln = isolationLevelName.trim().replace(' ', '_').toUpperCase();
isolationLevel = TransactionUtils.getTransactionIsolationLevelForName(iln);
if (isolationLevel < 0)
{
throw new IllegalArgumentException(LOCALISER.msg("008012", TRANSACTION_ISOLATION_PROPERTY, isolationLevelName));
}
}
/**
* Set the default transaction isolation level for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @param isolationLevel the default transaction isolation level.
*/
public synchronized void setTransactionIsolation(int isolationLevel)
{
assertConfigurable();
switch (isolationLevel)
{
case UserTransaction.TRANSACTION_NONE:
case UserTransaction.TRANSACTION_READ_UNCOMMITTED:
case UserTransaction.TRANSACTION_READ_COMMITTED:
case UserTransaction.TRANSACTION_REPEATABLE_READ:
case UserTransaction.TRANSACTION_SERIALIZABLE:
break;
default:
throw new IllegalArgumentException(LOCALISER.msg("008012", TRANSACTION_ISOLATION_PROPERTY, "" + isolationLevel));
}
this.isolationLevel = isolationLevel;
}
/**
* Get the default transaction isolation level for all
* <tt>PersistenceManager</tt> instances obtained from this factory.
* @return the default transaction isolation level.
*/
public int getTransactionIsolation()
{
return isolationLevel;
}
/**
* Mutator for the JTA Locator to use when using JTA transactions.
* @param locator Name of the locator. Should correspond to a locator plugin alias
*/
protected synchronized void setJtaLocator(String locator)
{
assertConfigurable();
jtaLocator = locator;
}
/**
* Accessor for the JTA locator to use (if any).
* @return the alias for the JTA locator
*/
public String getJtaLocator()
{
return jtaLocator;
}
/**
* Mutator for the JNDI location to use (if any) to get the JTA txn manager.
* @param jndi JNDI location to find the JTA txn manager
*/
protected synchronized void setJtaJndiLocation(String jndi)
{
assertConfigurable();
jtaJndiLocation = jndi;
}
/**
* Accessor for the JNDI location to use (if any) to get the JTA txn manager.
* @return the JNDI location to find the JTA transaction manager.
*/
public String getJtaJndiLocation()
{
return jtaJndiLocation;
}
/**
* Whether with datastore transactions we delay operations until commit.
* @param flag Whether we should delay all datastore ops til commit with datastore txns
*/
public synchronized void setDatastoreTransactionsDelayOperations(boolean flag)
{
assertConfigurable();
datastoreTransactionDelayOperations = flag;
}
/**
* Whether with datastore transactions we delay operations until commit.
* @return Whether we should delay all datastore ops til commit with datastore txns
*/
public boolean getDatastoreTransactionsDelayOperations()
{
return datastoreTransactionDelayOperations;
}
/**
* Mutator for the limit of number of dirty objects before a flush happens with
* datastore transactions.
* @param limit Limit on number of dirty objects before a flush happens with datastore txns
*/
protected synchronized void setDatastoreTransactionFlushLimit(int limit)
{
assertConfigurable();
datastoreTransactionFlushLimit = limit;
}
/**
* Accessor for the limit on number of dirty objects before a flush happens with
* datastore transactions.
* @return Number of dirty objects before a flush happens with datastore transactions
*/
public int getDatastoreTransactionFlushLimit()
{
return datastoreTransactionFlushLimit;
}
/**
* Set the DB4O Output File name.
* @param file name of the DB4O Output file
*/
public synchronized void setDb4oOutputFile(String file)
{
assertConfigurable();
db4oOutputFile = file;
}
/**
* Get the name of the DB4O Output File
* @return DB4O Output File
*/
public String getDb4oOutputFile()
{
return db4oOutputFile;
}
/**
* Set whether to flush DB4O file buffers at commit
* @param flush Whether to flush file buffers at commit with DB4O
*/
public synchronized void setDb4oFlushFileBuffers(boolean flush)
{
assertConfigurable();
db4oFlushFileBuffers = flush;
}
/**
* Accessor for whether to flush DB4O file buffers on commit.
* @return Whether to flush file buffers
*/
public boolean getDb4oFlushFileBuffers()
{
return db4oFlushFileBuffers;
}
/**
* Set whether to generate UUIDs.
* @param gen Whether to generate UUIDs
*/
public synchronized void setDb4oGenerateUUIDs(boolean gen)
{
assertConfigurable();
db4oGenerateUUIDs = gen;
}
/**
* Accessor for whether to generate UUIDs.
* @return Whether to generate UUIDs
*/
public boolean getDb4oGenerateUUIDs()
{
return db4oGenerateUUIDs;
}
/**
* Accessor for the suffix for table identifiers
* @param value the suffix for table identifiers
*/
public synchronized void setPropertiesFile(String value)
{
assertConfigurable();
if (value == null)
{
return;
}
if (this.propertiesFileName != null)
{
// Already have a properties file read in
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008013",
this.propertiesFileName, value));
return;
}
Properties props = new Properties();
//try to load the persistence factory properties file
File file = new File(value);
if (file.exists())
{
this.propertiesFileName = value;
try
{
InputStream is = new FileInputStream(file);
props.load(is);
is.close();
}
catch (FileNotFoundException e)
{
this.propertiesFileName = null;
throw new JPOXUserException(LOCALISER.msg("008014", value), e).setFatal();
}
catch (IOException e)
{
this.propertiesFileName = null;
throw new JPOXUserException(LOCALISER.msg("008014", value), e).setFatal();
}
}
else
{
// Try to load it as a resource in the CLASSPATH
try
{
InputStream is = PersistenceConfiguration.class.getClassLoader().getResourceAsStream(value);
props.load(is);
is.close();
this.propertiesFileName = value;
}
catch (Exception e)
{
// Still not loadable so throw exception
throw new JPOXUserException(LOCALISER.msg("008014", value), e).setFatal();
}
}
setOptions(props);
}
/**
* Accessor for the JDO MetaData file extension.
* @return Returns the JDO metadata File Extension.
*/
public String getJdoMetaDataFileExtension()
{
return jdoMetaDataFileExtension;
}
/**
* Mutator for the JDO MetaData file extension.
* @param metadataFileExtension The JDO metadata File Extension to set.
*/
public void setJdoMetaDataFileExtension(String metadataFileExtension)
{
this.jdoMetaDataFileExtension = metadataFileExtension;
}
/**
* Accessor for the ORM MetaData file extension.
* @return Returns the ORM metadata File Extension.
*/
public String getOrmMetaDataFileExtension()
{
return ormMetaDataFileExtension;
}
/**
* Mutator for the ORM MetaData file extension.
* @param metadataFileExtension The ORM metadata File Extension to set.
*/
public void setOrmMetaDataFileExtension(String metadataFileExtension)
{
this.ormMetaDataFileExtension = metadataFileExtension;
}
/**
* Accessor for the JDO Query MetaData file extension.
* @return Returns the JDO Query metadata File Extension.
*/
public String getJdoqueryMetaDataFileExtension()
{
return jdoqueryMetaDataFileExtension;
}
/**
* Mutator for the JDO Query MetaData file extension.
* @param metadataFileExtension The JDO Query metadata File Extension to set.
*/
public void setJdoqueryMetaDataFileExtension(String metadataFileExtension)
{
this.jdoqueryMetaDataFileExtension = metadataFileExtension;
}
/**
* Accessor for whether to validate the metadata.
* @return Returns whether to validate the metadata
*/
public boolean getMetaDataValidate()
{
return metadataValidate;
}
/**
* Mutator for whether to validate the metadata
* @param validate Whether to validate the metadata
*/
public void setMetaDataValidate(boolean validate)
{
this.metadataValidate = validate;
}
/**
* Accessor for the class name of the annotations manager.
* @return Class name for the annotations manager
*/
public String getMetaDataAnnotationsManager()
{
return metadataAnnotationsManager;
}
/**
* Mutator for the metadata annotations manager
* @param mgr Name of the annotations manager
*/
public void setMetaDataAnnotationsManager(String mgr)
{
this.metadataAnnotationsManager = mgr;
}
/**
* Method to return whether we include codes in any output messages.
* @return Whether to includes codes in messages
*/
public Boolean getMessagesIncludeCodes()
{
return (messagesIncludeCodes ? Boolean.TRUE : Boolean.FALSE);
}
/**
* Mutator for whether to includes codes in messages.
* @param include Whether to include codes in messages
*/
public void setMessagesIncludeCodes(Boolean include)
{
if (include != null)
{
this.messagesIncludeCodes = include.booleanValue();
// This sets it globally, even if only for this PMF. Localiser needs changes to do it per PMF
Localiser.setDisplayCodesInMessages(this.messagesIncludeCodes);
}
}
/**
* Mutator for the {@link PluginRegistry} class name. If one is provided, it will be used as registry for plug-ins
* @return the fully qualified class {@link PluginRegistry}
*/
public String getPluginRegistryClassName()
{
return pluginRegistryClassName;
}
/**
* Mutator for the {@link PluginRegistry} class name. If one is provided, it will be used as registry for plug-ins
* @param pluginRegistryClassName the fully qualified class {@link PluginRegistry}
*/
public void setPluginRegistryClassName(String pluginRegistryClassName)
{
this.pluginRegistryClassName = pluginRegistryClassName;
}
/**
* Mutator for what check the plugin registry should make on duplicate bundles.
* Typically only applies to the non-managed registry.
* @return What check the registry should perform on duplicate bundles
*/
public String getPluginRegistryBundleCheck()
{
return pluginRegistryBundleCheck;
}
/**
* Mutator for what check the plugin registry should perform on dup bundles.
* Can be "EXCEPTION", "LOG", or "NONE".
* @param check the check to perform
*/
public void setPluginRegistryBundleCheck(String check)
{
if (StringUtils.isWhitespace(check) ||
(!check.equalsIgnoreCase("EXCEPTION") && !check.equalsIgnoreCase("LOG") && !check.equalsIgnoreCase("NONE")))
{
return;
}
this.pluginRegistryBundleCheck = check.toUpperCase();
}
/**
* Asserts that a change to a configuration property is allowed.
*/
protected void assertConfigurable()
{
if (!configurable)
{
throw new JDOUserException(LOCALISER.msg("008016"));
}
}
/**
* Initialize the PROPERTY_SETTERS Map.
* @return The PROPERTY_SETTERS Map.
*/
protected Map initPropertySetters()
{
final Map map = new HashMap();
// JDO Standard properties
map.put(PersistenceConfiguration.JDO_OPTIMISTIC_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setOptimistic(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_RETAINVALUES_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setRetainValues(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_RESTOREVALUES_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setRestoreValues(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_IGNORECACHE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setIgnoreCache(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_DETACHALLONCOMMIT_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDetachAllOnCommit(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_COPYONATTACH_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCopyOnAttach(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_NONTRANSACTIONAL_READ_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setNontransactionalRead(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_NONTRANSACTIONAL_WRITE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setNontransactionalWrite(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_MULTITHREADED_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setMultithreaded(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.JDO_DATASTORE_USERNAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionUserName(s);
}
});
map.put(PersistenceConfiguration.JDO_DATASTORE_PASSWORD_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionPassword(s);
}
});
map.put(PersistenceConfiguration.JDO_DATASTORE_DRIVERNAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionDriverName(s);
}
});
map.put(PersistenceConfiguration.JDO_DATASTORE_URL_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionURL(s);
}
});
map.put(PersistenceConfiguration.JDO_CONNECTION_FACTORY_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionFactoryName(s);
}
});
map.put(PersistenceConfiguration.JDO_CONNECTION_FACTORY2_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionFactory2Name(s);
}
});
map.put(PersistenceConfiguration.JDO_CONNECTION_FACTORY_PROPERTY, new ObjectPropertySetter()
{
public void set(PersistenceConfiguration configuration, Object obj)
{
configuration.setConnectionFactory(obj);
}
});
map.put(PersistenceConfiguration.JDO_CONNECTION_FACTORY2_PROPERTY, new ObjectPropertySetter()
{
public void set(PersistenceConfiguration configuration, Object obj)
{
configuration.setConnectionFactory2(obj);
}
});
map.put(PersistenceConfiguration.JDO_MAPPING_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setMapping(s);
}
});
map.put(PersistenceConfiguration.JDO_MAPPING_CATALOG_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCatalog(s);
}
});
map.put(PersistenceConfiguration.JDO_MAPPING_SCHEMA_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setSchema(s);
}
});
map.put(PersistenceConfiguration.JDO_TRANSACTION_TYPE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setTransactionType(s);
}
});
map.put(PersistenceConfiguration.JDO_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setName(s);
}
});
map.put(PersistenceConfiguration.JDO_PERSISTENCE_UNIT_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPersistenceUnitName(s);
}
});
map.put(PersistenceConfiguration.JDO_SERVER_TIMEZONE_ID_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setServerTimeZoneID(s);
}
});
map.put(PersistenceConfiguration.JPA_TRANSACTION_TYPE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setTransactionType(s);
}
});
map.put(PersistenceConfiguration.JPA_ONE_TO_MANY_UNI_FK_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setJpaOneToManyUniFkRelations(Boolean.valueOf(s).booleanValue());
}
});
// JPOX Extension properties
map.put(PersistenceConfiguration.STORE_MANAGER_TYPE, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setStoreManagerType(s);
}
});
map.put(PersistenceConfiguration.MANAGED_RUNTIME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setManagedRuntime(Boolean.valueOf(s));
}
});
map.put(PersistenceConfiguration.PERSISTENCE_API_NAME, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPersistenceApiName(s);
}
});
map.put(PersistenceConfiguration.MANAGE_RELATIONSHIPS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setManageRelationships(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.MANAGE_RELATIONSHIPS_CHECKS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setManageRelationshipsChecks(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.FIND_OBJECT_CHECK_INHERITANCE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setFindObjectCheckInheritance(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.ATTACH_SAME_DATASTORE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAttachSameDatastore(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.DETACH_ON_CLOSE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDetachOnClose(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.DATASTORE_ADAPTER_CLASSNAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDatastoreAdapterClassName(s);
}
});
map.put(PersistenceConfiguration.STATEMENT_BATCH_LIMIT_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
int len = (new Integer(s)).intValue();
configuration.setStatementBatchLimit(len);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
map.put(PersistenceConfiguration.CHECK_EXIST_TABLES_VIEWS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCheckExistTablesOrViews(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.VALIDATE_TABLES_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setValidateTables(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.VALIDATE_COLUMNS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setValidateColumns(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.ADD_UNIQUE_CONSTRAINT_MAP_INVERSE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setUniqueConstraintsMapInverse(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.VALIDATE_CONSTRAINTS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setValidateConstraints(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.AUTO_CREATE_SCHEMA_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoCreateSchema(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.AUTO_CREATE_TABLES_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoCreateTables(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.AUTO_CREATE_COLUMNS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoCreateColumns(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.AUTO_CREATE_CONSTRAINTS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoCreateConstraints(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.AUTO_CREATE_WARN_ON_ERROR_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoCreateWarnOnError(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.INITIALIZE_COLUMN_INFO_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setInitializeColumnInfo(s);
}
});
map.put(PersistenceConfiguration.AUTO_START_MECHANISM_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoStartMechanism(s);
}
});
map.put(PersistenceConfiguration.AUTO_START_MECHANISM_XML_FILE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoStartMechanismXmlFile(s);
}
});
map.put(PersistenceConfiguration.AUTO_START_MECHANISM_MODE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoStartMechanismMode(s);
}
});
map.put(PersistenceConfiguration.AUTO_START_CLASS_NAMES_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setAutoStartClassNames(s);
}
});
map.put(PersistenceConfiguration.READ_ONLY_DATASTORE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setReadOnlyDatastore(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.READ_ONLY_DATASTORE_ACTION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setReadOnlyDatastoreAction(s);
}
});
map.put(PersistenceConfiguration.FIXED_DATASTORE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setFixedDatastore(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.RDBMS_CONSTRAINT_CREATE_MODE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setRDBMSConstraintCreateMode(s);
}
});
map.put(PersistenceConfiguration.DELETION_POLICY_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDeletionPolicy(s);
}
});
map.put(PersistenceConfiguration.IDENTIFIER_FACTORY_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setIdentifierFactory(s);
}
});
map.put(PersistenceConfiguration.IDENTIFIER_CASE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setIdentifierCase(s);
}
});
map.put(PersistenceConfiguration.IDENTIFIER_WORD_SEPARATOR_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setIdentifierWordSeparator(s);
}
});
map.put(PersistenceConfiguration.IDENTIFIER_TABLE_PREFIX_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setIdentifierTablePrefix(s);
}
});
map.put(PersistenceConfiguration.IDENTIFIER_TABLE_SUFFIX_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setIdentifierTableSuffix(s);
}
});
map.put(PersistenceConfiguration.CONNECTION_POOLING_TYPE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionPoolingType(s);
}
});
map.put(PersistenceConfiguration.CONNECTION_POOLING_CONFIGURATION_FILE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionPoolingConfigurationFile(s);
}
});
map.put(PersistenceConfiguration.DEFAULT_INHERITANCE_STRATEGY_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDefaultInheritanceStrategy(s);
}
});
map.put(PersistenceConfiguration.USE_UPDATE_LOCK_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setUseUpdateLock(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.DATASTORE_CLASS_ADDITION_MAX_RETRIES_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
int len = (new Integer(s)).intValue();
configuration.setDatastoreClassAdditionMaxRetries(len);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
map.put(PersistenceConfiguration.TRANSACTION_ISOLATION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setTransactionIsolation(s);
}
});
map.put(PersistenceConfiguration.JTA_LOCATOR_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setJtaLocator(s);
}
});
map.put(PersistenceConfiguration.JTA_JNDI_LOCATION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setJtaJndiLocation(s);
}
});
map.put(PersistenceConfiguration.DATASTORE_TXN_DELAY_OPERATIONS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDatastoreTransactionsDelayOperations(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.DATASTORE_TXN_FLUSH_LIMIT_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
int len = (new Integer(s)).intValue();
configuration.setDatastoreTransactionFlushLimit(len);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
map.put(PersistenceConfiguration.POID_TRANSACTION_ATTRIBUTE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPoidTransactionAttribute(s);
}
});
map.put(PersistenceConfiguration.POID_TRANSACTION_ISOLATION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPoidTransactionIsolation(s);
}
});
map.put(PersistenceConfiguration.PERSISTENCE_BY_REACHABILITY_AT_COMMIT, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPersistenceByReachabilityAtCommit(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.MAX_FETCH_DEPTH_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
int len = (new Integer(s)).intValue();
configuration.setMaxFetchDepth(len);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
map.put(PersistenceConfiguration.CLASS_LOADER_RESOLVER_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setClassLoaderResolverName(s);
}
});
map.put(PersistenceConfiguration.IMPLEMENTATION_CREATOR_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setImplementationCreatorName(s);
}
});
map.put(PersistenceConfiguration.DATASTORE_IDENTITY_CLASS_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDatastoreIdentityClassName(s);
}
});
// Query
map.put(PersistenceConfiguration.QUERY_FLUSH_BEFORE_EXECUTION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
boolean use = (new Boolean(s)).booleanValue();
configuration.setQueryFlushBeforeExecution(use);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
map.put(PersistenceConfiguration.QUERY_USE_FETCH_PLAN_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
boolean use = (new Boolean(s)).booleanValue();
configuration.setQueryUseFetchPlan(use);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
map.put(PersistenceConfiguration.QUERY_TIMEOUT_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
int len = (new Integer(s)).intValue();
configuration.setQueryTimeout(len);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
map.put(PersistenceConfiguration.QUERY_FETCH_DIRECTION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setQueryFetchDirection(s);
}
});
map.put(PersistenceConfiguration.QUERY_RESULT_SET_TYPE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setQueryResultSetType(s);
}
});
map.put(PersistenceConfiguration.QUERY_RESULT_SET_CONCURRENCY_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setQueryResultSetConcurrency(s);
}
});
map.put(PersistenceConfiguration.QUERY_JOIN_TYPE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setQueryJoinType(s);
}
});
map.put(PersistenceConfiguration.QUERY_EXISTS_INCLUDES_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setQueryExistsIncludesConstraints(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.QUERY_CONTAINS_EXISTS_ALWAYS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setQueryContainsUsesExistsAlways(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.QUERY_ALLOW_ALL_SQL_STATEMENTS, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
boolean allow = (new Boolean(s)).booleanValue();
configuration.setQueryAllowAllSQLStatements(allow);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
// Types
map.put(PersistenceConfiguration.STRING_DEFAULT_LENGTH_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
try
{
int len = (new Integer(s)).intValue();
configuration.setStringDefaultLength(len);
}
catch (NumberFormatException nfe)
{
// Do nothing
}
}
});
map.put(PersistenceConfiguration.STRING_LENGTH_ACTION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setStringLengthExceededAction(s);
}
});
map.put(PersistenceConfiguration.PERSIST_EMPTY_STRING_AS_NULL_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPersistEmptyStringAsNull((new Boolean(s)).booleanValue());
}
});
map.put(PersistenceConfiguration.DISCRIMINATOR_PER_SUBCLASSTABLE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDiscriminatorPerSubclassTable((new Boolean(s)).booleanValue());
}
});
map.put(PersistenceConfiguration.ORACLE_SORT_ORDER_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setOracleNlsSortOrder(s);
}
});
// Cache
map.put(PersistenceConfiguration.CACHE_COLLECTIONS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCacheCollections(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.CACHE_COLLECTIONS_LAZY_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
boolean lazy = Boolean.valueOf(s).booleanValue();
if (lazy)
{
configuration.setCacheCollectionsLazy(Boolean.TRUE);
}
else
{
configuration.setCacheCollectionsLazy(Boolean.FALSE);
}
}
});
map.put(PersistenceConfiguration.CACHE_LEVEL_1_TYPE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCacheLevel1Type(s);
}
});
map.put(PersistenceConfiguration.CACHE_LEVEL_2_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCacheLevel2(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.CACHE_LEVEL_2_TYPE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCacheLevel2Type(s);
}
});
map.put(PersistenceConfiguration.CACHE_LEVEL_2_CACHE_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCacheLevel2CacheName(s);
}
});
map.put(PersistenceConfiguration.CACHE_LEVEL_2_CONFIGURATION_FILE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setCacheLevel2ConfigurationFile(s);
}
});
map.put(PersistenceConfiguration.METADATA_JDO_FILE_EXTENSION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setJdoMetaDataFileExtension(s);
}
});
map.put(PersistenceConfiguration.METADATA_ORM_FILE_EXTENSION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setOrmMetaDataFileExtension(s);
}
});
map.put(PersistenceConfiguration.METADATA_JDOQUERY_FILE_EXTENSION_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setJdoqueryMetaDataFileExtension(s);
}
});
map.put(PersistenceConfiguration.METADATA_VALIDATE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setMetaDataValidate(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.METADATA_ANNOTATIONS_MANAGER_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setMetaDataAnnotationsManager(s);
}
});
map.put(PersistenceConfiguration.MESSAGES_INCLUDE_CODES_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setMessagesIncludeCodes(Boolean.valueOf(s));
}
});
map.put(PersistenceConfiguration.PROPERTIES_FILE, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPropertiesFile(s);
}
});
map.put(PersistenceConfiguration.PLUGIN_REGISTRY_CLASS_NAME, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPluginRegistryClassName(s);
}
});
map.put(PersistenceConfiguration.PLUGIN_REGISTRY_BUNDLE_CHECK, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setPluginRegistryBundleCheck(s);
}
});
map.put(PersistenceConfiguration.CONNECTION_PROVIDER_NAME_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionProviderName(s);
}
});
map.put(PersistenceConfiguration.CONNECTION_PROVIDER_FAILONERROR_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionProviderFailOnError(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.PRIMARY_CLASS_LOADER_PROPERTY, new ObjectPropertySetter()
{
public void set(PersistenceConfiguration configuration, Object o)
{
configuration.setPrimaryClassLoaderResolver((ClassLoader)o);
}
});
// Connection Properties
map.put(PersistenceConfiguration.CONNECTION_RESOURCE_TYPE, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnectionResourceType(s);
}
});
map.put(PersistenceConfiguration.CONNECTION2_RESOURCE_TYPE, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setConnection2ResourceType(s);
}
});
// DB4O Properties
map.put(PersistenceConfiguration.DB4O_OUTPUT_FILE_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDb4oOutputFile(s);
}
});
map.put(PersistenceConfiguration.DB4O_FLUSH_BUFFERS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDb4oFlushFileBuffers(Boolean.valueOf(s).booleanValue());
}
});
map.put(PersistenceConfiguration.DB4O_GENERATE_UUIDS_PROPERTY, new StringPropertySetter()
{
public void set(PersistenceConfiguration configuration, String s)
{
configuration.setDb4oGenerateUUIDs(Boolean.valueOf(s).booleanValue());
}
});
return map;
}
/**
* Set the options for this PersistenceManagerFactory based on the
* given Properties.
* @param props The Properties to set the options from.
*/
protected void setOptions(Properties props)
{
this.options = props;
for (Enumeration e = props.propertyNames(); e.hasMoreElements();)
{
String prop = (String) e.nextElement();
StringPropertySetter setter = (StringPropertySetter) PROPERTY_SETTERS.get(prop);
if (prop != null && setter != null)
{
String value = props.getProperty(prop);
setter.set(this, value);
}
else if (prop != null && setter == null)
{
// Omit the ones that we dont have setters for
if (!prop.equals(JDO_PMF_CLASS_PROPERTY) &&
!prop.equals(JPA_PERSISTENCE_PROVIDER_PROPERTY))
{
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008015",prop));
}
}
}
}
/**
* Set the options for this PersistenceManagerFactory based on the
* given map of properties.
* @param props The Properties to set the options from.
*/
protected void setOptions(Map props)
{
this.options = props;
Set keys = props.keySet();
Iterator keyIter = keys.iterator();
while (keyIter.hasNext())
{
Object keyObj = keyIter.next();
if (keyObj instanceof String)
{
String key = (String)keyObj;
Object valueObj = props.get(keyObj);
Object setter = PROPERTY_SETTERS.get(key);
if (setter == null)
{
// Omit the ones that we dont have setters for
if (key != null && !key.equals("javax.jdo.PersistenceManagerFactoryClass"))
{
JPOXLogger.PERSISTENCE.warn(LOCALISER.msg("008015", key));
}
}
else if (setter instanceof StringPropertySetter)
{
StringPropertySetter strSetter = (StringPropertySetter) setter;
if (valueObj != null)
{
if (valueObj instanceof String)
{
String valueStr = ((String)valueObj).trim();
strSetter.set(this, valueStr);
}
else
{
throw new IllegalArgumentException(LOCALISER.msg("008012", key, valueObj));
}
}
else
{
strSetter.set(this, null);
}
}
else if (setter instanceof ObjectPropertySetter)
{
ObjectPropertySetter objSetter = (ObjectPropertySetter) setter;
objSetter.set(this, valueObj);
}
}
else
{
// Ignore this key since we only accept String keys
}
}
}
/**
* Accessor for the options for this persistence configuration
* @return the options for this persistence configuration
*/
public Map getOptions()
{
return options;
}
}
|