001    package com.khubla.pragmatach.framework.controller.impl.streaming;
002    
003    import java.io.InputStream;
004    import java.util.Map;
005    
006    import javax.servlet.http.HttpServletResponse;
007    
008    import com.khubla.pragmatach.framework.api.PragmatachException;
009    import com.khubla.pragmatach.framework.controller.impl.AbstractResponse;
010    
011    /**
012     * @author tome
013     */
014    public class StreamingResponse extends AbstractResponse {
015       /**
016        * streaming controller
017        */
018       private final StreamingController streamingController;
019       /**
020        * input stream
021        */
022       private final InputStream inputStream;
023    
024       public StreamingResponse(Map<String, String> cacheHeaders, StreamingController streamingController, InputStream inputStream) {
025          super(cacheHeaders);
026          this.streamingController = streamingController;
027          this.inputStream = inputStream;
028       }
029    
030       @Override
031       public String getContentType() throws PragmatachException {
032          return null;
033       }
034    
035       @Override
036       public Map<String, String> getHeaders() throws PragmatachException {
037          return null;
038       }
039    
040       public StreamingController getStreamingController() {
041          return streamingController;
042       }
043    
044       @Override
045       public void render(HttpServletResponse httpServletResponse) throws PragmatachException {
046          try {
047             streamingController.render(inputStream, httpServletResponse.getOutputStream());
048          } catch (final Exception e) {
049             throw new PragmatachException("Exception in render", e);
050          }
051       }
052    }