001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.geronimo.clustering; 019 020 import java.util.Map; 021 022 /** 023 * Represents a clustered session. 024 * <p> 025 * A Session is created by a SessionManager and is uniquely identified by its sessionId. More accurately, this 026 * sessionId is unique within the set of SessionManagers from which this Session has been sourced. If two Sessions 027 * have the same sessionId, then a client can be sure that they have been created from two distinct set of 028 * SessionManagers. 029 * <p> 030 * A Session provides Map like contracts to manipulate state information. State information must be Serializable as 031 * it may be marshalled automatically by the underpinning local SessionManager. At any given point of time, a Session 032 * is uniquely "instantiated" once cluster wide. Also, cluster wide accesses to a given Session are 033 * ensured to be serialized by the set of SessionManagers from which the Session has been sourced. The interposition 034 * of a ClusteredInvocation between a client and the Session this client would like to access enforces unique 035 * instantiation and access serialization cluster wide for a given Session. 036 * 037 * @version $Rev$ $Date$ 038 */ 039 public interface Session { 040 041 /** 042 * Gets the sessionId. 043 * 044 * @return sessionId. 045 */ 046 String getSessionId(); 047 048 /** 049 * Map like contract to manipulate state information. 050 */ 051 Object addState(String key, Object value); 052 053 /** 054 * Map like contract to manipulate state information. 055 */ 056 Object getState(String key); 057 058 /** 059 * Map like contract to manipulate state information. 060 */ 061 Object removeState(String key); 062 063 /** 064 * Map like contract to manipulate state information. 065 * <p> 066 * The returned Map is mutable and is backed by the session. 067 */ 068 Map getState(); 069 070 /** 071 * Releases the session. 072 * <p> 073 * When a Session is released, it is released from the underlying set of SessionManagers. In other words, its 074 * sessionId is unknown and its state is permanently lost. After the release of a Session, the behavior of 075 * the other methods is undefined. 076 */ 077 void release(); 078 079 }