1 /**
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.apache.geronimo.clustering;
19
20 import java.util.Map;
21
22 /**
23 * Represents a clustered session.
24 * <p>
25 * A Session is created by a SessionManager and is uniquely identified by its sessionId. More accurately, this
26 * sessionId is unique within the set of SessionManagers from which this Session has been sourced. If two Sessions
27 * have the same sessionId, then a client can be sure that they have been created from two distinct set of
28 * SessionManagers.
29 * <p>
30 * A Session provides Map like contracts to manipulate state information. State information must be Serializable as
31 * it may be marshalled automatically by the underpinning local SessionManager. At any given point of time, a Session
32 * is uniquely "instantiated" once cluster wide. Also, cluster wide accesses to a given Session are
33 * ensured to be serialized by the set of SessionManagers from which the Session has been sourced. The interposition
34 * of a ClusteredInvocation between a client and the Session this client would like to access enforces unique
35 * instantiation and access serialization cluster wide for a given Session.
36 *
37 * @version $Rev$ $Date$
38 */
39 public interface Session {
40
41 /**
42 * Gets the sessionId.
43 *
44 * @return sessionId.
45 */
46 String getSessionId();
47
48 /**
49 * Map like contract to manipulate state information.
50 */
51 Object addState(String key, Object value);
52
53 /**
54 * Map like contract to manipulate state information.
55 */
56 Object getState(String key);
57
58 /**
59 * Map like contract to manipulate state information.
60 */
61 Object removeState(String key);
62
63 /**
64 * Map like contract to manipulate state information.
65 * <p>
66 * The returned Map is mutable and is backed by the session.
67 */
68 Map getState();
69
70 /**
71 * Releases the session.
72 * <p>
73 * When a Session is released, it is released from the underlying set of SessionManagers. In other words, its
74 * sessionId is unknown and its state is permanently lost. After the release of a Session, the behavior of
75 * the other methods is undefined.
76 */
77 void release();
78
79 }