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

io.helidon.microprofile.server.WebServerBinder Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2017, 2023 Oracle and/or its affiliates.
 *
 * 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.helidon.microprofile.server;

import io.helidon.webserver.http.ServerRequest;
import io.helidon.webserver.http.ServerResponse;

import jakarta.inject.Inject;
import jakarta.inject.Provider;
import jakarta.ws.rs.core.GenericType;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.glassfish.jersey.internal.inject.ReferencingFactory;
import org.glassfish.jersey.internal.util.collection.Ref;
import org.glassfish.jersey.process.internal.RequestScoped;

/**
 * An internal binder to enable WebServer specific types injection.
 * 

* This binder allows to inject underlying WebServer HTTP request and response instances. */ class WebServerBinder extends AbstractBinder { // Inspired by {@code GrizzlyHttpContainer.GrizzlyBinder} from Jersey to Grizzly integration. @Override protected void configure() { bindFactory(WebServerRequestReferencingFactory.class).to(ServerRequest.class) .proxy(true).proxyForSameScope(false) .in(RequestScoped.class); bindFactory(ReferencingFactory.referenceFactory()).to(new GenericType>() { }) .in(RequestScoped.class); bindFactory(WebServerResponseReferencingFactory.class).to(ServerResponse.class) .proxy(true).proxyForSameScope(false) .in(RequestScoped.class); bindFactory(ReferencingFactory.referenceFactory()).to(new GenericType>() { }) .in(RequestScoped.class); } private static class WebServerRequestReferencingFactory extends ReferencingFactory { @Inject WebServerRequestReferencingFactory(final Provider> referenceFactory) { super(referenceFactory); } } private static class WebServerResponseReferencingFactory extends ReferencingFactory { @Inject WebServerResponseReferencingFactory(final Provider> referenceFactory) { super(referenceFactory); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy