1 5 6 package org.infohazard.maverick.transform; 7 8 import java.io.IOException ; 9 import java.io.Writer ; 10 11 import javax.servlet.ServletException ; 12 import javax.servlet.http.HttpServletResponse ; 13 14 import org.apache.commons.logging.Log; 15 import org.apache.commons.logging.LogFactory; 16 import org.infohazard.maverick.flow.TransformContext; 17 import org.infohazard.maverick.flow.TransformStep; 18 import org.infohazard.maverick.util.FakeHttpServletResponse; 19 20 30 public abstract class AbstractTransformStep implements TransformStep 31 { 32 35 private static Log log = LogFactory.getLog(AbstractTransformStep.class); 36 37 39 private TransformContext transformCtx; 40 41 43 private TransformStep next; 44 45 47 protected FakeHttpServletResponse fakeResponse; 48 49 51 public AbstractTransformStep(TransformContext tctx) throws ServletException 52 { 53 this.transformCtx = tctx; 54 } 55 56 59 public boolean isLast() 60 { 61 return false; 62 } 63 64 67 public void setContentType(String contentType) 68 { 69 } 70 71 73 protected TransformContext getTransformCtx() 74 { 75 return this.transformCtx; 76 } 77 78 81 protected TransformStep getNext() throws ServletException 82 { 83 if (this.next == null) 84 this.next = this.getTransformCtx().getNextStep(); 85 86 return this.next; 87 } 88 89 91 public HttpServletResponse getResponse() throws IOException , ServletException 92 { 93 log.debug("Getting fake response"); 94 95 if (this.fakeResponse == null) 97 this.fakeResponse = new FakeHttpServletResponse(this.getTransformCtx().getRealResponse()); 98 99 return this.fakeResponse; 100 } 101 102 104 public Writer getWriter() throws IOException , ServletException 105 { 106 return this.getResponse().getWriter(); 107 } 108 } 109 | Popular Tags |