Author: hlship
Date: Thu Feb 4 00:45:57 2010
New Revision: 906307
URL: http://svn.apache.org/viewvc?rev=906307&view=rev
Log:
Add support for removing a PageLifeycleListener
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResources.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResources.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResources.java?rev=906307&r1=906306&r2=906307&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResources.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResources.java
Thu Feb 4 00:45:57 2010
@@ -175,6 +175,13 @@
void addPageLifecycleListener(PageLifecycleListener listener);
/**
+ * Removes a previously added listener.
+ *
+ * @since 5.2.0
+ */
+ void removePageLifecycleListener(PageLifecycleListener listener);
+
+ /**
* Discards all persistent field changes for the page containing the component. Changes
are eliminated from
* persistent storage (such as the {@link org.apache.tapestry5.services.Session}) which
will take effect in the
* <em>next</em> request (the attached page instance is not affected).
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java?rev=906307&r1=906306&r2=906307&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
Thu Feb 4 00:45:57 2010
@@ -131,8 +131,8 @@
private Informal firstInformal;
public InternalComponentResourcesImpl(Page page, ComponentPageElement element,
- ComponentResources containerResources, ComponentPageElementResources elementResources,
- String completeId, String nestedId, Instantiator componentInstantiator, boolean
mixin)
+ ComponentResources containerResources, ComponentPageElementResources elementResources,
String completeId,
+ String nestedId, Instantiator componentInstantiator, boolean mixin)
{
this.page = page;
this.element = element;
@@ -260,8 +260,7 @@
return getBinding(parameterName) != null;
}
- public <T extends Annotation> T getParameterAnnotation(String parameterName,
- Class<T> annotationType)
+ public <T extends Annotation> T getParameterAnnotation(String parameterName, Class<T>
annotationType)
{
Binding binding = getBinding(parameterName);
@@ -283,8 +282,7 @@
return input == null ? EMPTY : input;
}
- public boolean triggerContextEvent(String eventType, EventContext context,
- ComponentEventCallback callback)
+ public boolean triggerContextEvent(String eventType, EventContext context, ComponentEventCallback
callback)
{
return element.triggerContextEvent(eventType, context, callback);
}
@@ -312,8 +310,8 @@
}
catch (Exception ex)
{
- throw new TapestryException(StructureMessages.fieldPersistFailure(getCompleteId(),
- fieldName, ex), getLocation(), ex);
+ throw new TapestryException(StructureMessages.fieldPersistFailure(getCompleteId(),
fieldName, ex),
+ getLocation(), ex);
}
}
@@ -463,9 +461,8 @@
Object result = InternalUtils.get(renderVariables, name);
if (result == null)
- throw new IllegalArgumentException(StructureMessages.missingRenderVariable(
- getCompleteId(), name, renderVariables == null ? null : renderVariables
- .keySet()));
+ throw new IllegalArgumentException(StructureMessages.missingRenderVariable(getCompleteId(),
name,
+ renderVariables == null ? null : renderVariables.keySet()));
return result;
}
@@ -476,8 +473,7 @@
Defense.notNull(value, "value");
if (!element.isRendering())
- throw new IllegalStateException(StructureMessages.renderVariableSetWhenNotRendering(
- getCompleteId(), name));
+ throw new IllegalStateException(StructureMessages.renderVariableSetWhenNotRendering(getCompleteId(),
name));
if (renderVariables == null)
renderVariables = CollectionFactory.newCaseInsensitiveMap();
@@ -496,6 +492,11 @@
page.addLifecycleListener(listener);
}
+ public void removePageLifecycleListener(PageLifecycleListener listener)
+ {
+ page.removeLifecycleListener(listener);
+ }
+
public void addPageResetListener(PageResetListener listener)
{
page.addResetListener(listener);
@@ -513,19 +514,17 @@
conduits.put(parameterName, conduit);
}
-
- public String getPropertyName(String parameterName)
- {
+
+ public String getPropertyName(String parameterName)
+ {
Binding binding = getBinding(parameterName);
-
- if(binding == null) return null;
-
- if(binding instanceof InternalPropBinding)
- {
- return ((InternalPropBinding) binding).getPropertyName();
- }
-
+
+ if (binding == null)
+ return null;
+
+ if (binding instanceof InternalPropBinding) { return ((InternalPropBinding) binding).getPropertyName();
}
+
return null;
- }
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java?rev=906307&r1=906306&r2=906307&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/Page.java
Thu Feb 4 00:45:57 2010
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2009, 2010 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.
@@ -22,18 +22,15 @@
import java.util.Locale;
/**
- * Represents a unique page within the application. Pages are part of the <em>internal</em>
- * structure of a Tapestry
- * application; end developers who refer to "page" are really referring to the
- * {@link #getRootComponent() root
+ * Represents a unique page within the application. Pages are part of the <em>internal</em>
structure of a Tapestry
+ * application; end developers who refer to "page" are really referring to the {@link #getRootComponent()
root
* component} of the actual page.
* <p/>
- * One of the most important aspects of a Page is that it <em>does not</em> have
to be coded in a
- * thread-safe manner. Pages are always accessed within a single thread, associated with
a single
- * incoming request.
+ * One of the most important aspects of a Page is that it <em>does not</em> have
to be coded in a thread-safe manner.
+ * Pages are always accessed within a single thread, associated with a single incoming request.
* <p/>
- * The Page object is never visible to end-user code. The page also exists to provide a kind
of
- * service to components embedded (directly or indirectly) within the page.
+ * The Page object is never visible to end-user code. The page also exists to provide a kind
of service to components
+ * embedded (directly or indirectly) within the page.
*/
public interface Page
{
@@ -72,9 +69,9 @@
* just before the page
* is returned to the page pool.
* <p/>
- * A page may be clean or dirty. A page is dirty if its dirty count is greater than zero
- * (meaning that, during the render of the page, some components did not fully render),
or if
- * any of its listeners throw an exception from containingPageDidDetech().
+ * A page may be clean or dirty. A page is dirty if its dirty count is greater than zero
(meaning that, during the
+ * render of the page, some components did not fully render), or if any of its listeners
throw an exception from
+ * containingPageDidDetech().
* <p/>
* The page pool should discard pages that are dirty, rather than store them into the
pool.
*
@@ -106,6 +103,13 @@
void addLifecycleListener(PageLifecycleListener listener);
/**
+ * Removes a listener that was previously added.
+ *
+ * @since 5.2.0
+ */
+ void removeLifecycleListener(PageLifecycleListener listener);
+
+ /**
* Returns the logger of the root component element. Any logging about page construction
or
* activity should be sent
* to this logger.
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java?rev=906307&r1=906306&r2=906307&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/PageImpl.java
Thu Feb 4 00:45:57 2010
@@ -39,7 +39,7 @@
private ComponentPageElement rootElement;
- private final List<PageLifecycleListener> lifecycleListeners = CollectionFactory.newList();
+ private final List<PageLifecycleListener> lifecycleListeners = CollectionFactory.newThreadSafeList();
private final List<PageResetListener> resetListeners = CollectionFactory.newList();
@@ -111,6 +111,11 @@
lifecycleListeners.add(listener);
}
+ public void removeLifecycleListener(PageLifecycleListener listener)
+ {
+ lifecycleListeners.remove(listener);
+ }
+
public boolean detached()
{
boolean result = dirtyCount > 0;
|