This project has retired. For details please refer to its Attic page.
TilesContainer xref
View Javadoc

1   /*
2    * $Id: TilesContainer.java 1044659 2010-12-11 14:16:04Z apetrelli $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.tiles;
22  
23  import java.io.IOException;
24  
25  import org.apache.tiles.request.ApplicationContext;
26  import org.apache.tiles.request.Request;
27  
28  /**
29   * An encapsulation of the tiles framework.  This interface is
30   * used to expose tiles features to frameworks which leverage
31   * it as a plugin.  It can alternately be used by web applications
32   * which would like a programmatic interface.
33   *
34   * @since 2.0
35   * @version $Rev: 1044659 $ $Date: 2010-12-12 01:16:04 +1100 (Sun, 12 Dec 2010) $
36   */
37  public interface TilesContainer {
38  
39      /**
40       * Retrieve the containers context.
41       *
42       * @return current application context
43       */
44      ApplicationContext getApplicationContext();
45  
46      /**
47       * Retrive the attribute context of the current request.
48       * @param request The request.
49       * @return map of the attributes in the current attribute context.
50       */
51      AttributeContext getAttributeContext(Request request);
52  
53      /**
54       * Starts a new context, where attribute values are stored independently
55       * from others.<br>
56       * When the use of the contexts is finished, call
57       * {@link TilesContainer#endContext(Request)}
58       * @param request The request.
59       *
60       * @return The newly created context.
61       */
62      AttributeContext startContext(Request request);
63  
64      /**
65       * Ends a context, where attribute values are stored independently
66       * from others.<br>
67       * It must be called after a
68       * {@link TilesContainer#startContext(Request)} call.
69       * @param request The request.
70       */
71      void endContext(Request request);
72  
73      /**
74       * Renders the current context, as it is.
75       * @param request The request.
76       *
77       * @since 2.1.0
78       */
79      void renderContext(Request request);
80  
81      /**
82       * Executes a preparer.
83       *
84       * @param preparer The name of the preparer to execute.
85       * @param request The request.
86       */
87      void prepare(String preparer, Request request);
88  
89      /**
90       * Render the given tiles request.
91       *
92       * @param definition the current definition.
93       * @param request The request.
94       */
95      void render(String definition, Request request);
96  
97      /**
98       * Renders the specified definition.
99       * @param definition The definition to render.
100      * @param request The request context.
101      */
102     void render(Definition definition, Request request);
103 
104     /**
105      * Render the given Attribute.
106      *
107      * @param attribute The attribute to render.
108      * @param request The request.
109      * @throws IOException If something goes wrong during writing to the output.
110      * @since 2.1.2
111      */
112     void render(Attribute attribute, Request request)
113         throws IOException;
114 
115     /**
116      * Evaluates the given attribute.
117      *
118      * @param attribute The attribute to evaluate.
119      * @param request The request.
120      * @return The evaluated object.
121      * @since 2.1.0
122      */
123     Object evaluate(Attribute attribute, Request request);
124 
125     /**
126      * Returns a definition specifying its name.
127      *
128      * @param definitionName The name of the definition to find.
129      * @param request The request context.
130      * @return The definition, if found.
131      */
132     Definition getDefinition(String definitionName,
133             Request request);
134 
135     /**
136      * Determine whether or not the definition exists.
137      *
138      * @param definition the name of the definition.
139      * @param request The request.
140      * @return true if the definition is found.
141      */
142     boolean isValidDefinition(String definition, Request request);
143 }