com.admc.jamama.repository
Class MitFileRepository

java.lang.Object
  extended byAbstractDynamicMBean
      extended bycom.admc.jamama.repository.MitFileRepository
All Implemented Interfaces:
Configurable, Repository

public class MitFileRepository
extends AbstractDynamicMBean
implements Repository

Stores in-transit messages in Sendmail-spool-file-like files. TODO: Write more efficiently. No need for a printwriter here. This implementation of Repository does not use destKeys, since every in-transit message corresponds to its own unique file in the directory.

See Also:
Serialized Form

Constructor Summary
MitFileRepository()
           
 
Method Summary
 boolean addDestKey(java.lang.String key)
          Make the supplied destKey a valid destKey.
 java.lang.Object[] arrayFetch(java.lang.String queryString, java.lang.String destKey)
          Fetch the reqeusted objects.
 void configure(java.lang.Object inCfg)
          Initialize the object's state with information in the given Jaxb object.
protected  MBeanAttributeInfo[] createMBeanAttributeInfo()
           
 java.lang.Object fetch(java.lang.String key, java.lang.String destKey)
          Fetch the requested object.
 java.lang.Object getConfig()
          Returns the Jaxb object used to configure this.
 java.lang.String getDirectory()
          Get directory in which mail folders reside
protected  java.lang.String getMBeanDescription()
           
 java.lang.String getName()
          Name which Jamama config file uses to identify this object instance.
 java.lang.Class[] getPersistableClasses()
          Tell what classes this Repository implementation can handle.
 StringSet getValidDestKeys()
          Return a list of valid destination keys.
 boolean isDestKeyValid(java.lang.String key)
          Says whether the given destKey is valid.
 java.lang.String persist(java.lang.Object o, java.lang.String destKey)
          Primary key needs to come from Message-Id.
 java.lang.String persist(java.lang.Object o, java.lang.String d, boolean b)
          Completely replaces the files for this primary key and replaces them with new files.
 boolean remove(java.lang.Object object, java.lang.String destKey)
          Remove the given object from storage.
 boolean removeDestKey(java.lang.String key)
          Make the supplied destKey an invalid destKey.
 void setDestKeys(StringSet keys)
           
 void setDirectory(java.lang.String inDirectory)
          Set directory in which mail folders reside
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MitFileRepository

public MitFileRepository()
Method Detail

createMBeanAttributeInfo

protected MBeanAttributeInfo[] createMBeanAttributeInfo()

getMBeanDescription

protected java.lang.String getMBeanDescription()

setDestKeys

public void setDestKeys(StringSet keys)

addDestKey

public boolean addDestKey(java.lang.String key)
Description copied from interface: Repository
Make the supplied destKey a valid destKey.

Specified by:
addDestKey in interface Repository
Parameters:
key - The key to be added to the valid destKey list.
Returns:
false if destKey is already valid. true otherwise.

removeDestKey

public boolean removeDestKey(java.lang.String key)
Description copied from interface: Repository
Make the supplied destKey an invalid destKey.

Specified by:
removeDestKey in interface Repository
Parameters:
key - The key to be removed from the valid destKey list.
Returns:
false if destKey is already invalid. true otherwise.

getPersistableClasses

public java.lang.Class[] getPersistableClasses()
Description copied from interface: Repository
Tell what classes this Repository implementation can handle.

Specified by:
getPersistableClasses in interface Repository
Returns:
Return an array of the classes of Objects that the Repository implementation can fetch/store/remove.
See Also:
Repository

getValidDestKeys

public StringSet getValidDestKeys()
Description copied from interface: Repository
Return a list of valid destination keys.

Specified by:
getValidDestKeys in interface Repository
Returns:
The destKeys that are allowed for use with the other members of this interface that have a destKey parameter. A list with 0 elements means no valid keys. A null list means all keys are valid.
See Also:
Repository

isDestKeyValid

