KickJava   Java API By Example, From Geeks To Geeks.

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


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  * A simple Action that tracks if a <code>Session</code> object
30  * has been created or not.
31  *
32  * @author <a HREF="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
33  * @version CVS $Id: HelloAction.java 30932 2004-07-29 17:35:38Z vgritsenko $
34  */

35 public class HelloAction extends ServiceableAction implements ThreadSafe {
36
37     /**
38      * A simple Action that logs if the <code>Session</code> object
39      * has been created
40      */

41     public Map JavaDoc act (Redirector redirector, SourceResolver resolver, Map JavaDoc objectModel, String JavaDoc src, Parameters par) throws Exception JavaDoc {
42         Request request = ObjectModelHelper.getRequest(objectModel);
43         if (request != null) {
44             Session session = request.getSession (false);
45
46             if (session != null) {
47                 if (session.isNew()) {
48                     getLogger().debug("Session is new");
49                 } else {
50                     getLogger().debug("Session is old");
51                 }
52             } else {
53                 getLogger().debug("A session object was not created");
54             }
55         }
56
57         return null;
58     }
59 }
60
61
62
63
Popular Tags