org.jboss.system.pm
Class XMLAttributePersistenceManager

java.lang.Object
  extended byorg.jboss.system.pm.XMLAttributePersistenceManager
All Implemented Interfaces:
AttributePersistenceManager (src)

public class XMLAttributePersistenceManager
extends java.lang.Object
implements AttributePersistenceManager (src)

FileAttributePersistenceManager


Field Summary
static java.lang.String AL_ATTRIBUTE_ELEMENT
           
static java.lang.String AL_DATE_ATTRIBUTE
           
static java.lang.String AL_FALSE_VALUE
           
static java.lang.String AL_ID_ATTRIBUTE
           
static java.lang.String AL_NAME_ATTRIBUTE
           
static java.lang.String AL_NULL_ATTRIBUTE
           
static java.lang.String AL_ROOT_ELEMENT
          The XML attribute-list elements and attributes
static java.lang.String AL_SERIALIZED_ATTRIBUTE
           
static java.lang.String AL_TRUE_VALUE
           
static java.lang.String AL_TYPE_ATTRIBUTE
           
static java.lang.String DATA_DIR_ELEMENT
          The XML configuration element
static java.lang.String DEFAULT_BASE_DIR
          Default base directory if one not specified
 
Constructor Summary
XMLAttributePersistenceManager()
          Constructs a FileAttributePersistenceManager.
 
Method Summary
 void create(java.lang.String version, org.w3c.dom.Element config)
          Initializes the AttributePersistenceManager using the supplied configuration element CONFIG_ELEMENT whose content will be probably different for each particular implementation.
 void destroy()
          Releases resources and destroys the AttributePersistenceManager.
 boolean exists(java.lang.String id)
          Checks if a persistened AttributeList for this particular id exists
 boolean getState()
          Returns true if the AttributePersistenceManager is "in-service" state, i.e.
 java.lang.String[] listAll()
          Returns a String array with all the saved ids under the configured version tag.
 AttributeList (src) load(java.lang.String id)
          Persists an AttributeList (name/value pair list), under a specified id.
 void remove(java.lang.String id)
          Removes the persisted AttributeList, if exists
 void removeAll()
          Removes all the persisted data stored under the configured version tag.
 void store(java.lang.String id, AttributeList (src)  attrs)
          Uses the specified id to retrieve a previously persisted AttributeList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_DIR_ELEMENT

public static final java.lang.String DATA_DIR_ELEMENT
The XML configuration element

See Also:
Constant Field Values (src)

DEFAULT_BASE_DIR

public static final java.lang.String DEFAULT_BASE_DIR
Default base directory if one not specified

See Also:
Constant Field Values (src)

AL_ROOT_ELEMENT

public static final java.lang.String AL_ROOT_ELEMENT
The XML attribute-list elements and attributes

See Also:
Constant Field Values (src)

AL_ID_ATTRIBUTE

public static final java.lang.String AL_ID_ATTRIBUTE
See Also:
Constant Field Values (src)

AL_DATE_ATTRIBUTE

public static final java.lang.String AL_DATE_ATTRIBUTE
See Also:
Constant Field Values (src)

AL_ATTRIBUTE_ELEMENT

public static final java.lang.String AL_ATTRIBUTE_ELEMENT
See Also:
Constant Field Values (src)

AL_NAME_ATTRIBUTE

public static final java.lang.String AL_NAME_ATTRIBUTE
See Also:
Constant Field Values (src)

AL_TYPE_ATTRIBUTE

public static final java.lang.String AL_TYPE_ATTRIBUTE
See Also:
Constant Field Values (src)

AL_NULL_ATTRIBUTE

public static final java.lang.String AL_NULL_ATTRIBUTE
See Also:
Constant Field Values (src)

AL_SERIALIZED_ATTRIBUTE

public static final java.lang.String AL_SERIALIZED_ATTRIBUTE
See Also:
Constant Field Values (src)

AL_TRUE_VALUE

public static final java.lang.String AL_TRUE_VALUE
See Also:
Constant Field Values (src)

AL_FALSE_VALUE

public static final java.lang.String AL_FALSE_VALUE
See Also:
Constant Field Values (src)
Constructor Detail

XMLAttributePersistenceManager

public XMLAttributePersistenceManager()
Constructs a FileAttributePersistenceManager.

Method Detail

create

public void create(java.lang.String version,
                   org.w3c.dom.Element config)
            throws java.lang.Exception
Initializes the AttributePersistenceManager using the supplied configuration element CONFIG_ELEMENT whose content will be probably different for each particular implementation. The version string is a tag that must be used by the AttributePersistenceManager implementation to make sure that data saved/loaded under different version tags are partitioned. Once created, the configuration of the implementation object cannot change. Calling any other method before create() is executed will result in a IllegalStateException Finally, the implementation should be prepared to receive multiple concurrent calls.

Specified by:
create in interface AttributePersistenceManager (src)
Parameters:
version - a tag to identify the version
config - XML Element to load arbitrary config
Throws:
java.lang.Exception - when any error occurs during create

getState

public boolean getState()
Returns true if the AttributePersistenceManager is "in-service" state, i.e. after create() and before destroy() has been called, false otherwise.

Specified by:
getState in interface AttributePersistenceManager (src)
Returns:
true if in operational state

destroy

public void destroy()
Releases resources and destroys the AttributePersistenceManager. The object is unusable after destroy() has been called. Any call to any method will result to an IllegalStateException.

Specified by:
destroy in interface AttributePersistenceManager (src)

store

public void store(java.lang.String id,
                  AttributeList (src)  attrs)
           throws java.lang.Exception
Uses the specified id to retrieve a previously persisted AttributeList. If no data can be found under the specified id, a null will be returned.

Specified by:
store in interface AttributePersistenceManager (src)
Parameters:
id - the key for retrieving the data
attrs - the data to be persisted, not null
Returns:
the data, or null
Throws:
java.lang.Exception - when an error occurs

load

public AttributeList (src)  load(java.lang.String id)
                   throws java.lang.Exception
Persists an AttributeList (name/value pair list), under a specified id. The id can be used to retrieve the AttributeList later on. The actual mechanism will differ among implementations.

Specified by:
load in interface AttributePersistenceManager (src)
Parameters:
id - the key for retrieving the data later on, not null
Returns:
the data, or null
Throws:
java.lang.Exception - when data cannot be persisted

exists

public boolean exists(java.lang.String id)
               throws java.lang.Exception
Checks if a persistened AttributeList for this particular id exists

Specified by:
exists in interface AttributePersistenceManager (src)
Parameters:
id - the key of the image
Returns:
true if an image exists; false otherwise
Throws:
java.lang.Exception - on any error

remove

public void remove(java.lang.String id)
            throws java.lang.Exception
Removes the persisted AttributeList, if exists

Specified by:
remove in interface AttributePersistenceManager (src)
Parameters:
id - the key of the image
Throws:
java.lang.Exception - when any error occurs

removeAll

public void removeAll()
               throws java.lang.Exception
Removes all the persisted data stored under the configured version tag.

Specified by:
removeAll in interface AttributePersistenceManager (src)
Throws:
java.lang.Exception - when any error occurs

listAll

public java.lang.String[] listAll()
                           throws java.lang.Exception
Returns a String array with all the saved ids under the configured version tag.

Specified by:
listAll in interface AttributePersistenceManager (src)
Returns:
array with all persisted ids
Throws:
java.lang.Exception - when any error occurs