public boolean isDestKeyValid(java.lang.String key)
Description copied from interface: Repository
Says whether the given destKey is valid.

Specified by:
isDestKeyValid in interface Repository
Parameters:
key - The destKey to be checked.
Returns:
Tells whether the given destKey is allowed for use with the other members of this interface that have a destKey parameter.

persist

public java.lang.String persist(java.lang.Object o,
                                java.lang.String d,
                                boolean b)
                         throws UnsupportedClassException,
                                java.io.IOException
Completely replaces the files for this primary key and replaces them with new files.

Specified by:
persist in interface Repository
Parameters:
o - The object to store. It must be an implementation of a supported class.
d - A valid destination key
b - Whether the primary key (as determined by the Repository implementation) must already be in storage for the given destKey.
Returns:
Primary key (generated by the Repository implementation) used to successfully store the given object).
Throws:
UnsupportedClassException - if object does not implement a supported class.
java.io.IOException
See Also:
#persist(Object... I forget how to Javadoc this ref., 2-argument persiste method.

persist

public java.lang.String persist(java.lang.Object o,
                                java.lang.String destKey)
                         throws UnsupportedClassException,
                                java.io.IOException
Primary key needs to come from Message-Id. We need to research where Message-Id is supposed to be created, and if it is possible to have 2 messages with same Message-Id. When that is done, get rid of the msgid stub here and user Message-Id for primary key

Specified by:
persist in interface Repository
Parameters:
o - The object to store. It must be an implementation of a supported class.
destKey - A valid destination key
Returns:
Primary key (generated by the Repository implementation) used to successfully store the given object).
Throws:
UnsupportedClassException - if object does not implement a supported class.
java.io.IOException
See Also:
Repository

configure

public void configure(java.lang.Object inCfg)
Description copied from interface: Configurable
Initialize the object's state with information in the given Jaxb object.

Specified by:
configure in interface Configurable
Parameters:
inCfg - A Jaxb object corresponding to a XML document branch.
See Also:
Configurable

setDirectory

public void setDirectory(java.lang.String inDirectory)
Set directory in which mail folders reside


getDirectory

public java.lang.String getDirectory()
Get directory in which mail folders reside


getName

public java.lang.String getName()
Description copied from interface: Configurable
Name which Jamama config file uses to identify this object instance.

Specified by:
getName in interface Configurable
See Also:
Configurable

getConfig

public java.lang.Object getConfig()
Description copied from interface: Configurable
Returns the Jaxb object used to configure this.

Specified by:
getConfig in interface Configurable
See Also:
Configurable

remove

public boolean remove(java.lang.Object object,
                      java.lang.String destKey)
               throws java.io.IOException
Description copied from interface: Repository
Remove the given object from storage.

Specified by:
remove in interface Repository
Parameters:
object - The object to remove. Only the generated primary key (as generated by the Repository implementation) is used.
destKey - A valid destination key for the given stored object
Throws:
java.io.IOException

fetch

public java.lang.Object fetch(java.lang.String key,
                              java.lang.String destKey)
                       throws java.io.IOException
Description copied from interface: Repository
Fetch the requested object.

Specified by:
fetch in interface Repository
Parameters:
key - Primary key of object to fetch
destKey - A valid destination key
Returns:
The object fetched.
Throws:
java.io.IOException

arrayFetch

public java.lang.Object[] arrayFetch(java.lang.String queryString,
                                     java.lang.String destKey)
                              throws java.io.IOException
Description copied from interface: Repository
Fetch the reqeusted objects. The queryString is used in Repository implemenation specific manner. It could be used, for example, as a space-delimited list of primary keys, or as a SQL where clause.

Specified by:
arrayFetch in interface Repository
Parameters:
queryString - A string used by the Repository implementation to identify the subset of objects to fetch.
destKey - A valid destination key
Returns:
Array of fetched objects
Throws:
java.io.IOException