View Javadoc

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  /**
21   * Represents a local SessionManager.
22   * <p>
23   * A local SessionManager works collaboratively with remote SessionManagers to manage Session instances. A local 
24   * SessionMananger along with its associated remote SessionManagers are a single space where Session instances live.
25   * In this space, each Session is ensured to have a unique sessionId. This contract is enforced during creation of
26   * a Session instance by a local SessionManager. A Session in this space is preemptively migrated from one local 
27   * SessionManager to another. The interposition of a ClusteredInvocation between a Client and the Session he wants to
28   * access ensures that at any point in time a Session is uniquely instantiated once cluster wide. Clients can
29   * receive migration callbacks via the registration of SessionListener.
30   *
31   * @version $Rev$ $Date$
32   */
33  public interface SessionManager {
34      
35      /**
36       * Creates a Session having the specified sessionId.
37       * 
38       * @param sessionId Unique identifier of the Session instance.
39       * @return Session instance.
40       * @throws SessionAlreadyExistException Thrown when the provided sessiondId already exists in the Session space
41       * of this local SessionManager and its associated remote SessionManagers.
42       */
43      Session createSession(String sessionId) throws SessionAlreadyExistException;
44      
45      /**
46       * Registers a migration listener. 
47       */
48      void registerListener(SessionListener listener);    
49  
50      /**
51       * Unregisters a migration listener.
52       */
53      void unregisterListener(SessionListener listener);    
54  
55      /**
56       * Gets the Node hosting this local SessionManager.
57       * 
58       * @return Hosting Node.
59       */
60      Node getNode();
61  
62  }