/** * Read event data as a given generic type. * * @param type generic type to be used for event data de-serialization. * @param mediaType {@link MediaType media type} to be used for event data de-serialization. * @return event data de-serialized as an instance of a given type. * @throws javax.ws.rs.ProcessingException when provided type can't be read. The thrown exception wraps the original cause. * @since 2.3 */ public <T> T readData(GenericType<T> type, MediaType mediaType) { final MediaType effectiveMediaType = mediaType == null ? this.mediaType : mediaType; final MessageBodyReader reader = messageBodyWorkers.getMessageBodyReader(type.getRawType(), type.getType(), annotations, mediaType); if (reader == null) { throw new MessageBodyProviderNotFoundException(LocalizationMessages.EVENT_DATA_READER_NOT_FOUND()); } return readAndCast(type, effectiveMediaType, reader); }
@Override @SuppressWarnings("unchecked") public void aroundWriteTo(final WriterInterceptorContext context) throws WebApplicationException, IOException { processedCount--; //this is not regular interceptor -> count down traceBefore(null, MsgTraceEvent.WI_BEFORE); try { final TracingLogger tracingLogger = getTracingLogger(); if (tracingLogger.isLogEnabled(MsgTraceEvent.MBW_FIND)) { tracingLogger.log(MsgTraceEvent.MBW_FIND, context.getType().getName(), (context.getGenericType() instanceof Class ? ((Class) context.getGenericType()).getName() : context.getGenericType()), context.getMediaType(), java.util.Arrays.toString(context.getAnnotations())); } final MessageBodyWriter writer = workers.getMessageBodyWriter(context.getType(), context.getGenericType(), context.getAnnotations(), context.getMediaType(), WriterInterceptorExecutor.this); if (writer == null) { LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); } invokeWriteTo(context, writer); } finally { clearLastTracedInterceptor(); traceAfter(null, MsgTraceEvent.WI_AFTER); } }
@Override @SuppressWarnings("unchecked") public void aroundWriteTo(final WriterInterceptorContext context) throws WebApplicationException, IOException { processedCount--; //this is not regular interceptor -> count down traceBefore(null, MsgTraceEvent.WI_BEFORE); try { final TracingLogger tracingLogger = getTracingLogger(); if (tracingLogger.isLogEnabled(MsgTraceEvent.MBW_FIND)) { tracingLogger.log(MsgTraceEvent.MBW_FIND, context.getType().getName(), (context.getGenericType() instanceof Class ? ((Class) context.getGenericType()).getName() : context.getGenericType()), context.getMediaType(), java.util.Arrays.toString(context.getAnnotations())); } final MessageBodyWriter writer = workers.getMessageBodyWriter(context.getType(), context.getGenericType(), context.getAnnotations(), context.getMediaType(), WriterInterceptorExecutor.this); if (writer == null) { LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); } invokeWriteTo(context, writer); } finally { clearLastTracedInterceptor(); traceAfter(null, MsgTraceEvent.WI_AFTER); } }
LOGGER.log(Level.FINE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER(context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER( context.getMediaType(), context.getType(), context.getGenericType()));
LOGGER.log(Level.FINE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER(context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER( context.getMediaType(), context.getType(), context.getGenericType()));
@Override @SuppressWarnings("unchecked") public void aroundWriteTo(final WriterInterceptorContext context) throws WebApplicationException, IOException { processedCount--; //this is not regular interceptor -> count down traceBefore(null, MsgTraceEvent.WI_BEFORE); try { final TracingLogger tracingLogger = getTracingLogger(); if (tracingLogger.isLogEnabled(MsgTraceEvent.MBW_FIND)) { tracingLogger.log(MsgTraceEvent.MBW_FIND, context.getType().getName(), (context.getGenericType() instanceof Class ? ((Class) context.getGenericType()).getName() : context.getGenericType()), context.getMediaType(), java.util.Arrays.toString(context.getAnnotations())); } final MessageBodyWriter writer = workers.getMessageBodyWriter(context.getType(), context.getGenericType(), context.getAnnotations(), context.getMediaType(), WriterInterceptorExecutor.this); if (writer == null) { LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); } invokeWriteTo(context, writer); } finally { clearLastTracedInterceptor(); traceAfter(null, MsgTraceEvent.WI_AFTER); } }
@Override @SuppressWarnings("unchecked") public void aroundWriteTo(final WriterInterceptorContext context) throws WebApplicationException, IOException { processedCount--; //this is not regular interceptor -> count down traceBefore(null, MsgTraceEvent.WI_BEFORE); try { final TracingLogger tracingLogger = getTracingLogger(); if (tracingLogger.isLogEnabled(MsgTraceEvent.MBW_FIND)) { tracingLogger.log(MsgTraceEvent.MBW_FIND, context.getType().getName(), (context.getGenericType() instanceof Class ? ((Class) context.getGenericType()).getName() : context.getGenericType()), context.getMediaType(), java.util.Arrays.toString(context.getAnnotations())); } final MessageBodyWriter writer = workers.getMessageBodyWriter(context.getType(), context.getGenericType(), context.getAnnotations(), context.getMediaType(), WriterInterceptorExecutor.this); if (writer == null) { LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); } invokeWriteTo(context, writer); } finally { clearLastTracedInterceptor(); traceAfter(null, MsgTraceEvent.WI_AFTER); } }
@Override @SuppressWarnings("unchecked") public void aroundWriteTo(final WriterInterceptorContext context) throws WebApplicationException, IOException { processedCount--; //this is not regular interceptor -> count down traceBefore(null, MsgTraceEvent.WI_BEFORE); try { final TracingLogger tracingLogger = getTracingLogger(); if (tracingLogger.isLogEnabled(MsgTraceEvent.MBW_FIND)) { tracingLogger.log(MsgTraceEvent.MBW_FIND, context.getType().getName(), (context.getGenericType() instanceof Class ? ((Class) context.getGenericType()).getName() : context.getGenericType()), context.getMediaType(), java.util.Arrays.toString(context.getAnnotations())); } final MessageBodyWriter writer = workers.getMessageBodyWriter(context.getType(), context.getGenericType(), context.getAnnotations(), context.getMediaType(), WriterInterceptorExecutor.this); if (writer == null) { LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); } invokeWriteTo(context, writer); } finally { clearLastTracedInterceptor(); traceAfter(null, MsgTraceEvent.WI_AFTER); } }
@Override @SuppressWarnings("unchecked") public void aroundWriteTo(final WriterInterceptorContext context) throws WebApplicationException, IOException { processedCount--; //this is not regular interceptor -> count down traceBefore(null, MsgTraceEvent.WI_BEFORE); try { final TracingLogger tracingLogger = getTracingLogger(); if (tracingLogger.isLogEnabled(MsgTraceEvent.MBW_FIND)) { tracingLogger.log(MsgTraceEvent.MBW_FIND, context.getType().getName(), (context.getGenericType() instanceof Class ? ((Class) context.getGenericType()).getName() : context.getGenericType()), context.getMediaType(), java.util.Arrays.toString(context.getAnnotations())); } final MessageBodyWriter writer = workers.getMessageBodyWriter(context.getType(), context.getGenericType(), context.getAnnotations(), context.getMediaType(), WriterInterceptorExecutor.this); if (writer == null) { LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); } invokeWriteTo(context, writer); } finally { clearLastTracedInterceptor(); traceAfter(null, MsgTraceEvent.WI_AFTER); } }
@Override @SuppressWarnings("unchecked") public void aroundWriteTo(final WriterInterceptorContext context) throws WebApplicationException, IOException { processedCount--; //this is not regular interceptor -> count down traceBefore(null, MsgTraceEvent.WI_BEFORE); try { final TracingLogger tracingLogger = getTracingLogger(); if (tracingLogger.isLogEnabled(MsgTraceEvent.MBW_FIND)) { tracingLogger.log(MsgTraceEvent.MBW_FIND, context.getType().getName(), (context.getGenericType() instanceof Class ? ((Class) context.getGenericType()).getName() : context.getGenericType()), context.getMediaType(), java.util.Arrays.toString(context.getAnnotations())); } final MessageBodyWriter writer = workers.getMessageBodyWriter(context.getType(), context.getGenericType(), context.getAnnotations(), context.getMediaType(), WriterInterceptorExecutor.this); if (writer == null) { LOGGER.log(Level.SEVERE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYWRITER( context.getMediaType(), context.getType(), context.getGenericType())); } invokeWriteTo(context, writer); } finally { clearLastTracedInterceptor(); traceAfter(null, MsgTraceEvent.WI_AFTER); } }
LOGGER.log(Level.FINE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER(context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER( context.getMediaType(), context.getType(), context.getGenericType()));
LOGGER.log(Level.FINE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER(context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER( context.getMediaType(), context.getType(), context.getGenericType()));
LOGGER.log(Level.FINE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER(context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER( context.getMediaType(), context.getType(), context.getGenericType()));
LOGGER.log(Level.FINE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER(context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER( context.getMediaType(), context.getType(), context.getGenericType()));
LOGGER.log(Level.FINE, LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER(context.getMediaType(), context.getType(), context.getGenericType())); throw new MessageBodyProviderNotFoundException(LocalizationMessages.ERROR_NOTFOUND_MESSAGEBODYREADER( context.getMediaType(), context.getType(), context.getGenericType()));