WebContext.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.chain.web.jakarta;

  18. import java.util.Map;

  19. import jakarta.servlet.http.Cookie;

  20. import org.apache.commons.chain.Context;
  21. import org.apache.commons.chain.impl.ContextBase;

  22. /**
  23.  * Extended {@link Context} that provides web based applications that use
  24.  * it a "generic" view of HTTP related requests and responses, without
  25.  * tying the application to a particular underlying Java API (such as
  26.  * servlets). It is expected that a concrete subclass of {@link WebContext}
  27.  * for each API (such as
  28.  * {@code org.apache.commons.chain.web.jakarta.servlet.ServletWebContext}) will
  29.  * support adapting that particular API's implementation of request and
  30.  * response objects into this generic framework.
  31.  *
  32.  * <p>The characteristics of a web request/response are made visible via
  33.  * a series of JavaBeans properties (and mapped to read-only attributes
  34.  * of the same name, as supported by {@link ContextBase}.</p>
  35.  *
  36.  * @author Craig R. McClanahan
  37.  * @version $Revision$ $Date$
  38.  */
  39. public abstract class WebContext extends ContextBase {
  40.     private static final long serialVersionUID = 6804961872140299027L;

  41.     /**
  42.      * The Default-Constructor for this class.
  43.      */
  44.     public WebContext() {
  45.     }

  46.     /**
  47.      * Return a mutable {@code Map} that maps application scope
  48.      * attribute names to their values.
  49.      *
  50.      * @return Application scope Map.
  51.      */
  52.     public abstract Map<String, Object> getApplicationScope();

  53.     /**
  54.      * Return an immutable {@code Map} that maps header names to
  55.      * the first (or only) header value (as a String). Header names must
  56.      * be matched in a case-insensitive manner.
  57.      *
  58.      * @return Header values Map.
  59.      */
  60.     public abstract Map<String, String> getHeader();

  61.     /**
  62.      * Return an immutable {@code Map} that maps header names to
  63.      * the set of all values specified in the request (as a String array).
  64.      * Header names must be matched in a case-insensitive manner.
  65.      *
  66.      * @return Header values Map.
  67.      */
  68.     public abstract Map<String, String[]> getHeaderValues();

  69.     /**
  70.      * Return an immutable {@code Map} that maps context application
  71.      * initialization parameters to their values.
  72.      *
  73.      * @return Initialization parameter Map.
  74.      */
  75.     public abstract Map<String, String> getInitParam();

  76.     /**
  77.      * Return an immutable {@code Map} that maps request parameter
  78.      * names to the first (or only) value (as a String).
  79.      *
  80.      * @return Request parameter Map.
  81.      */
  82.     public abstract Map<String, String> getParam();

  83.     /**
  84.      * Return an immutable {@code Map} that maps request parameter
  85.      * names to the set of all values (as a String array).
  86.      *
  87.      * @return Request parameter Map.
  88.      */
  89.     public abstract Map<String, String[]> getParamValues();

  90.     /**
  91.      * Return an immutable {@code Map} that maps cookie names to
  92.      * the set of cookies specified in the request.
  93.      *
  94.      * @return Map of Cookies.
  95.      *
  96.      * @since Chain 1.1
  97.      */
  98.     public abstract Map<String, Cookie> getCookies();

  99.     /**
  100.      * Return a mutable {@code Map} that maps request scope
  101.      * attribute names to their values.
  102.      *
  103.      * @return Request scope Map.
  104.      */
  105.     public abstract Map<String, Object> getRequestScope();

  106.     /**
  107.      * Return a mutable {@code Map} that maps session scope
  108.      * attribute names to their values.
  109.      *
  110.      * @return Session scope Map.
  111.      */
  112.     public abstract Map<String, Object> getSessionScope();
  113. }