001: /*
002: * Modified from the original HttpSession.java by Nabh Information Systems, Inc.
003: * Modifications (c) 2005 Nabh Information Systems, Inc.
004: *
005: * Copyright 2004 The Apache Software Foundation
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: *
019: */
020: package com.nabhinc.core;
021:
022: import java.util.Enumeration;
023:
024: /**
025: * @author Padmanabh Dabke
026: * An abstract representation of a "session" mainly based on
027: * HTTPSession interface.
028: */
029: public interface WebServiceSession {
030: /**
031: *
032: * Returns the time when this session was created, measured
033: * in milliseconds since midnight January 1, 1970 GMT.
034: *
035: * @return a <code>long</code> specifying
036: * when this session was created,
037: * expressed in
038: * milliseconds since 1/1/1970 GMT
039: *
040: * @exception IllegalStateException if this method is called on an
041: * invalidated session
042: *
043: */
044:
045: public long getCreationTime();
046:
047: /**
048: *
049: * Returns a string containing the unique identifier assigned
050: * to this session. The identifier is assigned
051: * by the Web services container and is implementation dependent.
052: *
053: * @return a string specifying the identifier
054: * assigned to this session
055: *
056: * @exception IllegalStateException if this method is called on an
057: * invalidated session
058: *
059: */
060:
061: public String getId();
062:
063: /**
064: *
065: * Returns the last time the client sent a request associated with
066: * this session, as the number of milliseconds since midnight
067: * January 1, 1970 GMT, and marked by the time the container received the request.
068: *
069: * <p>Actions that your application takes, such as getting or setting
070: * a value associated with the session, do not affect the access
071: * time.
072: *
073: * @return a <code>long</code>
074: * representing the last time
075: * the client sent a request associated
076: * with this session, expressed in
077: * milliseconds since 1/1/1970 GMT
078: *
079: * @exception IllegalStateException if this method is called on an
080: * invalidated session
081: *
082: */
083:
084: public long getLastAccessedTime();
085:
086: /**
087: *
088: * Specifies the time, in seconds, between client requests before the
089: * Web services container will invalidate this session. A negative time
090: * indicates the session should never timeout.
091: *
092: * @param interval An integer specifying the number
093: * of seconds
094: *
095: */
096:
097: public void setMaxInactiveInterval(int interval);
098:
099: /**
100: * Returns the maximum time interval, in seconds, that
101: * the Web services container will keep this session open between
102: * client accesses. After this interval, the Web services container
103: * will invalidate the session. The maximum time interval can be set
104: * with the <code>setMaxInactiveInterval</code> method.
105: * A negative time indicates the session should never timeout.
106: *
107: *
108: * @return an integer specifying the number of
109: * seconds this session remains open
110: * between client requests
111: *
112: * @see #setMaxInactiveInterval
113: *
114: *
115: */
116:
117: public int getMaxInactiveInterval();
118:
119: /**
120: *
121: * Returns the object bound with the specified name in this session, or
122: * <code>null</code> if no object is bound under the name.
123: *
124: * @param name a string specifying the name of the object
125: *
126: * @return the object with the specified name
127: *
128: * @exception IllegalStateException if this method is called on an
129: * invalidated session
130: *
131: */
132:
133: public Object getAttribute(String name);
134:
135: /**
136: *
137: * Returns an <code>Enumeration</code> of <code>String</code> objects
138: * containing the names of all the objects bound to this session.
139: *
140: * @return an <code>Enumeration</code> of
141: * <code>String</code> objects specifying the
142: * names of all the objects bound to
143: * this session
144: *
145: * @exception IllegalStateException if this method is called on an
146: * invalidated session
147: *
148: */
149:
150: public Enumeration getAttributeNames();
151:
152: /**
153: * Binds an object to this session, using the name specified.
154: * If an object of the same name is already bound to the session,
155: * the object is replaced.
156: * *
157: *
158: * @param name the name to which the object is bound;
159: * cannot be null
160: *
161: * @param value the object to be bound
162: *
163: * @exception IllegalStateException if this method is called on an
164: * invalidated session
165: *
166: */
167:
168: public void setAttribute(String name, Object value);
169:
170: /**
171: *
172: * Removes the object bound with the specified name from
173: * this session. If the session does not have an object
174: * bound with the specified name, this method does nothing.
175: *
176: * @param name the name of the object to
177: * remove from this session
178: *
179: * @exception IllegalStateException if this method is called on an
180: * invalidated session
181: */
182:
183: public void removeAttribute(String name);
184:
185: /**
186: *
187: * Invalidates this session then unbinds any objects bound
188: * to it.
189: *
190: * @exception IllegalStateException if this method is called on an
191: * already invalidated session
192: *
193: */
194:
195: public void invalidate();
196:
197: /**
198: *
199: * Returns <code>true</code> if the client does not yet know about the
200: * session or if the client chooses not to join the session. For
201: * example, if the server used only cookie-based sessions, and
202: * the client had disabled the use of cookies, then a session would
203: * be new on each request.
204: *
205: * @return <code>true</code> if the
206: * server has created a session,
207: * but the client has not yet joined
208: *
209: * @exception IllegalStateException if this method is called on an
210: * already invalidated session
211: *
212: */
213:
214: public boolean isNew();
215:
216: }
|