diff options
author | Thomas Watson | 2015-08-11 20:52:40 +0000 |
---|---|---|
committer | Thomas Watson | 2015-08-11 20:52:40 +0000 |
commit | 9768ce0f3ebc232ec78118b986350cc589681022 (patch) | |
tree | d0788a92d907398e1e0e0ec24f959508cc8effc3 | |
parent | 38791e1a7de7e6a8cf5f73cb7956490d30ad6d63 (diff) | |
download | rt.equinox.bundles-9768ce0f3ebc232ec78118b986350cc589681022.tar.gz rt.equinox.bundles-9768ce0f3ebc232ec78118b986350cc589681022.tar.xz rt.equinox.bundles-9768ce0f3ebc232ec78118b986350cc589681022.zip |
Bug 474714 - [http whiteboard] regression in accessing parent
ServletContext init params
2 files changed, 17 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java index 569b78d65..874203e7e 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ContextController.java @@ -136,7 +136,7 @@ public class ContextController { this.contextServiceId = serviceId; this.initParams = ServiceProperties.parseInitParams( - servletContextHelperRef, HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX); + servletContextHelperRef, HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX, proxyContext.getServletContext()); this.trackingContext = trackingContextParam; this.consumingContext = consumingContext; diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceProperties.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceProperties.java index 9260a7811..7b24f944a 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceProperties.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceProperties.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) Dec 2, 2014 Liferay, Inc. + * Copyright (c) 2014, 2015 Liferay, Inc. * 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 @@ -13,6 +13,7 @@ package org.eclipse.equinox.http.servlet.internal.util; import java.util.*; +import javax.servlet.ServletContext; import org.osgi.framework.ServiceReference; public class ServiceProperties { @@ -32,10 +33,18 @@ public class ServiceProperties { } static public Map<String, String> parseInitParams( - ServiceReference<?> serviceReference, String prefix) { + ServiceReference<?> serviceReference, String prefix, ServletContext parentContext) { Map<String, String> initParams = new HashMap<String, String>(); + if (parentContext != null) { + // use the parent context init params; + // but allow them to be overriden below by service properties + for (Enumeration<String> initParamNames = parentContext.getInitParameterNames(); initParamNames.hasMoreElements();) { + String key = initParamNames.nextElement(); + initParams.put(key, parentContext.getInitParameter(key)); + } + } for (String key : serviceReference.getPropertyKeys()) { if (key.startsWith(prefix)) { initParams.put( @@ -47,6 +56,11 @@ public class ServiceProperties { return Collections.unmodifiableMap(initParams); } + static public Map<String, String> parseInitParams( + ServiceReference<?> serviceReference, String prefix) { + return parseInitParams(serviceReference, prefix, null); + } + static public String parseName(Object property, Object object) { if (property == null) { return object.getClass().getName(); |