001: /*
002: * Copyright 1999,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.catalina;
018:
019: import java.beans.PropertyChangeListener;
020: import java.io.IOException;
021:
022: /**
023: * A <b>Store</b> is the abstraction of a Catalina component that provides
024: * persistent storage and loading of Sessions and their associated user data.
025: * Implementations are free to save and load the Sessions to any media they
026: * wish, but it is assumed that saved Sessions are persistent across
027: * server or context restarts.
028: *
029: * @author Craig R. McClanahan
030: * @version $Revision: 1.2 $ $Date: 2004/02/27 14:58:39 $
031: */
032:
033: public interface Store {
034:
035: // ------------------------------------------------------------- Properties
036:
037: /**
038: * Return descriptive information about this Store implementation and
039: * the corresponding version number, in the format
040: * <code><description>/<version></code>.
041: */
042: public String getInfo();
043:
044: /**
045: * Return the Manager instance associated with this Store.
046: */
047: public Manager getManager();
048:
049: /**
050: * Set the Manager associated with this Store.
051: *
052: * @param manager The Manager which will use this Store.
053: */
054: public void setManager(Manager manager);
055:
056: /**
057: * Return the number of Sessions present in this Store.
058: *
059: * @exception IOException if an input/output error occurs
060: */
061: public int getSize() throws IOException;
062:
063: // --------------------------------------------------------- Public Methods
064:
065: /**
066: * Add a property change listener to this component.
067: *
068: * @param listener The listener to add
069: */
070: public void addPropertyChangeListener(
071: PropertyChangeListener listener);
072:
073: /**
074: * Return an array containing the session identifiers of all Sessions
075: * currently saved in this Store. If there are no such Sessions, a
076: * zero-length array is returned.
077: *
078: * @exception IOException if an input/output error occurred
079: */
080: public String[] keys() throws IOException;
081:
082: /**
083: * Load and return the Session associated with the specified session
084: * identifier from this Store, without removing it. If there is no
085: * such stored Session, return <code>null</code>.
086: *
087: * @param id Session identifier of the session to load
088: *
089: * @exception ClassNotFoundException if a deserialization error occurs
090: * @exception IOException if an input/output error occurs
091: */
092: public Session load(String id) throws ClassNotFoundException,
093: IOException;
094:
095: /**
096: * Remove the Session with the specified session identifier from
097: * this Store, if present. If no such Session is present, this method
098: * takes no action.
099: *
100: * @param id Session identifier of the Session to be removed
101: *
102: * @exception IOException if an input/output error occurs
103: */
104: public void remove(String id) throws IOException;
105:
106: /**
107: * Remove all Sessions from this Store.
108: */
109: public void clear() throws IOException;
110:
111: /**
112: * Remove a property change listener from this component.
113: *
114: * @param listener The listener to remove
115: */
116: public void removePropertyChangeListener(
117: PropertyChangeListener listener);
118:
119: /**
120: * Save the specified Session into this Store. Any previously saved
121: * information for the associated session identifier is replaced.
122: *
123: * @param session Session to be saved
124: *
125: * @exception IOException if an input/output error occurs
126: */
127: public void save(Session session) throws IOException;
128:
129: }
|