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

17
18
19 package org.apache.catalina.core;
20
21
22 import java.util.Enumeration;
23
24 import javax.servlet.ServletConfig;
25 import javax.servlet.ServletContext;
26
27
28 /**
29  * Facade for the <b>StandardWrapper</b> object.
30  *
31  * @author Remy Maucherat
32  */

33 public final class StandardWrapperFacade
34     implements ServletConfig {
35
36
37     // ----------------------------------------------------------- Constructors
38
39
40     /**
41      * Create a new facade around a StandardWrapper.
42      * @param config the associated wrapper
43      */

44     public StandardWrapperFacade(StandardWrapper config) {
45
46         super();
47         this.config = config;
48
49     }
50
51
52     // ----------------------------------------------------- Instance Variables
53
54
55     /**
56      * Wrapped config.
57      */

58     private final ServletConfig config;
59
60
61     /**
62      * Wrapped context (facade).
63      */

64     private ServletContext context = null;
65
66
67     // -------------------------------------------------- ServletConfig Methods
68
69
70     @Override
71     public String getServletName() {
72         return config.getServletName();
73     }
74
75
76     @Override
77     public ServletContext getServletContext() {
78         if (context == null) {
79             context = config.getServletContext();
80             if (context instanceof ApplicationContext) {
81                 context = ((ApplicationContext) context).getFacade();
82             }
83         }
84         return context;
85     }
86
87
88     @Override
89     public String getInitParameter(String name) {
90         return config.getInitParameter(name);
91     }
92
93
94     @Override
95     public Enumeration<String> getInitParameterNames() {
96         return config.getInitParameterNames();
97     }
98
99
100 }
101