001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.pageflow;
020:
021: import org.apache.struts.action.ActionMapping;
022: import org.apache.struts.action.ActionForm;
023: import org.apache.struts.action.ActionForward;
024: import org.apache.struts.config.ModuleConfig;
025:
026: import javax.servlet.ServletContext;
027:
028: /**
029: * An event reporter, which will be notified of events like "page flow created", "action raised", etc.
030: */
031: public abstract class PageFlowEventReporter {
032: private ServletContext _servletContext;
033:
034: protected PageFlowEventReporter(ServletContext servletContext) {
035: _servletContext = servletContext;
036: }
037:
038: /**
039: * Event fired when an action is raised on a FlowController (a page flow or a shared flow).
040: *
041: * @param requestContext the current request context.
042: * @param flowController the FlowController on which the action is being raised (a
043: * {@link PageFlowController} or a {@link SharedFlowController}).
044: * @param actionMapping the <code>org.apache.struts.action.ActionMapping</code> that represents the action being
045: * raised. The name of the action, prefixed by a '/', can be found by calling <code>getPath</code>
046: * on this object.
047: * @param form the form bean that was passed to the action, or <code>null</code> if there was none.
048: */
049: public abstract void actionRaised(RequestContext requestContext,
050: FlowController flowController, ActionMapping actionMapping,
051: ActionForm form);
052:
053: /**
054: * Event fired when an action successfully completes on a FlowController (a page flow or a shared flow).
055: *
056: * @param requestContext the current request context.
057: * @param flowController the FlowController on which the action was raised (a
058: * {@link PageFlowController} or a {@link SharedFlowController}).
059: * @param actionMapping the <code>org.apache.struts.action.ActionMapping</code> that represents the action that was
060: * raised. The name of the action, prefixed by a '/', can be found by calling <code>getPath</code>
061: * on this object.
062: * @param form the form bean that was passed to the action, or <code>null</code> if there was none.
063: * @param result the ActionForward result returned from the action.
064: * @param timeTakenMillis the length of time in milliseconds for the action to be run.
065: */
066: public abstract void actionSuccess(RequestContext requestContext,
067: FlowController flowController, ActionMapping actionMapping,
068: ActionForm form, ActionForward result, long timeTakenMillis);
069:
070: /**
071: * Event fired when an exception is raised during processing of an action request.
072: *
073: * @param requestContext the current request context.
074: * @param ex the Throwable that was raised.
075: * @param actionMapping the <code>org.apache.struts.action.ActionMapping</code> that represents the action that was
076: * raised. The name of the action, prefixed by a '/', can be found by calling <code>getPath</code>
077: * on this object. This parameter will be <code>null</code> if the request did not get to the point
078: * where an action was actuallly raised.
079: * @param form the form bean that was passed to the action, or <code>null</code> if there was none.
080: * @param flowController the FlowController associated with the action request. This parameter will be
081: * <code>null</code> if the request did not get to the point where a FlowController could be created or
082: * looked up.
083: *
084: * @see #beginActionRequest
085: */
086: public abstract void exceptionRaised(RequestContext requestContext,
087: Throwable ex, ActionMapping actionMapping, ActionForm form,
088: FlowController flowController);
089:
090: /**
091: * Event fired when an exception is handled successfully during processing of an action request.
092: *
093: * @param requestContext the current request context.
094: * @param ex the Throwable that was raised.
095: * @param actionMapping the <code>org.apache.struts.action.ActionMapping</code> that represents the action that was
096: * raised. The name of the action, prefixed by a '/', can be found by calling <code>getPath</code>
097: * on this object. This parameter will be <code>null</code> if the request did not get to the point
098: * where an action was actuallly raised.
099: * @param form the form bean that was passed to the action, or <code>null</code> if there was none.
100: * @param flowController the FlowController associated with the action request. This parameter will be
101: * <code>null</code> if the request did not get to the point where a FlowController could be created or
102: * looked up.
103: * @param result the ActionForward result returned from the exception handler.
104: * @param timeTakenMillis the length of time in milliseconds for the exception to be handled.
105: *
106: * @see #beginActionRequest
107: */
108: public abstract void exceptionHandled(
109: RequestContext requestContext, Throwable ex,
110: ActionMapping actionMapping, ActionForm form,
111: FlowController flowController, ActionForward result,
112: long timeTakenMillis);
113:
114: /**
115: *
116: * Event fired when a FlowController (a page flow or a shared flow) is created.
117: *
118: * @param requestContext the current request context.
119: * @param flowController the FlowController (a {@link PageFlowController} or a {@link SharedFlowController})
120: * that was created.
121: */
122: public abstract void flowControllerCreated(
123: RequestContext requestContext, FlowController flowController);
124:
125: /**
126: * Event fired when a FlowController (a page flow or a shared flow) is "destroyed", i.e., removed from wherever it
127: * is being stored.
128: *
129: * @param flowController the FlowController (a {@link PageFlowController} or a {@link SharedFlowController})
130: * that is being destroyed.
131: * @param storageLocation The storage location. For session-scoped FlowControllers, this is a
132: * <code>javax.servlet.http.HttpSession</code>.
133: */
134: public abstract void flowControllerDestroyed(
135: FlowController flowController, Object storageLocation);
136:
137: /**
138: * Event fired at the beginning of an action request. Note that this is called on all action requests, even those
139: * that do not successfully run actions.
140: *
141: * @param requestContext the current request context.
142: */
143: public abstract void beginActionRequest(
144: RequestContext requestContext);
145:
146: /**
147: * Event fired at the end of an action request. Note that this is called on all action requests, even those
148: * that do not successfully run actions.
149: *
150: * @param requestContext the current request context.
151: * @param timeTakenMillis the length of time in milliseconds for the action request to be processed.
152: *
153: */
154: public abstract void endActionRequest(
155: RequestContext requestContext, long timeTakenMillis);
156:
157: /**
158: * Event fired at the end of an action request. Note that this is called on all action requests, even those
159: * that do not successfully run actions.
160: *
161: * @param requestContext the current request context.
162: */
163: public abstract void beginPageRequest(RequestContext requestContext);
164:
165: /**
166: * Event fired at the end of a page request.
167: *
168: * @param requestContext the current request context.
169: * @param timeTakenMillis the length of time in milliseconds for the page request to be processed.
170: */
171: public abstract void endPageRequest(RequestContext requestContext,
172: long timeTakenMillis);
173:
174: /**
175: * Event fired when a page flow or shared flow is registered lazily (once per webapp deployment).
176: *
177: * @param modulePath the module path, which is the "parent directory" for actions on the controller.
178: * @param controllerClassName the name of the controller class.
179: * @param moduleConfig the Struts ModuleConfig that corresponds to the controller.
180: */
181: public abstract void flowControllerRegistered(String modulePath,
182: String controllerClassName, ModuleConfig moduleConfig);
183:
184: protected ServletContext getServletContext() {
185: return _servletContext;
186: }
187: }
|