001: /*
002: * $Id: ConfigHelperInterface.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts.config;
022:
023: import org.apache.struts.action.ActionForm;
024: import org.apache.struts.action.ActionFormBean;
025: import org.apache.struts.action.ActionForward;
026: import org.apache.struts.action.ActionMapping;
027: import org.apache.struts.action.ActionMessages;
028: import org.apache.struts.upload.MultipartRequestWrapper;
029: import org.apache.struts.util.MessageResources;
030:
031: /**
032: * <p> NOTE: THIS CLASS IS UNDER ACTIVE DEVELOPMENT. THE CURRENT CODE IS
033: * WRITTEN FOR CLARITY NOT EFFICIENCY. NOT EVERY API FUNCTION HAS BEEN
034: * IMPLEMENTED YET. </p><p> A helper object to expose the Struts shared
035: * resources, which are be stored in the application, session, or request
036: * contexts, as appropriate. </p><p> An instance should be created for each
037: * request processed. The methods which return resources from the request or
038: * session contexts are not thread-safe. </p><p> Provided for use by other
039: * servlets in the application so they can easily access the Struts shared
040: * resources. </p><p> The resources are stored under attributes in the
041: * application, session, or request contexts. </p><p> The ActionConfig methods
042: * simply return the resources from under the context and key used by the
043: * Struts ActionServlet when the resources are created. </p>
044: *
045: * @version $Rev: 471754 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
046: * $
047: * @since Struts 1.1
048: */
049: public interface ConfigHelperInterface {
050: // ------------------------------------------------ Application Context
051:
052: /**
053: * <p> The <code>org.apache.struts.action.ActionFormBeans</code>
054: * collection for this application. </p>
055: */
056: public ActionMessages getActionMessages();
057:
058: /**
059: * <p> The application resources for this application. </p>
060: */
061: public MessageResources getMessageResources();
062:
063: /**
064: * <p> The path-mapped pattern (<code>/action/*</code>) or extension
065: * mapped pattern ((<code>*.do</code>) used to determine our Action URIs
066: * in this application. </p>
067: */
068: public String getServletMapping();
069:
070: // ---------------------------------------------------- Session Context
071:
072: /**
073: * <p> The transaction token stored in this session, if it is used. </p>
074: */
075: public String getToken();
076:
077: // ---------------------------------------------------- Request Context
078:
079: /**
080: * <p> The runtime JspException that may be been thrown by a Struts tag
081: * extension, or compatible presentation extension, and placed in the
082: * request. </p>
083: */
084: public Throwable getException();
085:
086: /**
087: * <p> The multipart object for this request. </p>
088: */
089: public MultipartRequestWrapper getMultipartRequestWrapper();
090:
091: /**
092: * <p> The <code>org.apache.struts.ActionMapping</code> instance for this
093: * request. </p>
094: */
095: public ActionMapping getMapping();
096:
097: // ---------------------------------------------------- Utility Methods
098:
099: /**
100: * <p> Return true if a message string for the specified message key is
101: * present for the user's Locale. </p>
102: *
103: * @param key Message key
104: */
105: public boolean isMessage(String key);
106:
107: /**
108: * <p> Retrieve and return the <code>ActionForm</code> bean associated
109: * with this mapping, creating and stashing one if necessary. If there is
110: * no form bean associated with this mapping, return <code>null</code>.
111: * </p>
112: */
113: public ActionForm getActionForm();
114:
115: /**
116: * <p> Return the form bean definition associated with the specified
117: * logical name, if any; otherwise return <code>null</code>. </p>
118: *
119: * @param name Logical name of the requested form bean definition
120: */
121: public ActionFormBean getFormBean(String name);
122:
123: /**
124: * <p> Return the forwarding associated with the specified logical name,
125: * if any; otherwise return <code>null</code>. </p>
126: *
127: * @param name Logical name of the requested forwarding
128: */
129: public ActionForward getActionForward(String name);
130:
131: /**
132: * <p> Return the mapping associated with the specified request path, if
133: * any; otherwise return <code>null</code>. </p>
134: *
135: * @param path Request path for which a mapping is requested
136: */
137: public ActionMapping getActionMapping(String path);
138:
139: /**
140: * <p> Return the form action converted into an action mapping path. The
141: * value of the <code>action</code> property is manipulated as follows in
142: * computing the name of the requested mapping:
143: *
144: * <ul>
145: *
146: * <li>Any filename extension is removed (on the theory that extension
147: * mapping is being used to select the controller servlet).</li>
148: *
149: * <li>If the resulting value does not start with a slash, then a slash is
150: * prepended.</li>
151: *
152: * </ul> <p> :FIXME: Bad assumption =:o) </p>
153: */
154: public String getActionMappingName(String action);
155:
156: /**
157: * <p> Return the form action converted into a server-relative URL. </p>
158: */
159: public String getActionMappingURL(String action);
160:
161: /**
162: * <p> Return the url encoded to maintain the user session, if any. </p>
163: */
164: public String getEncodeURL(String url);
165:
166: // ------------------------------------------------ Presentation API
167:
168: /**
169: * <p> Renders the reference for a HTML <base> element </p>
170: */
171: public String getOrigRef();
172:
173: /**
174: * <p> Renders the reference for a HTML <base> element </p>
175: */
176: public String getBaseRef();
177:
178: /**
179: * <p> Return the path for the specified forward, otherwise return
180: * <code>null</code>. </p>
181: *
182: * @param name Name given to local or global forward.
183: */
184: public String getLink(String name);
185:
186: /**
187: * <p> Return the localized message for the specified key, otherwise
188: * return <code>null</code>. </p>
189: *
190: * @param key Message key
191: */
192: public String getMessage(String key);
193:
194: /**
195: * <p> Look up and return a message string, based on the specified
196: * parameters. </p>
197: *
198: * @param key Message key to be looked up and returned
199: * @param args Replacement parameters for this message
200: */
201: public String getMessage(String key, Object[] args);
202:
203: /**
204: * <p> Return the URL for the specified ActionMapping, otherwise return
205: * <code>null</code>. </p>
206: *
207: * @param path Name given to local or global forward.
208: */
209: public String getAction(String path);
210: }
|