001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: PersistentStore.java,v 1.2 2006-06-15 13:40:47 sinisa Exp $
022: */
023:
024: package com.lutris.util;
025:
026: import java.io.Serializable;
027:
028: /**
029: * Persitent storage interface.
030: *
031: * @author Kyle Clark
032: */
033: public interface PersistentStore {
034:
035: /**
036: * Method to store and object (persistent).
037: *
038: * @param key The key by which to identify the stored object.
039: * @param obj The serializable object to store.
040: * @exception com.lutris.util.PersistentStoreException
041: * if an error occurs.
042: */
043: public void store(String key, Serializable obj)
044: throws com.lutris.util.PersistentStoreException;
045:
046: /**
047: * Method to retrieve a stored object.
048: *
049: * @param key The key of the user whose session
050: * is to be retreived.
051: * @return The stored object. If an object is not
052: * stored under key, then <code>null</code> is returned.
053: * @see #remove
054: * @exception com.lutris.util.PersistentStoreException
055: * if an error occurs.
056: */
057: public Object retrieve(String key)
058: throws com.lutris.util.PersistentStoreException;
059:
060: /**
061: * Method to simultaneously retrieve and remove an
062: * object from persistent store. If an object is not
063: * stored under key, then null is returned.
064: *
065: * @param key The key by which to identify the stored object
066: * that is to be removed.
067: * @return The object that has been removed.
068: * @exception com.lutris.util.PersistentStoreException
069: * if an error occurs.
070: */
071: public Object remove(String key)
072: throws com.lutris.util.PersistentStoreException;
073:
074: /**
075: * Method to delete a a key. Any objects stored under
076: * key are also removed. If key is not defined, then
077: * this method does nothing.
078: *
079: * @param key
080: * The key to remove.
081: * @exception com.lutris.util.PersistentStoreException
082: * if an error occurs.
083: */
084: public void delete(String key)
085: throws com.lutris.util.PersistentStoreException;
086:
087: /**
088: * Method to query if an an object is stored.
089: *
090: * @param key The key by which to identify the stored object.
091: * @exception com.lutris.util.PersistentStoreException
092: * if an error occurs.
093: */
094: public boolean exists(String key)
095: throws com.lutris.util.PersistentStoreException;
096:
097: /**
098: * Method that returns an enumration of the keys
099: * of this persistent store.
100: *
101: * @exception com.lutris.util.PersistentStoreException
102: * if the enumeration could not be determined.
103: */
104: public java.util.Enumeration keys()
105: throws com.lutris.util.PersistentStoreException;
106:
107: }
|