diff options
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyStaticResourceServer.java')
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyStaticResourceServer.java | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyStaticResourceServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyStaticResourceServer.java index 15d9990b..ee2b0540 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyStaticResourceServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyStaticResourceServer.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023-2024 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +21,6 @@ package org.onap.policy.common.endpoints.http.server.internal; -import java.util.HashMap; -import java.util.Map; import lombok.ToString; import org.apache.commons.lang3.StringUtils; import org.eclipse.jetty.servlet.DefaultServlet; @@ -30,7 +29,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Jetty Server that uses DefaultServlets to support web static resources management. + * Jetty Server that uses DefaultServlets to support web static resources' management. */ @ToString public class JettyStaticResourceServer extends JettyServletServer { @@ -56,24 +55,20 @@ public class JettyStaticResourceServer extends JettyServletServer { protected static Logger logger = LoggerFactory.getLogger(JettyStaticResourceServer.class); /** - * Container for default servlets. - */ - protected final Map<String, ServletHolder> servlets = new HashMap<>(); - - /** * Constructor. * * @param name name * @param https enable https? * @param host host server host * @param port port server port + * @param sniHostCheck SNI Host checking flag * @param contextPath context path - * * @throws IllegalArgumentException in invalid arguments are provided */ - public JettyStaticResourceServer(String name, boolean https, String host, int port, String contextPath) { + public JettyStaticResourceServer(String name, boolean https, String host, int port, boolean sniHostCheck, + String contextPath) { - super(name, https, host, port, contextPath); + super(name, https, host, port, sniHostCheck, contextPath); } /** @@ -84,15 +79,14 @@ public class JettyStaticResourceServer extends JettyServletServer { * * @throws IllegalArgumentException if invalid arguments are provided */ - protected synchronized ServletHolder getDefaultServlet(String servPath) { - - return servlets.computeIfAbsent(servPath, key -> context.addServlet(DefaultServlet.class, servPath)); + protected synchronized ServletHolder getDefaultServlet(String servletPath) { + return super.getServlet(DefaultServlet.class, servletPath); } @Override - public synchronized void addServletResource(String servletPath, String resoureBase) { + public synchronized void addServletResource(String servletPath, String resourceBase) { - if (StringUtils.isBlank(resoureBase)) { + if (StringUtils.isBlank(resourceBase)) { throw new IllegalArgumentException("No resourceBase provided"); } @@ -102,7 +96,7 @@ public class JettyStaticResourceServer extends JettyServletServer { ServletHolder defaultServlet = this.getDefaultServlet(servletPath); - defaultServlet.setInitParameter(SERVLET_HOLDER_RESOURCE_BASE, resoureBase); + defaultServlet.setInitParameter(SERVLET_HOLDER_RESOURCE_BASE, resourceBase); defaultServlet.setInitParameter(SERVLET_HOLDER_DIR_ALLOWED, "false"); defaultServlet.setInitParameter(SERVLET_HOLDER_PATH_INFO_ONLY, "true"); |