本文整理汇总了Java中javax.ws.rs.ext.WriterInterceptorContext.proceed方法的典型用法代码示例。如果您正苦于以下问题:Java WriterInterceptorContext.proceed方法的具体用法?Java WriterInterceptorContext.proceed怎么用?Java WriterInterceptorContext.proceed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.ext.WriterInterceptorContext
的用法示例。
在下文中一共展示了WriterInterceptorContext.proceed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
MessageDigest digest = null;
try {
digest = getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException(e);
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DigestOutputStream digestStream = new DigestOutputStream(buffer, digest);
OutputStream old = context.getOutputStream();
context.setOutputStream(digestStream);
try {
context.proceed();
byte[] hash = digest.digest();
String encodedHash = getEncoder().encodeToString(hash);
context.getHeaders().putSingle(CONTENT_MD5_STRING, encodedHash);
byte[] content = buffer.toByteArray();
old.write(content);
} finally {
context.setOutputStream(old);
}
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:27,代码来源:ContentMD5Writer.java
示例2: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
if (!isVersioningSupported(context)) {
context.proceed();
return;
}
String targetVersion = Version.get(context);
Object source = context.getEntity();
if (source instanceof Collection) {
context.setEntity(convertCollectionToLowerVersion(targetVersion, (Collection<?>)source));
} else {
mapper.map(source);
context.setEntity(converter.convertToLowerVersion(targetVersion, source));
}
Type targetType = getVersionType(context.getGenericType(), targetVersion);
context.setType(toClass(targetType));
context.setGenericType(targetType);
context.proceed();
Version.unset(context);
}
示例3: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext wic) throws IOException, WebApplicationException {
System.out.println("MyServerWriterInterceptor");
wic.setOutputStream(new FilterOutputStream(wic.getOutputStream()) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@Override
public void write(int b) throws IOException {
baos.write(b);
super.write(b);
}
@Override
public void close() throws IOException {
System.out.println("MyServerWriterInterceptor --> " + baos.toString());
super.close();
}
});
wic.proceed();
}
示例4: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
if (!context.getHeaders().containsKey(HttpHeaders.CONTENT_LENGTH)) {
Object entity = context.getEntity();
StreamingProcess<Object> process = MessageHelper.getStreamingProcess(entity, manager);
if (process != null) {
long length = process.length(entity);
if (length != -1)
context.getHeaders().putSingle(HttpHeaders.CONTENT_LENGTH, length);
}
}
context.proceed();
}
示例5: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext)
throws IOException, WebApplicationException {
final LoggingStream stream = (LoggingStream) writerInterceptorContext.getProperty(ENTITY_LOGGER_PROPERTY);
writerInterceptorContext.proceed();
final Object requestId = Requests.getProperty(LOGGING_ID_PROPERTY);
final long id = requestId != null ? (Long) requestId : _id.incrementAndGet();
StringBuilder b = (StringBuilder) writerInterceptorContext.getProperty(LOGGER_BUFFER_PROPERTY);
if (b == null) {
b = new StringBuilder();
writerInterceptorContext.setProperty(LOGGER_BUFFER_PROPERTY, b);
}
printPrefixedHeaders(b, id, RESPONSE_PREFIX, HeaderUtils.asStringHeaders(writerInterceptorContext.getHeaders()));
if (stream != null) {
log(stream.getStringBuilder(MessageUtils.getCharset(writerInterceptorContext.getMediaType())));
} else {
log(b);
}
}
示例6: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
final Object entity = context.getEntity();
if (entity instanceof Viewable) {
User user = (User) securityContext.getUserPrincipal();
if ( ((Viewable) entity).getModel() instanceof ViewData) {
ViewData model = ((ViewData) ((Viewable) entity).getModel());
model.set("authUser", user);
String templateName = ((Viewable) entity).getTemplateName();
context.setEntity(new Viewable(templateName, model.getData()));
}
}
context.proceed();
}
示例7: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
final List<String> requestHeader = httpHeaders.getRequestHeader(HttpHeaders.ACCEPT_ENCODING);
if (requestHeader != null && requestHeader.contains("gzip")) {
context.setOutputStream(new GZIPOutputStream(context.getOutputStream()));
context.getHeaders().add(HttpHeaders.CONTENT_ENCODING, "gzip");
}
context.proceed();
}
示例8: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
final LoggingStream stream = (LoggingStream) context.getProperty("client.LoggingStream");
context.proceed();
if (stream != null) {
System.out.printf("Body: %s\n", stream.getString(StandardCharsets.UTF_8));
}
System.out.printf("-----------\n");
}
示例9: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException {
MultivaluedMap<String, Object> headers = context.getHeaders();
headers.add("Content-Encoding", "gzip");
final OutputStream outputStream = context.getOutputStream();
context.setOutputStream(new GZIPOutputStream(outputStream));
context.proceed();
}
开发者ID:durimkryeziu,项目名称:jersey-2.x-webapp-for-servlet-container,代码行数:11,代码来源:GZIPWriterInterceptor.java
示例10: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException {
MultivaluedMap<String, Object> responseHeaders = context.getHeaders();
Object rangeHeader = responseHeaders.getFirst("Content-Range");
// Use a custom header here
// Some clients needs to know the content length in response headers in order to display a loading state
// Browsers don't let programmers to change the default "Accept-Encoding" header, then we use a custom one.
String acceptEncoding = requestHeaders.getHeaderString("x-accept-encoding");
GZIPOutputStream gzipOutputStream = null;
if (acceptEncoding != null && acceptEncoding.equals("identity")) {
responseHeaders.add("Content-Encoding", "identity");
} else if (rangeHeader == null) {
responseHeaders.add("Content-Encoding", "gzip");
responseHeaders.remove("Content-Length");
gzipOutputStream = new GZIPOutputStream(context.getOutputStream(), DEFAULT_BUFFER_SIZE);
context.setOutputStream(gzipOutputStream);
}
try {
context.proceed();
} finally {
if (gzipOutputStream != null) {
gzipOutputStream.finish();
}
}
}
示例11: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
public void aroundWriteTo(WriterInterceptorContext context)
throws IOException, WebApplicationException {
TraceContext traceContext = tracer.startSpan("MessageBodyWriter#writeTo");
try {
context.proceed();
} finally {
tracer.endSpan(traceContext);
}
}
开发者ID:GoogleCloudPlatform,项目名称:cloud-trace-java-instrumentation,代码行数:10,代码来源:TraceMessageBodyInterceptor.java
示例12: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException
{
MessageDigest digest = null;
try
{
digest = MessageDigest.getInstance("MD5");
}
catch (NoSuchAlgorithmException e)
{
throw new IllegalArgumentException(e);
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DigestOutputStream digestStream = new DigestOutputStream(buffer, digest);
OutputStream old = context.getOutputStream();
context.setOutputStream(digestStream);
try
{
context.proceed();
byte[] hash = digest.digest();
String encodedHash = Base64.encodeBytes(hash);
context.getHeaders().putSingle("Content-MD5", encodedHash);
byte[] content = buffer.toByteArray();
old.write(content);
}
finally
{
context.setOutputStream(old);
}
}
示例13: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public final void aroundWriteTo(WriterInterceptorContext context) throws IOException {
if (isBase64(context)) {
context.setOutputStream(Base64.getEncoder().wrap(context.getOutputStream()));
}
context.proceed();
}
示例14: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context)
throws IOException, WebApplicationException {
try (ActiveSpan activeSpan = decorateWrite(context, buildSpan(context, "serialize"))) {
try {
context.proceed();
} catch (Exception e) {
Tags.ERROR.set(activeSpan, true);
throw e;
}
}
}
示例15: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
public void aroundWriteTo(WriterInterceptorContext ctx) throws IOException, WebApplicationException {
ByteArrayInterceptingOutputStream interceptOS = new ByteArrayInterceptingOutputStream(ctx.getOutputStream());
ctx.setOutputStream(interceptOS);
ctx.proceed();
if (!ctx.getHeaders().containsKey(header)) {
String xhubHeaderValue = XHub.generateHeaderXHubToken(getEncoder(), getHash(), Objects.requireNonNull(token, "cannot encode with a null token"), interceptOS.interceptedContent());
ctx.getHeaders().putSingle(header, xhubHeaderValue);
}
return;
}