You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by cr...@apache.org on 2006/10/13 19:28:04 UTC
svn commit: r463744 -
/shale/framework/trunk/shale-dialog-basic/src/main/java/org/apache/shale/dialog/basic/BasicDialogContext.java
Author: craigmcc
Date: Fri Oct 13 10:28:03 2006
New Revision: 463744
URL: http://svn.apache.org/viewvc?view=rev&rev=463744
Log:
Add some debugging logic, and fix an endless recursion when processing a
subdialog state that would cause out of memory errors.
SHALE-300
Modified:
shale/framework/trunk/shale-dialog-basic/src/main/java/org/apache/shale/dialog/basic/BasicDialogContext.java
Modified: shale/framework/trunk/shale-dialog-basic/src/main/java/org/apache/shale/dialog/basic/BasicDialogContext.java
URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog-basic/src/main/java/org/apache/shale/dialog/basic/BasicDialogContext.java?view=diff&rev=463744&r1=463743&r2=463744
==============================================================================
--- shale/framework/trunk/shale-dialog-basic/src/main/java/org/apache/shale/dialog/basic/BasicDialogContext.java (original)
+++ shale/framework/trunk/shale-dialog-basic/src/main/java/org/apache/shale/dialog/basic/BasicDialogContext.java Fri Oct 13 10:28:03 2006
@@ -24,6 +24,8 @@
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.shale.dialog.DialogContext;
import org.apache.shale.dialog.DialogContextManager;
@@ -70,6 +72,11 @@
this.id = id;
this.parentDialogId = parentDialogId;
+ if (log().isDebugEnabled()) {
+ log().debug("Constructor(id=" + id + ", name="
+ + dialogName + ")");
+ }
+
}
@@ -115,6 +122,13 @@
/**
+ * <p>The <code>Log</code> instance for this dialog context.
+ * This value is lazily created (or recreated) as necessary.</p>
+ */
+ private transient Log log = null;
+
+
+ /**
* <p>Identifier of the parent {@link DialogContext} associated with
* this {@link DialogContext}, if any. If there is no such parent,
* this value is set to <code>null</code>.</p>
@@ -243,6 +257,11 @@
+ getName() + "' has not yet been started");
}
+ if (log().isDebugEnabled()) {
+ log().debug("advance(id=" + getId() + ", name=" + getName()
+ + ", outcome=" + outcome + ")");
+ }
+
// Perform an initial transition from the current state based on
// the logical outcome received from the (current) view state
Position position = peek();
@@ -256,6 +275,9 @@
if (state instanceof ActionState) {
ActionState astate = (ActionState) state;
+ if (log().isTraceEnabled()) {
+ log().trace("-->ActionState(method=" + astate.getMethod() + ")");
+ }
try {
MethodBinding mb = context.getApplication().
createMethodBinding(astate.getMethod(), ACTION_STATE_SIGNATURE);
@@ -267,6 +289,9 @@
state = position.getState();
continue;
} else if (state instanceof EndState) {
+ if (log().isTraceEnabled()) {
+ log().trace("-->EndState()");
+ }
pop();
position = peek();
if (position == null) {
@@ -276,6 +301,10 @@
break;
} else if (state instanceof SubdialogState) {
SubdialogState sstate = (SubdialogState) state;
+ if (log().isTraceEnabled()) {
+ log().trace("-->SubdialogState(dialogName="
+ + sstate.getDialogName() + ")");
+ }
Dialog subdialog = (Dialog) dialogs(context).get(sstate.getDialogName());
if (subdialog == null) {
throw new IllegalStateException("Cannot find dialog definition '"
@@ -283,9 +312,14 @@
}
start(subdialog);
position = peek();
+ state = position.getState();
continue;
} else if (state instanceof ViewState) {
viewId = ((ViewState) state).getViewId();
+ if (log().isTraceEnabled()) {
+ log().trace("-->ViewState(viewId="
+ + ((ViewState) state).getViewId() + ")");
+ }
break;
} else {
throw new IllegalStateException
@@ -299,6 +333,9 @@
if (viewId == null) {
return;
}
+ if (log().isTraceEnabled()) {
+ log().trace("-->Navigate(viewId=" + viewId + ")");
+ }
ViewHandler vh = context.getApplication().getViewHandler();
UIViewRoot view = vh.createView(context, viewId);
view.setViewId(viewId);
@@ -318,6 +355,11 @@
}
started = true;
+ if (log().isDebugEnabled()) {
+ log().debug("start(id=" + getId() + ", name="
+ + getName() + ")");
+ }
+
// inform listeners we've been started
fireOnStart();
@@ -340,6 +382,12 @@
+ getName() + "' has not yet been started");
}
started = false;
+
+ if (log().isDebugEnabled()) {
+ log().debug("stop(id=" + getId() + ", name="
+ + getName() + ")");
+ }
+
deactivate();
manager.remove(this);
@@ -412,6 +460,20 @@
// Throw an exception if dialog configuration resources have not
// been processed yet
throw new IllegalStateException("Dialog configuration resources have not yet been processed");
+
+ }
+
+
+ /**
+ * <p>Return the <code>Log</code> instance for this dialog context,
+ * creating one if necessary.</p>
+ */
+ private Log log() {
+
+ if (log == null) {
+ log = LogFactory.getLog(BasicDialogContext.class);
+ }
+ return log;
}