KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > webapps > session > SessionManager


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.webapps.session;
17
18 import org.apache.cocoon.ProcessingException;
19 import org.apache.cocoon.environment.Session;
20 import org.apache.cocoon.xml.XMLConsumer;
21 import org.w3c.dom.DocumentFragment JavaDoc;
22 import org.xml.sax.SAXException JavaDoc;
23
24 /**
25  *
26  * This is the session manager component.
27  *
28  * The main purpose of this component is creating and termination sessions
29  *
30  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
31  * @version CVS $Id: SessionManager.java 30932 2004-07-29 17:35:38Z vgritsenko $
32 */

33 public interface SessionManager {
34
35     /** Avalon role */
36     String JavaDoc ROLE = SessionManager.class.getName();;
37
38     /**
39      * Create a new session for the user.
40      * A new session is created for this user. If the user has already a session,
41      * no new session is created and the old one is returned.
42      */

43     Session createSession();
44
45     /**
46      * Get the session for the current user.
47      * If the user has no session right now, <CODE>null</CODE> is returned.
48      * If createFlag is true, the session is created if it does not exist.
49      */

50     Session getSession(boolean createFlag);
51
52     /**
53      * Terminate the current session.
54      * If the user has a session, this session is terminated and all of its
55      * data is deleted.
56      * @param force If this is set to true the session is terminated, if
57      * it is set to false, the session is only terminated
58      * if no session context is available.
59      */

60     void terminateSession(boolean force)
61     throws ProcessingException;
62
63
64     /**
65      * Get information from the context.
66      * A document fragment containg the xml data stored in the session context
67      * with the given name is returned. If the information is not available,
68      * <CODE>null</CODE> is returned.
69      * @param contextName The name of the public context.
70      * @param path XPath expression specifying which data to get.
71      * @return A DocumentFragment containing the data or <CODE>null</CODE>
72      */

73     DocumentFragment JavaDoc getContextFragment(String JavaDoc contextName,
74                                         String JavaDoc path)
75     throws ProcessingException;
76
77     /**
78      * Stream public context data.
79      * The document fragment containing the data from a path in the
80      * given context is streamed to the consumer.
81      *
82      * @param contextName The name of the public context.
83      * @param path XPath expression specifying which data to get.
84      *
85      * @return If the data is available <code>true</code> is returned,
86      * otherwise <code>false</code> is returned.
87      */

88     boolean streamContextFragment(String JavaDoc contextName,
89                                   String JavaDoc path,
90                                   XMLConsumer consumer)
91     throws SAXException JavaDoc, ProcessingException;
92
93     /**
94      * Set data in a public context.
95      * The document fragment containing the data is set at the given path in the
96      * public session context.
97      *
98      * @param contextName The name of the public context.
99      * @param path XPath expression specifying where to set the data.
100      * @param fragment The DocumentFragment containing the data.
101      *
102      */

103     void setContextFragment(String JavaDoc contextName,
104                             String JavaDoc path,
105                             DocumentFragment JavaDoc fragment)
106     throws ProcessingException;
107
108     /**
109      * Append data in a public context.
110      * The document fragment containing the data is appended at the given
111      * path in the public session context.
112      *
113      * @param contextName The name of the public context.
114      * @param path XPath expression specifying where to append the data.
115      * @param fragment The DocumentFragment containing the data.
116      *
117      */

118     void appendContextFragment(String JavaDoc contextName,
119                                 String JavaDoc path,
120                                 DocumentFragment JavaDoc fragment)
121     throws ProcessingException;
122
123     /**
124      * Merge data in a public context.
125      * The document fragment containing the data is merged at the given
126      * path in the public session context.
127      *
128      * @param contextName The name of the public context.
129      * @param path XPath expression specifying where to merge the data.
130      * @param fragment The DocumentFragment containing the data.
131      *
132      */

133     void mergeContextFragment(String JavaDoc contextName,
134                                String JavaDoc path,
135                                DocumentFragment JavaDoc fragment)
136     throws ProcessingException;
137
138     /**
139      * Remove data in a public context.
140      * The data specified by the path is removed from the public session context.
141      *
142      * @param contextName The name of the public context.
143      * @param path XPath expression specifying where to merge the data.
144      *
145      */

146     void removeContextFragment(String JavaDoc contextName,
147                                 String JavaDoc path)
148     throws ProcessingException;
149
150 }
151
Popular Tags