You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2008/10/29 00:34:29 UTC
svn commit: r708725 - in
/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure:
AbstractComponentCallback.java ComponentCallback.java
ComponentPageElementImpl.java LifecycleNotificationComponentCallback.java
Author: hlship
Date: Tue Oct 28 16:34:29 2008
New Revision: 708725
URL: http://svn.apache.org/viewvc?rev=708725&view=rev
Log:
TAP5-128: Render phase short circuiting fails to abort the event when mixins are present on the component, resulting in an IllegalStateException when trying to store a subsequent result value
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/AbstractComponentCallback.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/LifecycleNotificationComponentCallback.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentCallback.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/AbstractComponentCallback.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/AbstractComponentCallback.java?rev=708725&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/AbstractComponentCallback.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/AbstractComponentCallback.java Tue Oct 28 16:34:29 2008
@@ -0,0 +1,38 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.structure;
+
+import org.apache.tapestry5.runtime.Event;
+
+/**
+ * Base class for most implementations of {@link org.apache.tapestry5.internal.structure.ComponentCallback}, used when
+ * there is an underlying {@link org.apache.tapestry5.runtime.Event}.
+ *
+ * @see LifecycleNotificationComponentCallback
+ */
+public abstract class AbstractComponentCallback implements ComponentCallback
+{
+ private final Event event;
+
+ public AbstractComponentCallback(Event event)
+ {
+ this.event = event;
+ }
+
+ public boolean isEventAborted()
+ {
+ return event.isAborted();
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentCallback.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentCallback.java?rev=708725&r1=708724&r2=708725&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentCallback.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentCallback.java Tue Oct 28 16:34:29 2008
@@ -1,17 +1,17 @@
-// Copyright 2006 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
+// Copyright 2006, 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package org.apache.tapestry5.internal.structure;
import org.apache.tapestry5.runtime.Component;
@@ -25,4 +25,12 @@
* Callback method, passed a component to operate upon.
*/
void run(Component component);
+
+ /**
+ * Returns true if the underlying event has been aborted and no further event method invocations should occur.
+ *
+ * @return true if the event is aborted, false if event processing should continue
+ * @see org.apache.tapestry5.runtime.Event#isAborted()
+ */
+ boolean isEventAborted();
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java?rev=708725&r1=708724&r2=708725&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java Tue Oct 28 16:34:29 2008
@@ -73,7 +73,7 @@
}
};
- private static final ComponentCallback CONTAINING_PAGE_DID_ATTACH = new ComponentCallback()
+ private static final ComponentCallback CONTAINING_PAGE_DID_ATTACH = new LifecycleNotificationComponentCallback()
{
public void run(Component component)
{
@@ -81,7 +81,7 @@
}
};
- private static final ComponentCallback CONTAINING_PAGE_DID_DETACH = new ComponentCallback()
+ private static final ComponentCallback CONTAINING_PAGE_DID_DETACH = new LifecycleNotificationComponentCallback()
{
public void run(Component component)
{
@@ -89,7 +89,7 @@
}
};
- private static final ComponentCallback CONTAINING_PAGE_DID_LOAD = new ComponentCallback()
+ private static final ComponentCallback CONTAINING_PAGE_DID_LOAD = new LifecycleNotificationComponentCallback()
{
public void run(Component component)
{
@@ -97,7 +97,7 @@
}
};
- private static final ComponentCallback POST_RENDER_CLEANUP = new ComponentCallback()
+ private static final ComponentCallback POST_RENDER_CLEANUP = new LifecycleNotificationComponentCallback()
{
public void run(Component component)
{
@@ -191,7 +191,7 @@
RenderPhaseEventHandler handler = new RenderPhaseEventHandler();
final Event event = new EventImpl(handler, getEventLogger());
- ComponentCallback callback = new ComponentCallback()
+ ComponentCallback callback = new AbstractComponentCallback(event)
{
public void run(Component component)
{
@@ -220,7 +220,7 @@
RenderPhaseEventHandler handler = new RenderPhaseEventHandler();
final Event event = new EventImpl(handler, getEventLogger());
- ComponentCallback callback = new ComponentCallback()
+ ComponentCallback callback = new AbstractComponentCallback(event)
{
public void run(Component component)
{
@@ -249,7 +249,7 @@
RenderPhaseEventHandler handler = new RenderPhaseEventHandler();
final Event event = new EventImpl(handler, getEventLogger());
- ComponentCallback callback = new ComponentCallback()
+ ComponentCallback callback = new AbstractComponentCallback(event)
{
public void run(Component component)
{
@@ -278,7 +278,7 @@
RenderPhaseEventHandler handler = new RenderPhaseEventHandler();
final Event event = new EventImpl(handler, getEventLogger());
- ComponentCallback callback = new ComponentCallback()
+ ComponentCallback callback = new AbstractComponentCallback(event)
{
public void run(Component component)
{
@@ -309,7 +309,7 @@
final RenderPhaseEventHandler handler = new RenderPhaseEventHandler();
final Event event = new EventImpl(handler, getEventLogger());
- ComponentCallback callback = new ComponentCallback()
+ ComponentCallback callback = new AbstractComponentCallback(event)
{
public void run(Component component)
{
@@ -340,7 +340,7 @@
RenderPhaseEventHandler handler = new RenderPhaseEventHandler();
final Event event = new EventImpl(handler, getEventLogger());
- ComponentCallback callback = new ComponentCallback()
+ ComponentCallback callback = new AbstractComponentCallback(event)
{
public void run(Component component)
{
@@ -387,7 +387,7 @@
RenderPhaseEventHandler handler = new RenderPhaseEventHandler();
final Event event = new EventImpl(handler, getEventLogger());
- ComponentCallback callback = new ComponentCallback()
+ ComponentCallback callback = new AbstractComponentCallback(event)
{
public void run(Component component)
{
@@ -483,7 +483,7 @@
RenderPhaseEventHandler handler = new RenderPhaseEventHandler();
final Event event = new EventImpl(handler, getEventLogger());
- ComponentCallback callback = new ComponentCallback()
+ ComponentCallback callback = new AbstractComponentCallback(event)
{
public void run(Component component)
{
@@ -916,7 +916,12 @@
Iterator<Component> i = reverse ? InternalUtils.reverseIterator(components) : components.iterator();
- while (i.hasNext()) callback.run(i.next());
+ while (i.hasNext())
+ {
+ callback.run(i.next());
+
+ if (callback.isEventAborted()) return;
+ }
}
catch (RuntimeException ex)
{
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/LifecycleNotificationComponentCallback.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/LifecycleNotificationComponentCallback.java?rev=708725&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/LifecycleNotificationComponentCallback.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/LifecycleNotificationComponentCallback.java Tue Oct 28 16:34:29 2008
@@ -0,0 +1,32 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry5.internal.structure;
+
+/**
+ * Implementation of {@link org.apache.tapestry5.internal.structure.ComponentCallback} used for lifecycle notifications
+ * that do not have an event, and can therefore never be aborted.
+ *
+ * @see org.apache.tapestry5.internal.structure.AbstractComponentCallback
+ */
+public abstract class LifecycleNotificationComponentCallback implements ComponentCallback
+{
+ /**
+ * Always returns false, as there is no event.
+ */
+ public boolean isEventAborted()
+ {
+ return false;
+ }
+}