/** * Overloaded variant of {@link #send(Object)} that also accepts a MediaType * hint for how to serialize the given Object. * @param object the object to write * @param mediaType a MediaType hint for selecting an HttpMessageConverter * @throws IOException raised when an I/O error occurs * @throws java.lang.IllegalStateException wraps any other errors */ public synchronized void send(Object object, @Nullable MediaType mediaType) throws IOException { Assert.state(!this.complete, "ResponseBodyEmitter is already set complete"); sendInternal(object, mediaType); }
/** * Overloaded variant of {@link #send(Object)} that also accepts a MediaType * hint for how to serialize the given Object. * @param object the object to write * @param mediaType a MediaType hint for selecting an HttpMessageConverter * @throws IOException raised when an I/O error occurs * @throws java.lang.IllegalStateException wraps any other errors */ public synchronized void send(Object object, @Nullable MediaType mediaType) throws IOException { Assert.state(!this.complete, "ResponseBodyEmitter is already set complete"); sendInternal(object, mediaType); }
synchronized void initialize(Handler handler) throws IOException { this.handler = handler; for (DataWithMediaType sendAttempt : this.earlySendAttempts) { sendInternal(sendAttempt.getData(), sendAttempt.getMediaType()); } this.earlySendAttempts.clear(); if (this.complete) { if (this.failure != null) { this.handler.completeWithError(this.failure); } else { this.handler.complete(); } } else { this.handler.onTimeout(this.timeoutCallback); this.handler.onError(this.errorCallback); this.handler.onCompletion(this.completionCallback); } }
synchronized void initialize(Handler handler) throws IOException { this.handler = handler; for (DataWithMediaType sendAttempt : this.earlySendAttempts) { sendInternal(sendAttempt.getData(), sendAttempt.getMediaType()); } this.earlySendAttempts.clear(); if (this.complete) { if (this.failure != null) { this.handler.completeWithError(this.failure); } else { this.handler.complete(); } } else { this.handler.onTimeout(this.timeoutCallback); this.handler.onError(this.errorCallback); this.handler.onCompletion(this.completionCallback); } }