You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/04/03 06:47:18 UTC
svn commit: r525030 -
/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java
Author: ehillenius
Date: Mon Apr 2 21:47:17 2007
New Revision: 525030
URL: http://svn.apache.org/viewvc?view=rev&rev=525030
Log:
Log the really important errors in a runtime methods so that clients may override or intercept them.
The application I'm working on logs a generated incident idea, that's also displayed on the error page
for the user's reference. Right now, the logging is done double, and turning off the logging of
RequestCycle is not a viable option as there is a lot of logging done that is interesting to have in
the logs, but that isn't user facing (doesn't result in the error page being shown).
Modified:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java?view=diff&rev=525030&r1=525029&r2=525030
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/RequestCycle.java Mon Apr 2 21:47:17 2007
@@ -229,21 +229,6 @@
current.set(cycle);
}
- /** The application object. */
- protected final Application application;
-
- /** The processor for this request. */
- protected final IRequestCycleProcessor processor;
-
- /** The current request. */
- protected Request request;
-
- /** The current response. */
- protected Response response;
-
- /** The session object. */
- protected final Session session;
-
/** The current stage of event processing. */
private int currentStep = NOT_STARTED;
@@ -256,7 +241,6 @@
*/
private boolean redirect;
-
/** holds the stack of set {@link IRequestTarget}, the last set op top. */
private transient final ArrayListStack requestTargets = new ArrayListStack(3);
@@ -266,6 +250,22 @@
/** True if the session should be updated (for clusterf purposes). */
private boolean updateSession;
+ /** The application object. */
+ protected final Application application;
+
+ /** The processor for this request. */
+ protected final IRequestCycleProcessor processor;
+
+
+ /** The current request. */
+ protected Request request;
+
+ /** The current response. */
+ protected Response response;
+
+ /** The session object. */
+ protected final Session session;
+
/**
* Constructor. This instance will be set as the current one for this
* thread.
@@ -657,6 +657,40 @@
}
/**
+ * Returns a URL that references a given interface on a given behaviour of a
+ * component. When the URL is requested from the server at a later time, the
+ * interface on the behaviour will be called. A URL returned by this method
+ * will not be stable across sessions and cannot be bookmarked by a user.
+ *
+ * @param component
+ * The component to reference
+ * @param behaviour
+ * The behaviour to reference
+ * @param listener
+ * The listener interface on the component
+ * @return A URL that encodes a page, component, behaviour and interface to
+ * call
+ */
+ public final CharSequence urlFor(final Component component, final IBehavior behaviour,
+ final RequestListenerInterface listener)
+ {
+ int index = component.getBehaviors().indexOf(behaviour);
+ if (index == -1)
+ {
+ throw new IllegalArgumentException("Behavior " + this
+ + " was not registered with this component: " + component.toString());
+ }
+ RequestParameters params = new RequestParameters();
+ params.setBehaviorId(String.valueOf(index));
+
+ final IRequestTarget target = new BehaviorRequestTarget(component.getPage(), component,
+ listener, params);
+ final IRequestCodingStrategy requestCodingStrategy = getProcessor()
+ .getRequestCodingStrategy();
+ return requestCodingStrategy.encode(this, target);
+ }
+
+ /**
* Returns a URL that references a given interface on a component. When the
* URL is requested from the server at a later time, the interface will be
* called. A URL returned by this method will not be stable across sessions
@@ -699,34 +733,25 @@
}
/**
- * Returns a URL that references a given interface on a given behaviour of a
- * component. When the URL is requested from the server at a later time, the
- * interface on the behaviour will be called. A URL returned by this method
- * will not be stable across sessions and cannot be bookmarked by a user.
+ * Returns a bookmarkable URL that references a given page class using a
+ * given set of page parameters. Since the URL which is returned contains
+ * all information necessary to instantiate and render the page, it can be
+ * stored in a user's browser as a stable bookmark.
*
- * @param component
- * The component to reference
- * @param behaviour
- * The behaviour to reference
- * @param listener
- * The listener interface on the component
- * @return A URL that encodes a page, component, behaviour and interface to
- * call
+ * @param pageMap
+ * Pagemap to use
+ * @param pageClass
+ * Class of page
+ * @param parameters
+ * Parameters to page
+ * @return Bookmarkable URL to page
*/
- public final CharSequence urlFor(final Component component, final IBehavior behaviour,
- final RequestListenerInterface listener)
+ public final CharSequence urlFor(final IPageMap pageMap, final Class pageClass,
+ final PageParameters parameters)
{
- int index = component.getBehaviors().indexOf(behaviour);
- if (index == -1)
- {
- throw new IllegalArgumentException("Behavior " + this
- + " was not registered with this component: " + component.toString());
- }
- RequestParameters params = new RequestParameters();
- params.setBehaviorId(String.valueOf(index));
-
- final IRequestTarget target = new BehaviorRequestTarget(component.getPage(), component,
- listener, params);
+ final IRequestTarget target = new BookmarkablePageRequestTarget(pageMap == null
+ ? PageMap.DEFAULT_NAME
+ : pageMap.getName(), pageClass, parameters);
final IRequestCodingStrategy requestCodingStrategy = getProcessor()
.getRequestCodingStrategy();
return requestCodingStrategy.encode(this, target);
@@ -763,31 +788,6 @@
}
/**
- * Returns a bookmarkable URL that references a given page class using a
- * given set of page parameters. Since the URL which is returned contains
- * all information necessary to instantiate and render the page, it can be
- * stored in a user's browser as a stable bookmark.
- *
- * @param pageMap
- * Pagemap to use
- * @param pageClass
- * Class of page
- * @param parameters
- * Parameters to page
- * @return Bookmarkable URL to page
- */
- public final CharSequence urlFor(final IPageMap pageMap, final Class pageClass,
- final PageParameters parameters)
- {
- final IRequestTarget target = new BookmarkablePageRequestTarget(pageMap == null
- ? PageMap.DEFAULT_NAME
- : pageMap.getName(), pageClass, parameters);
- final IRequestCodingStrategy requestCodingStrategy = getProcessor()
- .getRequestCodingStrategy();
- return requestCodingStrategy.encode(this, target);
- }
-
- /**
* Returns a URL that references a shared resource through the provided
* resource reference.
*
@@ -821,31 +821,6 @@
}
/**
- * Creates a new agent info object based on this request. Typically, this
- * method is called once by the session and the returned object will be
- * cached in the session after that call; we can expect the client to stay
- * the same for the whole session, and implementations of
- * {@link #newClientInfo()} might be relatively expensive.
- *
- * @return the agent info object based on this request
- */
- protected abstract ClientInfo newClientInfo();
-
- /**
- * Called when the request cycle object is beginning its response
- */
- protected void onBeginRequest()
- {
- }
-
- /**
- * Called when the request cycle object has finished its response
- */
- protected void onEndRequest()
- {
- }
-
- /**
* Checks whether no processing has been done yet and throws an exception
* when a client tries to reuse this instance.
*/
@@ -1093,7 +1068,7 @@
// it's not an internal error
if (!(e instanceof PageExpiredException))
{
- log.error(e.getMessage(), e);
+ logRuntimeException(e);
}
// try to play nicely and let the request processor handle the
@@ -1181,5 +1156,44 @@
// Clear ThreadLocal reference; makes sense as this object should not be
// reused
current.set(null);
+ }
+
+ /**
+ * Called when an unrecoverable runtime exception during request cycle
+ * handling occured. Clients can override this method in case they want to
+ * customize logging. NOT called for
+ * {@link PageExpiredException page expired exceptions}.
+ *
+ * @param e
+ * the runtime exception
+ */
+ protected void logRuntimeException(RuntimeException e)
+ {
+ log.error(e.getMessage(), e);
+ }
+
+ /**
+ * Creates a new agent info object based on this request. Typically, this
+ * method is called once by the session and the returned object will be
+ * cached in the session after that call; we can expect the client to stay
+ * the same for the whole session, and implementations of
+ * {@link #newClientInfo()} might be relatively expensive.
+ *
+ * @return the agent info object based on this request
+ */
+ protected abstract ClientInfo newClientInfo();
+
+ /**
+ * Called when the request cycle object is beginning its response
+ */
+ protected void onBeginRequest()
+ {
+ }
+
+ /**
+ * Called when the request cycle object has finished its response
+ */
+ protected void onEndRequest()
+ {
}
}