All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.inverno.mod.http.server.internal.http1x.Http1xConnectionFactory Maven / Gradle / Ivy

There is a newer version: 1.11.0
Show newest version
/*
 * Copyright 2020 Jeremy KUHN
 *
 * Licensed 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 io.inverno.mod.http.server.internal.http1x;

import io.inverno.core.annotation.Bean;
import io.inverno.core.annotation.Bean.Visibility;
import io.inverno.mod.base.converter.ObjectConverter;
import io.inverno.mod.http.base.ExchangeContext;
import io.inverno.mod.http.base.Parameter;
import io.inverno.mod.http.base.header.HeaderService;
import io.inverno.mod.http.base.internal.ws.GenericWebSocketFrame;
import io.inverno.mod.http.base.internal.ws.GenericWebSocketMessage;
import io.inverno.mod.http.server.ErrorExchange;
import io.inverno.mod.http.server.Exchange;
import io.inverno.mod.http.server.HttpServerConfiguration;
import io.inverno.mod.http.server.Part;
import io.inverno.mod.http.server.ServerController;
import io.inverno.mod.http.server.internal.multipart.MultipartDecoder;
import java.util.function.Supplier;

/**
 * 

* A factory to create {@link Http1xConnection} when a HTTP/1.x channel is initialized. *

* * @author Jeremy Kuhn * @since 1.0 */ @Bean(visibility = Visibility.PRIVATE) public class Http1xConnectionFactory implements Supplier { private final HttpServerConfiguration configuration; private final ServerController, ErrorExchange> controller; private final HeaderService headerService; private final ObjectConverter parameterConverter; private final MultipartDecoder urlEncodedBodyDecoder; private final MultipartDecoder multipartBodyDecoder; private final GenericWebSocketFrame.GenericFactory webSocketFrameFactory; private final GenericWebSocketMessage.GenericFactory webSocketMessageFactory; /** *

* Creates a HTTP1.x connection factory. *

* * @param configuration the server configuration * @param controller the server controller * @param headerService the header service * @param parameterConverter a string object converter * @param urlEncodedBodyDecoder the application/x-www-form-urlencoded body decoder * @param multipartBodyDecoder the multipart/form-data body decoder */ @SuppressWarnings({ "unchecked" }) public Http1xConnectionFactory( HttpServerConfiguration configuration, ServerController, ? extends ErrorExchange> controller, HeaderService headerService, ObjectConverter parameterConverter, MultipartDecoder urlEncodedBodyDecoder, MultipartDecoder multipartBodyDecoder) { this.configuration = configuration; this.controller = (ServerController, ErrorExchange>)controller; this.headerService = headerService; this.parameterConverter = parameterConverter; this.urlEncodedBodyDecoder = urlEncodedBodyDecoder; this.multipartBodyDecoder = multipartBodyDecoder; this.webSocketFrameFactory = new GenericWebSocketFrame.GenericFactory(configuration.ws_max_frame_size()); this.webSocketMessageFactory = new GenericWebSocketMessage.GenericFactory(configuration.ws_max_frame_size()); } @Override public Http1xConnection get() { return new Http1xConnection(this.configuration, this.controller, this.headerService, this.parameterConverter, this.urlEncodedBodyDecoder, this.multipartBodyDecoder, this.webSocketFrameFactory, this.webSocketMessageFactory); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy