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, 2018 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.message.internal;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.net.URI;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.ws.rs.ProcessingException;
import javax.ws.rs.core.Configuration;
import javax.ws.rs.core.Cookie;
import javax.ws.rs.core.EntityTag;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Link;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.NewCookie;
import javax.ws.rs.ext.RuntimeDelegate;
import org.glassfish.jersey.CommonProperties;
import org.glassfish.jersey.internal.LocalizationMessages;
import org.glassfish.jersey.internal.util.ReflectionHelper;
/**
* Base outbound message context implementation.
*
* @author Marek Potociar (marek.potociar at oracle.com)
*/
public class OutboundMessageContext {
private static final Annotation[] EMPTY_ANNOTATIONS = new Annotation[0];
private static final List WILDCARD_ACCEPTABLE_TYPE_SINGLETON_LIST =
Collections.singletonList(MediaTypes.WILDCARD_ACCEPTABLE_TYPE);
private final MultivaluedMap headers;
private final CommittingOutputStream committingOutputStream;
private Object entity;
private GenericType> entityType;
private Annotation[] entityAnnotations = EMPTY_ANNOTATIONS;
private OutputStream entityStream;
/**
* The callback interface which is used to get the terminal output stream into which the entity should be
* written and to inform the implementation about the entity size.
*/
public static interface StreamProvider {
/**
* Get the output stream. This method will be called after all the
* {@link javax.ws.rs.ext.WriterInterceptor writer interceptors} are called and written entity is buffered
* into the buffer or the buffer exceeds.
*
* @param contentLength the size of the buffered entity or -1 if the entity exceeded the maximum buffer
* size or if the buffering is disabled.
* @return the adapted output stream into which the serialized entity should be written. May return null
* which will cause ignoring the written entity (in that case the entity will
* still be written by {@link javax.ws.rs.ext.MessageBodyWriter message body writers}
* but the output will be ignored).
* @throws java.io.IOException in case of an IO error.
*/
public OutputStream getOutputStream(int contentLength) throws IOException;
}
/**
* Create new outbound message context.
*/
public OutboundMessageContext() {
this.headers = HeaderUtils.createOutbound();
this.committingOutputStream = new CommittingOutputStream();
this.entityStream = committingOutputStream;
}
/**
* Create new outbound message context copying the content
* of another context.
*
* @param original the original outbound message context.
*/
public OutboundMessageContext(OutboundMessageContext original) {
this.headers = HeaderUtils.createOutbound();
this.headers.putAll(original.headers);
this.committingOutputStream = new CommittingOutputStream();
this.entityStream = committingOutputStream;
this.entity = original.entity;
this.entityType = original.entityType;
this.entityAnnotations = original.entityAnnotations;
}
/**
* Replace all headers.
*
* @param headers new headers.
*/
public void replaceHeaders(MultivaluedMap headers) {
getHeaders().clear();
if (headers != null) {
getHeaders().putAll(headers);
}
}
/**
* Get a multi-valued map representing outbound message headers with their values converted
* to strings.
*
* @return multi-valued map of outbound message header names to their string-converted values.
*/
public MultivaluedMap getStringHeaders() {
return HeaderUtils.asStringHeaders(headers);
}
/**
* Get a message header as a single string value.
*
* Each single header value is converted to String using a
* {@link javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate} if one is available
* via {@link javax.ws.rs.ext.RuntimeDelegate#createHeaderDelegate(java.lang.Class)}
* for the header value class or using its {@code toString} method if a header
* delegate is not available.
*
* @param name the message header.
* @return the message header value. If the message header is not present then
* {@code null} is returned. If the message header is present but has no
* value then the empty string is returned. If the message header is present
* more than once then the values of joined together and separated by a ','
* character.
*/
public String getHeaderString(String name) {
return HeaderUtils.asHeaderString(headers.get(name), RuntimeDelegate.getInstance());
}
/**
* Get a single typed header value.
*
* @param header value type.
* @param name header name.
* @param valueType header value class.
* @param converter from string conversion function. Is expected to throw {@link ProcessingException}
* if conversion fails.
* @param convertNull if {@code true} this method calls the provided converter even for {@code null}. Otherwise this
* method returns the {@code null} without calling the converter.
* @return value of the header, or (possibly converted) {@code null} if not present.
*/
private T singleHeader(String name, Class valueType, Function converter, boolean convertNull) {
final List