KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > webapps > authentication > user > RequestState


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.authentication.user;
17
18 import org.apache.avalon.framework.configuration.Configuration;
19 import org.apache.cocoon.ProcessingException;
20 import org.apache.cocoon.webapps.authentication.configuration.ApplicationConfiguration;
21 import org.apache.excalibur.source.SourceResolver;
22
23
24 /**
25  * The state of the user for the current request.
26  * This object holds the information which handler and application
27  * is currently used for this request.
28  *
29  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
30  * @version CVS $Id: RequestState.java 30932 2004-07-29 17:35:38Z vgritsenko $
31 */

32 public final class RequestState
33 implements java.io.Serializable JavaDoc {
34
35     /** The handlers */
36     private UserHandler handler;
37         
38     /** The application */
39     private String JavaDoc application;
40     
41     /**
42      * Create a new handler object.
43      */

44     public RequestState(UserHandler handler, String JavaDoc app) {
45         this.handler = handler;
46         this.application = app;
47     }
48     
49     /**
50      * Initialize
51      */

52     public void initialize(SourceResolver resolver)
53     throws ProcessingException {
54         if ( this.application != null && !this.handler.getApplicationsLoaded()) {
55             ApplicationConfiguration conf = (ApplicationConfiguration) this.handler.getHandlerConfiguration().getApplications().get(this.application);
56             if ( !this.handler.isApplicationLoaded( conf ) ) {
57                 this.handler.getContext().loadApplicationXML( conf, resolver );
58             }
59         }
60     }
61
62     public String JavaDoc getApplicationName() {
63         return this.application;
64     }
65     
66     public UserHandler getHandler() {
67         return this.handler;
68     }
69     
70     public String JavaDoc getHandlerName() {
71         return this.handler.getHandlerName();
72     }
73     
74     public ApplicationConfiguration getApplicationConfiguration() {
75         if ( this.application != null ) {
76             return (ApplicationConfiguration)this.handler.getHandlerConfiguration().getApplications().get(this.application);
77         }
78         return null;
79     }
80     
81     /**
82      * Get the configuration if available
83      */

84     public Configuration getModuleConfiguration(String JavaDoc name) {
85         Configuration conf = null;
86
87         if (this.handler != null && this.application != null) {
88             conf = this.getApplicationConfiguration().getConfiguration(name);
89         }
90         if (this.handler != null && conf == null) {
91             conf = this.handler.getHandlerConfiguration().getConfiguration(name);
92         }
93
94         return conf;
95     }
96 }
97
Popular Tags