diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java')
-rw-r--r-- | bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java new file mode 100644 index 000000000..44ed9f113 --- /dev/null +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/ServletConfigImpl.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2005 Cognos Incorporated. + * 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 + *******************************************************************************/ + +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(); + } +} |