org.datanucleus
Class PersistenceConfiguration

java.lang.Object
  extended by org.datanucleus.PersistenceConfiguration
Direct Known Subclasses:
ObjectManagerFactoryImpl

public abstract class PersistenceConfiguration
extends java.lang.Object

Class providing configuration for persistence. Persistence properties should be defined in the "plugin.xml" of the plugin that originates them. This class will read the available defined plugin properties (and their defaults, validators etc) and loaded up accordingly. Then any user-provided properties are superimposed over the top of these. Components can then access these properties using any of the convenience accessors for boolean, Boolean, long, int, Object, String types.


Field Summary
protected  boolean configurable
          Flag for whether this object is still configurable.
protected static Localiser LOCALISER
          Localisation of messages.
 
Constructor Summary
PersistenceConfiguration()
          Constructor.
 
Method Summary
protected  void assertConfigurable()
          Asserts that a change to a configuration property is allowed.
 boolean equals(java.lang.Object obj)
          Equality operator.
 java.lang.Boolean getBooleanObjectProperty(java.lang.String name)
          Accessor for the specified property as a Boolean.
 boolean getBooleanProperty(java.lang.String name)
          Accessor for the specified property as a boolean.
 java.util.Calendar getCalendarForDateTimezone()
          Accessor for the Calendar to be used in handling all timezone issues with the datastore.
 int getIntProperty(java.lang.String name)
          Accessor for the specified property as an int.
 long getLongProperty(java.lang.String name)
          Accessor for the specified property as a long.
 java.util.Map getOptions()
          Accessor for the options for this persistence configuration
 java.lang.ClassLoader getPrimaryClassLoader()
          Accessor for the primary class loader
 java.lang.Object getProperty(java.lang.String name)
          Accessor for the specified property as an Object.
 java.lang.String getStringProperty(java.lang.String name)
          Accessor for the specified property as a String.
 java.util.Set getSupportedOptions()
          Accessor for the names of the supported persistence properties.
 boolean hasProperty(java.lang.String name)
          Accessor for whether a particular property is defined.
 boolean isJcaMode()
          Accessor for the JCA mode.
 void setDefaultProperties(PluginManager pluginMgr)
          Method to set the persistence property defaults based on what is defined for plugins.
 void setJCAMode(java.lang.Boolean jca)
          Mutator for the JCA mode.
 void setOptions(java.util.Map props)
          Set the options for this PersistenceManagerFactory based on the given map of properties.
 void setPrimaryClassLoader(java.lang.ClassLoader loader)
          Mutator to set the primary class loader.
 void setPropertiesFile(java.lang.String value)
          Accessor for the suffix for table identifiers
 void setProperty(java.lang.String name, java.lang.Object value)
          Convenience method to set a persistence property.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation of messages.


configurable

protected transient boolean configurable
Flag for whether this object is still configurable.

Constructor Detail

PersistenceConfiguration

public PersistenceConfiguration()
Constructor.

Method Detail

getOptions

public java.util.Map getOptions()
Accessor for the options for this persistence configuration

Returns:
the options for this persistence configuration

getSupportedOptions

public java.util.Set getSupportedOptions()
Accessor for the names of the supported persistence properties.

Returns:
The persistence properties that we support

setDefaultProperties

public void setDefaultProperties(PluginManager pluginMgr)
Method to set the persistence property defaults based on what is defined for plugins.

Parameters:
pluginMgr - The plugin manager

hasProperty

public boolean hasProperty(java.lang.String name)
Accessor for whether a particular property is defined.

Parameters:
name - Property name
Returns:
Whether the property is defined

getLongProperty

public long getLongProperty(java.lang.String name)
Accessor for the specified property as a long. If the specified property isn't found returns 0.

Parameters:
name - Name of the property
Returns:
Long value for the property
Throws:
PropertyTypeInvalidException - thrown when the property is not available as this type

getIntProperty

public int getIntProperty(java.lang.String name)
Accessor for the specified property as an int. If the specified property isn't found returns 0.

Parameters:
name - Name of the property
Returns:
Int value for the property
Throws:
PropertyTypeInvalidException - thrown when the property is not available as this type

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
Accessor for the specified property as a boolean. If the specified property isn't found returns false.

Parameters:
name - Name of the property
Returns:
Boolean value for the property
Throws:
PropertyTypeInvalidException - thrown when the property is not available as this type

getBooleanObjectProperty

public java.lang.Boolean getBooleanObjectProperty(java.lang.String name)
Accessor for the specified property as a Boolean. If the specified property isn't found returns false.

Parameters:
name - Name of the property
Returns:
Boolean value for the property
Throws:
PropertyTypeInvalidException - thrown when the property is not available as this type

getStringProperty

public java.lang.String getStringProperty(java.lang.String name)
Accessor for the specified property as a String. If the specified property isn't found returns null.

Parameters:
name - Name of the property
Returns:
String value for the property
Throws:
PropertyTypeInvalidException - thrown when the property is not available as this type

getProperty

public java.lang.Object getProperty(java.lang.String name)
Accessor for the specified property as an Object. If the specified property isn't found returns null.

Parameters:
name - Name of the property
Returns:
Value for the property

equals

public boolean equals(java.lang.Object obj)
Equality operator.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to compare against.
Returns:
Whether the objects are equal.

getCalendarForDateTimezone

public java.util.Calendar getCalendarForDateTimezone()
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.

Returns:
The calendar to use for dateTimezone issues.

setPrimaryClassLoader

public void setPrimaryClassLoader(java.lang.ClassLoader loader)
Mutator to set the primary class loader. Setter provided since the input is an object and so cannot go through property input

Parameters:
loader - Loader

getPrimaryClassLoader

public java.lang.ClassLoader getPrimaryClassLoader()
Accessor for the primary class loader

Returns:
primary class loader

setJCAMode

public void setJCAMode(java.lang.Boolean jca)
Mutator for the JCA mode.

Parameters:
jca - true if using JCA connector

isJcaMode

public boolean isJcaMode()
Accessor for the JCA mode.

Returns:
true if using JCA connector.

setPropertiesFile

public void setPropertiesFile(java.lang.String value)
Accessor for the suffix for table identifiers

Parameters:
value - the suffix for table identifiers

setOptions

public void setOptions(java.util.Map props)
Set the options for this PersistenceManagerFactory based on the given map of properties.

Parameters:
props - The Properties to set the options from.

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Convenience method to set a persistence property.

Parameters:
name - Name of the property
value - Value

assertConfigurable

protected void assertConfigurable()
Asserts that a change to a configuration property is allowed.



Copyright © 2009. All Rights Reserved.