001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.clustering;
018    
019    import java.util.Set;
020    
021    /**
022     * Represents a local SessionManager.
023     * <p>
024     * A local SessionManager works collaboratively with remote SessionManagers to manage Session instances. A local 
025     * SessionMananger along with its associated remote SessionManagers are a single space where Session instances live.
026     * In this space, each Session is ensured to have a unique sessionId. This contract is enforced during creation of
027     * a Session instance by a local SessionManager. A Session in this space is preemptively migrated from one local 
028     * SessionManager to another. The interposition of a ClusteredInvocation between a Client and the Session he wants to
029     * access ensures that at any point in time a Session is uniquely instantiated once cluster wide. Clients can
030     * receive migration callbacks via the registration of SessionListener.
031     *
032     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
033     */
034    public interface SessionManager {
035        
036        /**
037         * Creates a Session having the specified sessionId.
038         * 
039         * @param sessionId Unique identifier of the Session instance.
040         * @return Session instance.
041         * @throws SessionAlreadyExistException Thrown when the provided sessiondId already exists in the Session space
042         * of this local SessionManager and its associated remote SessionManagers.
043         */
044        Session createSession(String sessionId) throws SessionAlreadyExistException;
045        
046        /**
047         * Registers a migration listener. 
048         */
049        void registerListener(SessionListener listener);    
050    
051        /**
052         * Unregisters a migration listener.
053         */
054        void unregisterListener(SessionListener listener);    
055    
056        /**
057         * Gets the Node hosting this local SessionManager.
058         * 
059         * @return Hosting Node.
060         */
061        Node getNode();
062    
063        /**
064         * Gets the remote Nodes hosting the corresponding remote SessionManagers.
065         * 
066         * @return Hosting Node.
067         */
068        Set<Node> getRemoteNodes();
069    }