org.datanucleus
Class PersistenceConfiguration

java.lang.Object
  extended by org.datanucleus.PersistenceConfiguration

public class PersistenceConfiguration
extends java.lang.Object

Class providing configuration for persistence. Properties are defined in plugin.xml (aliases, default value, validators etc). Property values are stored in two maps.

Components can then access these properties using any of the convenience accessors for boolean, Boolean, long, int, Object, String types. When accessing properties the user-provided value is taken first (if available), otherwise the default value is used (or null).


Field Summary
protected static Localiser LOCALISER
          Localisation of messages.
 
Constructor Summary
PersistenceConfiguration()
          Constructor.
 
Method Summary
 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.
 boolean getBooleanProperty(java.lang.String name, boolean resultIfNotSet)
          Accessor for the specified property as a boolean.
 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<java.lang.String,java.lang.Object> getPersistenceProperties()
          Accessor for the persistence properties.
 java.util.Map<java.lang.String,java.lang.Object> getPersistencePropertiesDefaults()
          Accessor for the persistence properties default values.
 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<java.lang.String> getSupportedProperties()
          Accessor for the names of the supported persistence properties.
 boolean hasProperty(java.lang.String name)
          Accessor for whether a particular property is defined.
 void setDefaultProperties(java.util.Map props)
          Method to set the persistence property defaults based on what is defined for plugins.
 void setDefaultProperties(PluginManager pluginMgr)
          Method to set the persistence property defaults based on what is defined for plugins.
 void setPersistenceProperties(java.util.Map props)
          Set the properties for this configuration.
 void setPropertiesUsingFile(java.lang.String filename)
          Method to set the persistence properties using those defined in a file.
 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.

Constructor Detail

PersistenceConfiguration

public PersistenceConfiguration()
Constructor.

Method Detail

getSupportedProperties

public java.util.Set<java.lang.String> getSupportedProperties()
Accessor for the names of the supported persistence properties.

Returns:
The persistence properties that we support

setDefaultProperties

public void setDefaultProperties(java.util.Map props)
Method to set the persistence property defaults based on what is defined for plugins. This should only be called after the other setDefaultProperties method is called, which sets up the mappings

Parameters:
props - Properties to use in the default set

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

getProperty

public java.lang.Object getProperty(java.lang.String name)
Accessor for the specified property as an Object. Returns user-specified value if propvided, otherwise the default value, otherwise null.

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

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

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name,
                                  boolean resultIfNotSet)
Accessor for the specified property as a boolean.

Parameters:
name - Name of the property
resultIfNotSet - The value to return if no value for the specified property is found.
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

setPropertiesUsingFile

public void setPropertiesUsingFile(java.lang.String filename)
Method to set the persistence properties using those defined in a file.

Parameters:
filename - Name of the file containing the properties

getPersistencePropertiesDefaults

public java.util.Map<java.lang.String,java.lang.Object> getPersistencePropertiesDefaults()
Accessor for the persistence properties default values. This returns the defaulted properties

Returns:
The persistence properties

getPersistenceProperties

public java.util.Map<java.lang.String,java.lang.Object> getPersistenceProperties()
Accessor for the persistence properties. This returns just the user-supplied properties, not the defaulted properties

Returns:
The persistence properties
See Also:
getPersistenceProperties()

setPersistenceProperties

public void setPersistenceProperties(java.util.Map props)
Set the properties for this configuration. Note : this has this name so it has a getter/setter pair for use by things like Spring.

Parameters:
props - The persistence properties
See Also:
getPersistencePropertiesDefaults()

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Convenience method to set a persistence property. Uses any validator defined for the property to govern whether the value is suitable.

Parameters:
name - Name of the property
value - Value

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.


Copyright © 2011. All Rights Reserved.