blob: 06174a0e93e5c7de6c131a4fe68ac6b19f9ff334 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.ambari.infra.conf;
import java.time.Duration;
import javax.inject.Inject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;
@Component
public class InfraManagerWebServerCustomizer implements WebServerFactoryCustomizer<JettyServletWebServerFactory> {
@Value("${infra-manager.server.port:61890}")
private int port;
@Inject
private ServerProperties serverProperties;
private static final Integer SESSION_TIMEOUT = 60 * 30;
private static final String INFRA_MANAGER_SESSIONID = "INFRAMANAGER_SESSIONID";
private static final String INFRA_MANAGER_APPLICATION_NAME = "infra-manager";
@Override
public void customize(JettyServletWebServerFactory factory) {
factory.setPort(port);
factory.setDisplayName(INFRA_MANAGER_APPLICATION_NAME);
factory.getSession().getCookie().setName(INFRA_MANAGER_SESSIONID);
factory.getSession().setTimeout(Duration.ofSeconds(SESSION_TIMEOUT));
}
}