Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
A bundle project producing JAX-RS RI bundles. The primary artifact is an "all-in-one" OSGi-fied JAX-RS RI bundle
(jaxrs-ri.jar).
Attached to that are two compressed JAX-RS RI archives. The first archive (jaxrs-ri.zip) consists of binary RI bits and
contains the API jar (under "api" directory), RI libraries (under "lib" directory) as well as all external
RI dependencies (under "ext" directory). The secondary archive (jaxrs-ri-src.zip) contains buildable JAX-RS RI source
bundle and contains the API jar (under "api" directory), RI sources (under "src" directory) as well as all external
RI dependencies (under "ext" directory). The second archive also contains "build.xml" ANT script that builds the RI
sources. To build the JAX-RS RI simply unzip the archive, cd to the created jaxrs-ri directory and invoke "ant" from
the command line.
/*
* Copyright (c) 2012, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.jersey.client;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
import jakarta.ws.rs.client.ClientRequestContext;
import jakarta.ws.rs.core.CacheControl;
import jakarta.ws.rs.core.Configuration;
import jakarta.ws.rs.core.Cookie;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Variant;
import jakarta.ws.rs.ext.ReaderInterceptor;
import jakarta.ws.rs.ext.WriterInterceptor;
import org.glassfish.jersey.client.internal.LocalizationMessages;
import org.glassfish.jersey.http.HttpHeaders;
import org.glassfish.jersey.internal.MapPropertiesDelegate;
import org.glassfish.jersey.internal.PropertiesDelegate;
import org.glassfish.jersey.internal.guava.Preconditions;
import org.glassfish.jersey.internal.inject.InjectionManager;
import org.glassfish.jersey.internal.inject.InjectionManagerSupplier;
import org.glassfish.jersey.internal.util.ExceptionUtils;
import org.glassfish.jersey.internal.PropertiesResolver;
import org.glassfish.jersey.internal.util.collection.LazyValue;
import org.glassfish.jersey.internal.util.collection.Value;
import org.glassfish.jersey.internal.util.collection.Values;
import org.glassfish.jersey.message.MessageBodyWorkers;
import org.glassfish.jersey.message.internal.HeaderUtils;
import org.glassfish.jersey.message.internal.OutboundMessageContext;
/**
* Jersey client request context.
*
* @author Marek Potociar
*/
public class ClientRequest extends OutboundMessageContext
implements ClientRequestContext, HttpHeaders, InjectionManagerSupplier, PropertiesResolver {
// Request-scoped configuration instance
private final ClientConfig clientConfig;
// Request-scoped properties delegate
private final PropertiesDelegate propertiesDelegate;
// Absolute request URI
private URI requestUri;
// Request method
private String httpMethod;
// Request filter chain execution aborting response
private Response abortResponse;
// Entity providers
private MessageBodyWorkers workers;
// Flag indicating whether the request is asynchronous
private boolean asynchronous;
// true if writeEntity() was already called
private boolean entityWritten;
// writer interceptors used to write the request
private Iterable writerInterceptors;
// reader interceptors used to write the request
private Iterable readerInterceptors;
// do not add user-agent header (if not directly set) to the request.
private boolean ignoreUserAgent;
// lazy PropertiesResolver
private LazyValue propertiesResolver = Values.lazy(
(Value) () -> PropertiesResolver.create(getConfiguration(), getPropertiesDelegate())
);
// by default nothing to be cancelled.
private Future cancellable = NotCancellable.INSTANCE;
private static final Logger LOGGER = Logger.getLogger(ClientRequest.class.getName());
/**
* Create new Jersey client request context.
*
* @param requestUri request Uri.
* @param clientConfig request configuration.
* @param propertiesDelegate properties delegate.
*/
protected ClientRequest(
final URI requestUri, final ClientConfig clientConfig, final PropertiesDelegate propertiesDelegate) {
super(clientConfig.getConfiguration());
clientConfig.checkClient();
this.requestUri = requestUri;
this.clientConfig = clientConfig;
this.propertiesDelegate = propertiesDelegate;
}
/**
* Copy constructor.
*
* @param original original instance.
*/
public ClientRequest(final ClientRequest original) {
super(original);
this.requestUri = original.requestUri;
this.httpMethod = original.httpMethod;
this.workers = original.workers;
this.clientConfig = original.clientConfig.snapshot();
this.asynchronous = original.isAsynchronous();
this.readerInterceptors = original.readerInterceptors;
this.writerInterceptors = original.writerInterceptors;
this.propertiesDelegate = new MapPropertiesDelegate(original.propertiesDelegate);
this.ignoreUserAgent = original.ignoreUserAgent;
this.cancellable = original.cancellable;
}
@Override
public T resolveProperty(final String name, final Class type) {
return propertiesResolver.get().resolveProperty(name, type);
}
@Override
public T resolveProperty(final String name, final T defaultValue) {
return propertiesResolver.get().resolveProperty(name, defaultValue);
}
@Override
public boolean hasProperty(final String name) {
return propertiesDelegate.hasProperty(name);
}
@Override
public Object getProperty(final String name) {
return propertiesDelegate.getProperty(name);
}
@Override
public Collection getPropertyNames() {
return propertiesDelegate.getPropertyNames();
}
@Override
public void setProperty(final String name, final Object object) {
propertiesDelegate.setProperty(name, object);
}
@Override
public void removeProperty(final String name) {
propertiesDelegate.removeProperty(name);
}
/**
* Get the underlying properties delegate.
*
* @return underlying properties delegate.
*/
PropertiesDelegate getPropertiesDelegate() {
return propertiesDelegate;
}
/**
* Get the underlying client runtime.
*
* @return underlying client runtime.
*/
ClientRuntime getClientRuntime() {
return clientConfig.getRuntime();
}
@Override
public URI getUri() {
return requestUri;
}
@Override
public void setUri(final URI uri) {
this.requestUri = uri;
}
@Override
public String getMethod() {
return httpMethod;
}
@Override
public void setMethod(final String method) {
this.httpMethod = method;
}
@Override
public JerseyClient getClient() {
return clientConfig.getClient();
}
@Override
public void abortWith(final Response response) {
this.abortResponse = response;
}
/**
* Get the request filter chain aborting response if set, or {@code null} otherwise.
*
* @return request filter chain aborting response if set, or {@code null} otherwise.
*/
public Response getAbortResponse() {
return abortResponse;
}
@Override
public Configuration getConfiguration() {
return clientConfig.getRuntime().getConfig();
}
/**
* Get internal client configuration state.
*
* @return internal client configuration state.
*/
ClientConfig getClientConfig() {
return clientConfig;
}
/**
* Get the values of an HTTP request header if the header exists on the current request. The returned value will be
* a read-only List if the specified header exists or {@code null} if it does not. This is a shortcut for
* {@code getRequestHeaders().get(name)}.
*
* @param name the header name, case insensitive.
* @return a read-only list of header values if the specified header exists, otherwise {@code null}.
* @throws java.lang.IllegalStateException if called outside the scope of a request.
*/
@Override
public List getRequestHeader(String name) {
final List