KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ha > hasessionstate > interfaces > HASessionState


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ha.hasessionstate.interfaces;
23
24 import org.jboss.ha.hasessionstate.interfaces.PackagedSession;
25 import org.jboss.ha.framework.interfaces.HAPartition;
26
27 /**
28  * Interface for services providing clustered state session availability
29  *
30  * @see org.jboss.ha.hasessionstate.server.HASessionStateImpl
31  *
32  * @author <a HREF="mailto:sacha.labourey@cogito-info.ch">Sacha Labourey</a>
33  * @version $Revision: 37459 $
34  *
35  * <p><b>Revisions:</b><br>
36  */

37
38 public interface HASessionState
39 {
40    
41    public void init () throws Exception JavaDoc;
42    public void start () throws Exception JavaDoc;
43    
44    /**
45     * Information that can be used to clean a cache for example. It indicates that
46     * another node has touched a session that we were previously owning.
47     *
48     */

49    public interface HASessionStateListener
50    {
51       public void sessionExternallyModified (PackagedSession session);
52    }
53    /**
54     * Subscribe to receive notifications when objects gets modified on another node.
55     *
56     */

57    public void subscribe (String JavaDoc appName, HASessionStateListener listener);
58    public void unsubscribe (String JavaDoc appName, HASessionStateListener listener);
59    
60    public HAPartition getCurrentHAPartition ();
61    
62    /**
63     * Return the name of this node as used in the computations
64     */

65    public String JavaDoc getNodeName ();
66    
67    /**
68     * Share a new session state in the sub-partition of this cluster
69     * @param appName Application name for which is state is shared
70     * @param keyId Key identifier of the state
71     */

72    public void createSession (String JavaDoc appName, Object JavaDoc keyId);
73    /**
74     * Modifies a state already shared
75     * @param appName Application name hosting this state
76     * @param keyId Key identifier of the state to modify
77     * @param state New state
78     */

79    public void setState (String JavaDoc appName, Object JavaDoc keyId, byte[] state)
80       throws java.rmi.RemoteException JavaDoc;
81    
82    /**
83     * Get a particular state
84     * @param appName Application hosting the state
85     * @param keyId Key identifier of the state
86     * @return The state value
87     */

88    public PackagedSession getState (String JavaDoc appName, Object JavaDoc keyId);
89    /**
90     * Get a state and, if it is not already the case, takes its ownership (a state is
91     * always owned by a node)
92     * @param appName Application hosting the state
93     * @param keyId Key identifier of the state
94     * @throws java.rmi.RemoteException Thrown if an exception occurs while getting the ownership of the state
95     * @return The state value
96     */

97    public PackagedSession getStateWithOwnership (String JavaDoc appName, Object JavaDoc keyId) throws java.rmi.RemoteException JavaDoc;
98    
99    /**
100     * Take ownership of a state. Each state is owned by a node.
101     * @param appName Application hosting the state
102     * @param keyId Key identifier of the state
103     * @throws java.rmi.RemoteException Trown if a communication exception occurs while asking other node to get the ownership
104     */

105    public void takeOwnership (String JavaDoc appName, Object JavaDoc keyId) throws java.rmi.RemoteException JavaDoc;
106       
107    /**
108     * Remove a session from the sub-partition
109     * @param appName Application hosting the state
110     * @param keyId Key identifier of the state
111     */

112    public void removeSession (String JavaDoc appName, Object JavaDoc keyId);
113    
114 }
115
116
Popular Tags