private MediaTypeMap<SortedKey<MessageBodyWriter>> getServerMessageBodyWriters() { if (serverMessageBodyWriters == null && parent != null) return parent.getServerMessageBodyWriters(); return serverMessageBodyWriters; }
public <T> MessageBodyWriter<T> getServerMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType, RESTEasyTracingLogger tracingLogger) { MediaTypeMap<SortedKey<MessageBodyWriter>> availableWriters = getServerMessageBodyWriters(); return resolveMessageBodyWriter(type, genericType, annotations, mediaType, availableWriters, tracingLogger); }
@Deprecated public <T> MessageBodyWriter<T> getServerMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { MediaTypeMap<SortedKey<MessageBodyWriter>> availableWriters = getServerMessageBodyWriters(); return resolveMessageBodyWriter(type, genericType, annotations, mediaType, availableWriters); }
public Map<MessageBodyWriter<?>, Class<?>> getPossibleMessageBodyWritersMap(Class type, Type genericType, Annotation[] annotations, MediaType accept) { Map<MessageBodyWriter<?>, Class<?>> map = new HashMap<MessageBodyWriter<?>, Class<?>>(); List<SortedKey<MessageBodyWriter>> writers = getServerMessageBodyWriters().getPossible(accept, type); for (SortedKey<MessageBodyWriter> writer : writers) { if (writer.obj.isWriteable(type, genericType, annotations, accept)) { Class<?> mbwc = writer.obj.getClass(); if (!mbwc.isInterface() && mbwc.getSuperclass() != null && !mbwc.getSuperclass().equals(Object.class) && mbwc.isSynthetic()) { mbwc = mbwc.getSuperclass(); } Class writerType = Types.getTemplateParameterOfInterface(mbwc, MessageBodyWriter.class); if (writerType == null || !writerType.isAssignableFrom(type)) continue; map.put(writer.obj, writerType); } } return map; }
/** * Always gets server MBW. * * @param type the class of the object that is to be written. * @param genericType the type of object to be written. E.g. if the * message body is to be produced from a field, this will be * the declared type of the field as returned by {@code Field.getGenericType}. * @param annotations an array of the annotations on the declaration of the * artifact that will be written. E.g. if the * message body is to be produced from a field, this will be * the annotations on that field returned by * {@code Field.getDeclaredAnnotations}. * @param mediaType the media type of the data that will be written. * @param <T> type * @return message writer */ public <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { MediaTypeMap<SortedKey<MessageBodyWriter>> availableWriters = getServerMessageBodyWriters(); MessageBodyWriter<T> writer = resolveMessageBodyWriter(type, genericType, annotations, mediaType, availableWriters); if (writer != null) LogMessages.LOGGER.debugf("MessageBodyWriter: %s", writer.getClass().getName()); return writer; }
public MediaType getConcreteMediaTypeFromMessageBodyWriters(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { List<SortedKey<MessageBodyWriter>> writers = getServerMessageBodyWriters().getPossible(mediaType, type); for (SortedKey<MessageBodyWriter> writer : writers) { if (writer.obj.isWriteable(type, genericType, annotations, mediaType)) { MessageBodyWriter mbw = writer.obj; Class writerType = Types.getTemplateParameterOfInterface(mbw.getClass(), MessageBodyWriter.class); if (writerType == null || writerType.equals(Object.class) || !writerType.isAssignableFrom(type)) continue; Produces produces = mbw.getClass().getAnnotation(Produces.class); if (produces == null) continue; for (String produce : produces.value()) { MediaType mt = MediaType.valueOf(produce); if (mt.isWildcardType() || mt.isWildcardSubtype()) continue; return mt; } } } return null; }
classContracts = parent == null ? new ConcurrentHashMap<>() : new ConcurrentHashMap<>(parent.getClassContracts()); serverMessageBodyReaders = parent == null ? new MediaTypeMap<>() : parent.getServerMessageBodyReaders().clone(); serverMessageBodyWriters = parent == null ? new MediaTypeMap<>() : parent.getServerMessageBodyWriters().clone(); clientMessageBodyReaders = parent == null ? new MediaTypeMap<>() : parent.getClientMessageBodyReaders().clone(); clientMessageBodyWriters = parent == null ? new MediaTypeMap<>() : parent.getClientMessageBodyWriters().clone();
private MediaTypeMap<SortedKey<MessageBodyWriter>> getServerMessageBodyWriters() { if (serverMessageBodyWriters == null && parent != null) return parent.getServerMessageBodyWriters(); return serverMessageBodyWriters; }
serverMessageBodyWriters = parent.getServerMessageBodyWriters().clone();
public <T> MessageBodyWriter<T> getServerMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType, RESTEasyTracingLogger tracingLogger) { MediaTypeMap<SortedKey<MessageBodyWriter>> availableWriters = getServerMessageBodyWriters(); return resolveMessageBodyWriter(type, genericType, annotations, mediaType, availableWriters, tracingLogger); }
@Deprecated public <T> MessageBodyWriter<T> getServerMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { MediaTypeMap<SortedKey<MessageBodyWriter>> availableWriters = getServerMessageBodyWriters(); return resolveMessageBodyWriter(type, genericType, annotations, mediaType, availableWriters); }
public Map<MessageBodyWriter<?>, Class<?>> getPossibleMessageBodyWritersMap(Class type, Type genericType, Annotation[] annotations, MediaType accept) { Map<MessageBodyWriter<?>, Class<?>> map = new HashMap<MessageBodyWriter<?>, Class<?>>(); List<SortedKey<MessageBodyWriter>> writers = getServerMessageBodyWriters().getPossible(accept, type); for (SortedKey<MessageBodyWriter> writer : writers) { if (writer.obj.isWriteable(type, genericType, annotations, accept)) { Class<?> mbwc = writer.obj.getClass(); if (!mbwc.isInterface() && mbwc.getSuperclass() != null && !mbwc.getSuperclass().equals(Object.class) && mbwc.isSynthetic()) { mbwc = mbwc.getSuperclass(); } Class writerType = Types.getTemplateParameterOfInterface(mbwc, MessageBodyWriter.class); if (writerType == null || !writerType.isAssignableFrom(type)) continue; map.put(writer.obj, writerType); } } return map; }
/** * Always gets server MBW. * * @param type the class of the object that is to be written. * @param genericType the type of object to be written. E.g. if the * message body is to be produced from a field, this will be * the declared type of the field as returned by {@code Field.getGenericType}. * @param annotations an array of the annotations on the declaration of the * artifact that will be written. E.g. if the * message body is to be produced from a field, this will be * the annotations on that field returned by * {@code Field.getDeclaredAnnotations}. * @param mediaType the media type of the data that will be written. * @param <T> type * @return message writer */ public <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) { MediaTypeMap<SortedKey<MessageBodyWriter>> availableWriters = getServerMessageBodyWriters(); MessageBodyWriter<T> writer = resolveMessageBodyWriter(type, genericType, annotations, mediaType, availableWriters); if (writer != null) LogMessages.LOGGER.debugf("MessageBodyWriter: %s", writer.getClass().getName()); return writer; }
public MediaType getConcreteMediaTypeFromMessageBodyWriters(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { List<SortedKey<MessageBodyWriter>> writers = getServerMessageBodyWriters().getPossible(mediaType, type); for (SortedKey<MessageBodyWriter> writer : writers) { if (writer.obj.isWriteable(type, genericType, annotations, mediaType)) { MessageBodyWriter mbw = writer.obj; Class writerType = Types.getTemplateParameterOfInterface(mbw.getClass(), MessageBodyWriter.class); if (writerType == null || writerType.equals(Object.class) || !writerType.isAssignableFrom(type)) continue; Produces produces = mbw.getClass().getAnnotation(Produces.class); if (produces == null) continue; for (String produce : produces.value()) { MediaType mt = MediaType.valueOf(produce); if (mt.isWildcardType() || mt.isWildcardSubtype()) continue; return mt; } } } return null; }
classContracts = parent == null ? new ConcurrentHashMap<>() : new ConcurrentHashMap<>(parent.getClassContracts()); serverMessageBodyReaders = parent == null ? new MediaTypeMap<>() : parent.getServerMessageBodyReaders().clone(); serverMessageBodyWriters = parent == null ? new MediaTypeMap<>() : parent.getServerMessageBodyWriters().clone(); clientMessageBodyReaders = parent == null ? new MediaTypeMap<>() : parent.getClientMessageBodyReaders().clone(); clientMessageBodyWriters = parent == null ? new MediaTypeMap<>() : parent.getClientMessageBodyWriters().clone();
serverMessageBodyWriters = parent.getServerMessageBodyWriters().clone();