1 16 package org.apache.cocoon.environment.background; 17 18 import org.apache.avalon.framework.logger.Logger; 19 20 import org.apache.cocoon.environment.AbstractEnvironment; 21 import org.apache.cocoon.environment.Context; 22 import org.apache.cocoon.environment.ObjectModelHelper; 23 import org.apache.cocoon.environment.Request; 24 import org.apache.cocoon.environment.commandline.CommandLineContext; 25 import org.apache.cocoon.environment.commandline.CommandLineRequest; 26 import org.apache.cocoon.environment.commandline.CommandLineResponse; 27 import org.apache.cocoon.util.NullOutputStream; 28 29 import java.io.File ; 30 import java.io.IOException ; 31 import java.io.OutputStream ; 32 import java.net.MalformedURLException ; 33 import java.util.Collections ; 34 import java.util.HashMap ; 35 36 45 public class BackgroundEnvironment extends AbstractEnvironment { 46 47 public BackgroundEnvironment(Logger logger, Context ctx) throws MalformedURLException { 48 super("", null, new File (ctx.getRealPath("/")), null); 49 enableLogging(logger); 50 51 this.outputStream = new NullOutputStream(); 52 53 Request request = new CommandLineRequest( 55 this, "", "", "", new HashMap (), Collections.EMPTY_MAP, Collections.EMPTY_MAP ); 63 this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request); 64 this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, 65 new CommandLineResponse()); 66 this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT, ctx); 67 } 68 69 77 public BackgroundEnvironment(String uri, String view, File context, OutputStream stream, Logger log) 78 throws MalformedURLException { 79 80 super(uri, view, context); 81 this.enableLogging(log); 82 this.outputStream = stream; 83 84 Request request = new CommandLineRequest(this, "", uri, null, null, null); 86 this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request); 87 this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, 88 new CommandLineResponse()); 89 this.objectModel.put(ObjectModelHelper.CONTEXT_OBJECT, 90 new CommandLineContext(context.getAbsolutePath())); 91 } 92 93 96 public void redirect(boolean sessionmode, String newURL) throws IOException { 97 } 98 99 102 public void setContentType(String mimeType) { 103 } 104 105 108 public String getContentType() { 109 return null; 110 } 111 112 115 public void setContentLength(int length) { 116 } 117 118 123 public boolean isExternal() { 124 return false; 125 } 126 } 127 | Popular Tags |