View Javadoc
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;
18  
19  import java.util.Map;
20  
21  /**
22   * A {@link Context} represents the state information that is
23   * accessed and manipulated by the execution of a {@link Command} or a
24   * {@link Chain}. Specialized implementations of {@link Context} will
25   * typically add JavaBeans properties that contain typesafe accessors
26   * to information that is relevant to a particular use case for this
27   * context, and/or add operations that affect the state information
28   * that is saved in the context.
29   *
30   * <p>Implementations of {@link Context} must also implement all of the
31   * required and optional contracts of the {@code java.util.Map}
32   * interface.</p>
33   *
34   * <p>It is strongly recommended, but not required, that JavaBeans
35   * properties added to a particular {@link Context} implementation exhibit
36   * <em>Attribute-Property Transparency</em>. In other words,
37   * a value stored via a call to {@code setFoo(value)} should be visible
38   * by calling {@code get("foo")}, and a value stored
39   * via a call to {@code put("foo", value)} should be
40   * visible by calling {@code getFoo()}. If your {@link Context}
41   * implementation class exhibits this feature, it becomes easier to reuse the
42   * implementation in multiple environments, without the need to cast to a
43   * particular implementation class in order to access the property getter
44   * and setter methods.</p>
45   *
46   * <p>To protect applications from evolution of this interface, specialized
47   * implementations of {@link Context} should generally be created by extending
48   * the provided base class ({@link org.apache.commons.chain.impl.ContextBase})
49   * rather than directly implementing this interface.</p>
50   *
51   * <p>Applications should <strong>NOT</strong> assume that
52   * {@link Context} implementations, or the values stored in its
53   * attributes, may be accessed from multiple threads
54   * simultaneously unless this is explicitly documented for a particular
55   * implementation.</p>
56   *
57   * @author Craig R. McClanahan
58   * @version $Revision$ $Date$
59   */
60  public interface Context extends Map<String, Object> {
61  }