blob: 51951e1476a477eeadf5609e982e265ed5555153 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*******************************************************************************
* Copyright (c) 2005, 2007 Cognos Incorporated, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Cognos Incorporated - initial API and implementation
* IBM Corporation - bug fixes and enhancements
*******************************************************************************/
package org.eclipse.equinox.http.servlet.internal;
import java.util.*;
import javax.servlet.*;
public class ServletConfigImpl implements ServletConfig {
private static final Dictionary EMPTY_PARAMS = new Hashtable(0);
private static final String SERVLET_NAME = "servlet-name"; //$NON-NLS-1$
private Servlet servlet;
private Dictionary initparams;
private ServletContext servletContext;
public ServletConfigImpl(Servlet servlet, Dictionary initparams, ServletContext servletContext) {
this.servlet = servlet;
this.initparams = (initparams != null) ? initparams : EMPTY_PARAMS;
this.servletContext = servletContext;
}
/*
* @see javax.servlet.ServletConfig#getServletName()
*
* The OSGi Http Service does not specify a way to set a servlet name at the API level. This
* implementation will try to use the value of the "servlet-name" initial parameter if available.
*/
public String getServletName() {
String servletName = (String) initparams.get(SERVLET_NAME);
return (servletName != null) ? servletName : servlet.getClass().getName();
}
public ServletContext getServletContext() {
return servletContext;
}
public String getInitParameter(String name) {
return (String) initparams.get(name);
}
public Enumeration getInitParameterNames() {
return initparams.keys();
}
}
|