KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > acting > SessionInvalidatorAction


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.acting;
17
18 import org.apache.avalon.framework.parameters.Parameters;
19 import org.apache.avalon.framework.thread.ThreadSafe;
20 import org.apache.cocoon.environment.ObjectModelHelper;
21 import org.apache.cocoon.environment.Redirector;
22 import org.apache.cocoon.environment.Request;
23 import org.apache.cocoon.environment.Session;
24 import org.apache.cocoon.environment.SourceResolver;
25
26 import java.util.Map JavaDoc;
27
28 /**
29  * This is the action used to invalidate an HTTP session. The action returns
30  * empty map if everything is ok, null otherwise.
31  *
32  * @author <a HREF="mailto:Martin.Man@seznam.cz">Martin Man</a>
33  * @version CVS $Id: SessionInvalidatorAction.java 30932 2004-07-29 17:35:38Z vgritsenko $
34  */

35 public class SessionInvalidatorAction extends AbstractAction implements ThreadSafe
36 {
37     /**
38      * Main invocation routine.
39      */

40     public Map JavaDoc act (Redirector redirector, SourceResolver resolver, Map JavaDoc objectModel, String JavaDoc src,
41             Parameters parameters) throws Exception JavaDoc {
42         Request req = ObjectModelHelper.getRequest(objectModel);
43
44         /* check session validity */
45         Session session = req.getSession (false);
46         if (session != null) {
47             session.invalidate ();
48             if (this.getLogger().isDebugEnabled()) {
49                 getLogger ().debug ("SESSIONINVALIDATOR: session invalidated");
50             }
51         } else {
52             if (this.getLogger().isDebugEnabled()) {
53                 getLogger ().debug ("SESSIONINVALIDATOR: no session object");
54             }
55         }
56
57         return EMPTY_MAP; // cut down on object creation
58
}
59 }
60
Popular Tags