Jwma

dtw.webmail.plugin.std
Class CastorXMLPreferencesPersistence

java.lang.Object
  |
  +--dtw.webmail.plugin.std.CastorXMLPreferencesPersistence
All Implemented Interfaces:
JwmaPlugin, PreferencesPersistencePlugin

public class CastorXMLPreferencesPersistence
extends java.lang.Object
implements PreferencesPersistencePlugin

A PreferencesPersistancePlugin implementation based on Castor XML marshalling/unmarshalling.

Stores the preferences as XML files.

Version:
0.9.7 07/02/2003
Author:
Dieter Wimberger

Constructor Summary
CastorXMLPreferencesPersistence()
           
 
Method Summary
 void activate()
          Activates the plugin for subsequent use.
 void deactivate()
          Deactivates the plugin.
 JwmaPreferencesImpl getPreferencesTemplate(JwmaSession session)
          Returns a copy of the template JwmaPreferencesImpl instance.
 boolean isPersistent(java.lang.String identity)
          Tests if preferences for the given user exist on the store.
 JwmaPreferencesImpl loadPreferences(java.lang.String identity)
          Loads the given user's preferences from the persistent store and returns them as a JwmaPreferencesImpl instance.
 void savePreferences(JwmaPreferencesImpl prefs)
          Saves the given preferences to the persistent store.
 void setPreferencesTemplate(JwmaPreferencesImpl template)
          Sets the template JwmaPreferencesImpl instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CastorXMLPreferencesPersistence

public CastorXMLPreferencesPersistence()
Method Detail

loadPreferences

public JwmaPreferencesImpl loadPreferences(java.lang.String identity)
                                    throws JwmaException
Description copied from interface: PreferencesPersistencePlugin
Loads the given user's preferences from the persistent store and returns them as a JwmaPreferencesImpl instance.

If preferences for the given user do not exist on the store, the method returns null.

Specified by:
loadPreferences in interface PreferencesPersistencePlugin
Parameters:
identity - a String representing the user (in a unique way).
Returns:
the JwmaPreferencesImpl instance.
Throws:
JwmaException - if an I/O error occurs.
See Also:
JwmaPreferencesImpl, JwmaPreferences.getUserIdentity()

savePreferences

public void savePreferences(JwmaPreferencesImpl prefs)
                     throws JwmaException
Description copied from interface: PreferencesPersistencePlugin
Saves the given preferences to the persistent store.

If the preferences do not exist on the store, the method should create them, otherwise update the existing version.
The identity is retrieved using the getUserIdentity() method of the given JwmaPreferencesImpl instance.

Specified by:
savePreferences in interface PreferencesPersistencePlugin
Parameters:
prefs - the JwmaPreferencesImpl instance to saved.
Throws:
JwmaException - if an I/O error occurs.
See Also:
JwmaPreferencesImpl, JwmaPreferences.getUserIdentity()

isPersistent

public boolean isPersistent(java.lang.String identity)
                     throws JwmaException
Description copied from interface: PreferencesPersistencePlugin
Tests if preferences for the given user exist on the store.

Specified by:
isPersistent in interface PreferencesPersistencePlugin
Parameters:
identity - a String representing the user (in a unique way).
Throws:
JwmaException - if an I/O error occurs.
See Also:
JwmaPreferences.getUserIdentity()

getPreferencesTemplate

public JwmaPreferencesImpl getPreferencesTemplate(JwmaSession session)
Description copied from interface: PreferencesPersistencePlugin
Returns a copy of the template JwmaPreferencesImpl instance.

Specified by:
getPreferencesTemplate in interface PreferencesPersistencePlugin
Parameters:
session - the actual JwmaSession instance.
Returns:
the template JwmaPreferencesImpl instance.
See Also:
JwmaPreferencesImpl

activate

public void activate()
              throws JwmaException
Description copied from interface: JwmaPlugin
Activates the plugin for subsequent use.

This method is called during bootstrap to allow an implementation to initialize properly. If the plugin cannot perform it's task, it has to throw a JwmaException.

Specified by:
activate in interface JwmaPlugin
Throws:
JwmaException - if initialization failed.

deactivate

public void deactivate()
Description copied from interface: JwmaPlugin
Deactivates the plugin.

This method is called during shutdown or probably on dynamic implementation exchange, to allow an implementation to finalize properly.

Specified by:
deactivate in interface JwmaPlugin

setPreferencesTemplate

public void setPreferencesTemplate(JwmaPreferencesImpl template)
                            throws JwmaException
Description copied from interface: PreferencesPersistencePlugin
Sets the template JwmaPreferencesImpl instance.

The caller assumes that the plugin handles the persistence of the passed in template instance.

Specified by:
setPreferencesTemplate in interface PreferencesPersistencePlugin
Parameters:
template - JwmaPreferencesImpl instance.
Throws:
JwmaException - if an I/O error occurs.
See Also:
JwmaPreferencesImpl

Jwma

Copyright © 2000-2003 jwma team (All Rights Reserved.)