01: /*
02: * $Id: $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21: package org.apache.struts2.portlet.servlet;
22:
23: import java.util.Enumeration;
24:
25: import javax.portlet.PortletConfig;
26: import javax.portlet.PortletContext;
27: import javax.servlet.ServletConfig;
28: import javax.servlet.ServletContext;
29:
30: /**
31: * Wrapper object exposing a {@link PortletConfig} as a {@link ServletConfig} instance.
32: * Clients accessing this config object will in fact operate on the
33: * {@link PortletConfig} object wrapped by this config object.
34: */
35: public class PortletServletConfig implements ServletConfig {
36:
37: private PortletConfig portletConfig;
38:
39: public PortletServletConfig(PortletConfig portletConfig) {
40: this .portletConfig = portletConfig;
41: }
42:
43: /* (non-Javadoc)
44: * @see javax.servlet.ServletConfig#getInitParameter(java.lang.String)
45: */
46: public String getInitParameter(String name) {
47: return portletConfig.getInitParameter(name);
48: }
49:
50: /* (non-Javadoc)
51: * @see javax.servlet.ServletConfig#getInitParameterNames()
52: */
53: public Enumeration getInitParameterNames() {
54: return portletConfig.getInitParameterNames();
55: }
56:
57: /**
58: * Get the {@link PortletContext} as a {@link PortletServletContext} instance.
59: * @see javax.servlet.ServletConfig#getServletContext()
60: */
61: public ServletContext getServletContext() {
62: return new PortletServletContext(portletConfig
63: .getPortletContext());
64: }
65:
66: /**
67: * Will return the portlet name.
68: * @see javax.servlet.ServletConfig#getServletName()
69: */
70: public String getServletName() {
71: return portletConfig.getPortletName();
72: }
73:
74: /**
75: * Get the wrapped {@link PortletConfig} instance.
76: * @return The wrapped {@link PortletConfig} instance.
77: */
78: public PortletConfig getPortletConfig() {
79: return portletConfig;
80: }
81:
82: }
|