1 16 package org.apache.cocoon.components; 17 18 import java.util.Map ; 19 20 import org.apache.avalon.framework.CascadingRuntimeException; 21 import org.apache.avalon.framework.context.Context; 22 import org.apache.avalon.framework.context.ContextException; 23 import org.apache.cocoon.environment.ObjectModelHelper; 24 import org.apache.cocoon.environment.Request; 25 import org.apache.cocoon.environment.Response; 26 27 34 35 public final class ContextHelper { 36 37 38 public static final String CONTEXT_OBJECT_MODEL = "object-model"; 39 40 41 public static final String CONTEXT_REQUEST_OBJECT = CONTEXT_OBJECT_MODEL + '.' + ObjectModelHelper.REQUEST_OBJECT; 42 43 44 public static final String CONTEXT_RESPONSE_OBJECT = CONTEXT_OBJECT_MODEL + '.' + ObjectModelHelper.RESPONSE_OBJECT; 45 46 47 public static final String CONTEXT_SITEMAP_SERVICE_MANAGER = "sitemap-service-manager"; 48 49 private ContextHelper() { 50 } 52 53 58 public static final Request getRequest(Context context) { 59 try { 61 return (Request)context.get(CONTEXT_REQUEST_OBJECT); 62 } catch (ContextException ce) { 63 throw new CascadingRuntimeException("Unable to get the request object from the context.", ce); 64 } 65 } 66 67 72 public static final Response getResponse(Context context) { 73 try { 75 return (Response)context.get(CONTEXT_RESPONSE_OBJECT); 76 } catch (ContextException ce) { 77 throw new CascadingRuntimeException("Unable to get the response object from the context.", ce); 78 } 79 } 80 81 86 public static final Map getObjectModel(Context context) { 87 try { 89 return (Map )context.get(CONTEXT_OBJECT_MODEL); 90 } catch (ContextException ce) { 91 throw new CascadingRuntimeException("Unable to get the object model from the context.", ce); 92 } 93 } 94 } 95 | Popular Tags |