You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/07/09 18:24:32 UTC
svn commit: r962593 - in /click/trunk/click:
extras/src/org/apache/click/extras/panel/ framework/src/org/apache/click/
framework/src/org/apache/click/control/ mock/src/org/apache/click/
mock/test/org/apache/click/
Author: sabob
Date: Fri Jul 9 16:24:32 2010
New Revision: 962593
URL: http://svn.apache.org/viewvc?rev=962593&view=rev
Log:
renamed CallbackDispatcher to ControlRegistry
Added:
click/trunk/click/framework/src/org/apache/click/ControlRegistry.java
- copied, changed from r962521, click/trunk/click/framework/src/org/apache/click/CallbackDispatcher.java
Removed:
click/trunk/click/framework/src/org/apache/click/CallbackDispatcher.java
Modified:
click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java
click/trunk/click/framework/src/org/apache/click/ClickServlet.java
click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java
click/trunk/click/mock/src/org/apache/click/MockContainer.java
click/trunk/click/mock/src/org/apache/click/MockContext.java
click/trunk/click/mock/test/org/apache/click/MockContextTest.java
Modified: click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java
URL: http://svn.apache.org/viewvc/click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java?rev=962593&r1=962592&r2=962593&view=diff
==============================================================================
--- click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java (original)
+++ click/trunk/click/extras/src/org/apache/click/extras/panel/TabbedPanel.java Fri Jul 9 16:24:32 2010
@@ -20,7 +20,7 @@ package org.apache.click.extras.panel;
import java.util.List;
import org.apache.click.ActionListener;
-import org.apache.click.CallbackDispatcher;
+import org.apache.click.ControlRegistry;
import org.apache.click.Context;
import org.apache.click.Control;
import org.apache.click.control.ActionLink;
@@ -409,7 +409,7 @@ public class TabbedPanel extends Panel {
@Override
public void onInit() {
if (hasBehaviors()) {
- CallbackDispatcher.registerAjaxTarget(this);
+ ControlRegistry.registerAjaxTarget(this);
}
initActivePanel();
Modified: click/trunk/click/framework/src/org/apache/click/ClickServlet.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ClickServlet.java?rev=962593&r1=962592&r2=962593&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/ClickServlet.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ClickServlet.java Fri Jul 9 16:24:32 2010
@@ -339,9 +339,9 @@ public class ClickServlet extends HttpSe
// Bind ActionEventDispatcher to current thread
ActionEventDispatcher.pushThreadLocalDispatcher(eventDispatcher);
- CallbackDispatcher callbackDispatcher = createCallbackDispatcher();
+ ControlRegistry controlRegistry = createControlRegistry();
// Bind CallbackDispatcher to current thread
- CallbackDispatcher.pushThreadLocalDispatcher(callbackDispatcher);
+ ControlRegistry.pushThreadLocalDispatcher(controlRegistry);
Context context = createContext(request, response, isPost);
// Bind context to current thread
@@ -423,7 +423,7 @@ public class ClickServlet extends HttpSe
if (request.getAttribute(MOCK_MODE_ENABLED) == null) {
Context.popThreadLocalContext();
}
- CallbackDispatcher.popThreadLocalDispatcher();
+ ControlRegistry.popThreadLocalDispatcher();
ActionEventDispatcher.popThreadLocalDispatcher();
}
}
@@ -575,7 +575,7 @@ public class ClickServlet extends HttpSe
protected void processPageEvents(Page page, Context context) throws Exception {
ActionEventDispatcher eventDispatcher = ActionEventDispatcher.getThreadLocalDispatcher();
- CallbackDispatcher callbackDispatcher = CallbackDispatcher.getThreadLocalDispatcher();
+ ControlRegistry controlRegistry = ControlRegistry.getThreadLocalDispatcher();
boolean errorOccurred = page instanceof ErrorPage;
// Support direct access of click-error.htm
@@ -583,9 +583,9 @@ public class ClickServlet extends HttpSe
ErrorPage errorPage = (ErrorPage) page;
errorPage.setMode(configService.getApplicationMode());
- // Notify the dispatcher and callbackRegistry of the error
+ // Notify the eventDispatcher and controlRegistry of the error
eventDispatcher.errorOccurred(errorPage.getError());
- callbackDispatcher.errorOccurred(errorPage.getError());
+ controlRegistry.errorOccurred(errorPage.getError());
}
boolean continueProcessing = performOnSecurityCheck(page, context);
@@ -613,8 +613,8 @@ public class ClickServlet extends HttpSe
}
}
- callbackDispatcher.processPreResponse(context);
- callbackDispatcher.processPreGetHeadElements(context);
+ controlRegistry.processPreResponse(context);
+ controlRegistry.processPreGetHeadElements(context);
performRender(page, context, partial);
}
@@ -1128,7 +1128,7 @@ public class ClickServlet extends HttpSe
// notify callbacks of destroy event
// TODO check that exceptions don't unnecessarily trigger preDestroy
- CallbackDispatcher.getThreadLocalDispatcher().processPreDestroy(page.getContext());
+ ControlRegistry.getThreadLocalDispatcher().processPreDestroy(page.getContext());
List<Control> controls = page.getControls();
@@ -1663,12 +1663,12 @@ public class ClickServlet extends HttpSe
}
/**
- * Creates and returns a new CallbackDispatcher instance.
+ * Creates and returns a new ControlRegistry instance.
*
- * @return the new CallbackDispatcher instance
+ * @return the new ControlRegistry instance
*/
- protected CallbackDispatcher createCallbackDispatcher() {
- return new CallbackDispatcher(configService);
+ protected ControlRegistry createControlRegistry() {
+ return new ControlRegistry(configService);
}
/**
@@ -1772,7 +1772,7 @@ public class ClickServlet extends HttpSe
ActionEventDispatcher eventDispatcher = ActionEventDispatcher.getThreadLocalDispatcher();
- CallbackDispatcher callbackDispatcher = CallbackDispatcher.getThreadLocalDispatcher();
+ ControlRegistry controlRegistry = ControlRegistry.getThreadLocalDispatcher();
// TODO Ajax requests shouldn't reach this code path
// Support direct access of click-error.htm
@@ -1782,7 +1782,7 @@ public class ClickServlet extends HttpSe
// Notify the dispatcher and registry of the error
eventDispatcher.errorOccurred(errorPage.getError());
- callbackDispatcher.errorOccurred(errorPage.getError());
+ controlRegistry.errorOccurred(errorPage.getError());
}
boolean continueProcessing = performOnSecurityCheck(page, context);
@@ -1798,8 +1798,8 @@ public class ClickServlet extends HttpSe
// Returned partial could be null
partial = performPageAction(page, pageAction, context);
- callbackDispatcher.processPreResponse(context);
- callbackDispatcher.processPreGetHeadElements(context);
+ controlRegistry.processPreResponse(context);
+ controlRegistry.processPreGetHeadElements(context);
renderPartial(partial, context);
}
@@ -1810,10 +1810,10 @@ public class ClickServlet extends HttpSe
// TODO: Ajax doesn't support forward. Is it still necessary to
// check isForward?
- if (callbackDispatcher.hasAjaxTargetControls() && !context.isForward()) {
+ if (controlRegistry.hasAjaxTargetControls() && !context.isForward()) {
// Perform onProcess for regsitered Ajax controls
- processAjaxControls(context, eventDispatcher, callbackDispatcher);
+ processAjaxControls(context, eventDispatcher, controlRegistry);
// Fire behaviors registered during the onProcess event
// The target behavior will set the eventDispatcher partial instance
@@ -1822,8 +1822,8 @@ public class ClickServlet extends HttpSe
// Ensure we execute the beforeResponse and beforeGetHeadElements
// for Ajax requests
- callbackDispatcher.processPreResponse(context);
- callbackDispatcher.processPreGetHeadElements(context);
+ controlRegistry.processPreResponse(context);
+ controlRegistry.processPreGetHeadElements(context);
partial = eventDispatcher.getPartial();
@@ -1840,8 +1840,8 @@ public class ClickServlet extends HttpSe
performOnRender(page, context);
}
- callbackDispatcher.processPreResponse(context);
- callbackDispatcher.processPreGetHeadElements(context);
+ controlRegistry.processPreResponse(context);
+ controlRegistry.processPreGetHeadElements(context);
performRender(page, context);
}
} else {
@@ -1857,11 +1857,11 @@ public class ClickServlet extends HttpSe
* processing, false otherwise.
*
* @param context the request context
- * @param callbackDispatcher the callback dispatcher
+ * @param controlRegistry the control registry
* @return true if the page should continue processing, false otherwise
*/
protected boolean processAjaxControls(Context context,
- ActionEventDispatcher eventDispatcher, CallbackDispatcher callbackDispatcher) {
+ ActionEventDispatcher eventDispatcher, ControlRegistry controlRegistry) {
boolean continueProcessing = true;
@@ -1869,8 +1869,8 @@ public class ClickServlet extends HttpSe
if (logger.isTraceEnabled()) {
logger.trace(" the following controls have been registered as potential Ajax targets:");
- if (!callbackDispatcher.hasAjaxTargetControls()) {
- for (Control control : callbackDispatcher.getAjaxTargetControls()) {
+ if (!controlRegistry.hasAjaxTargetControls()) {
+ for (Control control : controlRegistry.getAjaxTargetControls()) {
HtmlStringBuffer buffer = new HtmlStringBuffer();
String controlClassName = ClassUtils.getShortClassName(control.getClass());
buffer.append(" ").append(controlClassName);
@@ -1882,7 +1882,7 @@ public class ClickServlet extends HttpSe
}
}
- for (Control control : callbackDispatcher.getAjaxTargetControls()) {
+ for (Control control : controlRegistry.getAjaxTargetControls()) {
if (control.isAjaxTarget(context)) {
ajaxTarget = control;
Copied: click/trunk/click/framework/src/org/apache/click/ControlRegistry.java (from r962521, click/trunk/click/framework/src/org/apache/click/CallbackDispatcher.java)
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/ControlRegistry.java?p2=click/trunk/click/framework/src/org/apache/click/ControlRegistry.java&p1=click/trunk/click/framework/src/org/apache/click/CallbackDispatcher.java&r1=962521&r2=962593&rev=962593&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/CallbackDispatcher.java (original)
+++ click/trunk/click/framework/src/org/apache/click/ControlRegistry.java Fri Jul 9 16:24:32 2010
@@ -31,7 +31,7 @@ import org.apache.commons.lang.Validate;
*
* TODO: javadoc
*/
-public class CallbackDispatcher {
+public class ControlRegistry {
// Constants --------------------------------------------------------------
@@ -52,7 +52,7 @@ public class CallbackDispatcher {
// Constructors -----------------------------------------------------------
- public CallbackDispatcher(ConfigService configService) {
+ public ControlRegistry(ConfigService configService) {
this.logger = configService.getLogService();
}
@@ -67,12 +67,12 @@ public class CallbackDispatcher {
* @param control the control to register
*/
public static void registerAjaxTarget(Control control) {
- CallbackDispatcher instance = getThreadLocalDispatcher();
+ ControlRegistry instance = getThreadLocalDispatcher();
instance.internalRegisterAjaxTarget(control);
}
public static void registerCallback(Control control, Callback callback) {
- CallbackDispatcher instance = getThreadLocalDispatcher();
+ ControlRegistry instance = getThreadLocalDispatcher();
instance.internalRegisterCallback(control, callback);
}
@@ -223,7 +223,7 @@ public class CallbackDispatcher {
return callbacks;
}
- static CallbackDispatcher getThreadLocalDispatcher() {
+ static ControlRegistry getThreadLocalDispatcher() {
return getDispatcherStack().peek();
}
@@ -232,7 +232,7 @@ public class CallbackDispatcher {
*
* @param callbackDispatcher the CallbackDispatcher to add
*/
- static void pushThreadLocalDispatcher(CallbackDispatcher callbackDispatcher) {
+ static void pushThreadLocalDispatcher(ControlRegistry callbackDispatcher) {
getDispatcherStack().push(callbackDispatcher);
}
@@ -242,9 +242,9 @@ public class CallbackDispatcher {
*
* @return the callbackDispatcher instance on top of the dispatcher stack
*/
- static CallbackDispatcher popThreadLocalDispatcher() {
+ static ControlRegistry popThreadLocalDispatcher() {
RegistryStack registryStack = getDispatcherStack();
- CallbackDispatcher callbackDispatcher = registryStack.pop();
+ ControlRegistry callbackDispatcher = registryStack.pop();
if (registryStack.isEmpty()) {
THREAD_LOCAL_REGISTRY.set(null);
@@ -267,7 +267,7 @@ public class CallbackDispatcher {
/**
* Provides an unsynchronized Stack.
*/
- static class RegistryStack extends ArrayList<CallbackDispatcher> {
+ static class RegistryStack extends ArrayList<ControlRegistry> {
/** Serialization version indicator. */
private static final long serialVersionUID = 1L;
@@ -287,7 +287,7 @@ public class CallbackDispatcher {
* @param callbackDispatcher the CallbackDispatcher to push onto this stack
* @return the CallbackDispatcher pushed on this stack
*/
- private CallbackDispatcher push(CallbackDispatcher callbackDispatcher) {
+ private ControlRegistry push(ControlRegistry callbackDispatcher) {
add(callbackDispatcher);
return callbackDispatcher;
@@ -298,8 +298,8 @@ public class CallbackDispatcher {
*
* @return the CallbackDispatcher at the top of this stack
*/
- private CallbackDispatcher pop() {
- CallbackDispatcher callbackDispatcher = peek();
+ private ControlRegistry pop() {
+ ControlRegistry callbackDispatcher = peek();
remove(size() - 1);
@@ -312,7 +312,7 @@ public class CallbackDispatcher {
*
* @return the CallbackDispatcher at the top of this stack
*/
- private CallbackDispatcher peek() {
+ private ControlRegistry peek() {
int length = size();
if (length == 0) {
Modified: click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java?rev=962593&r1=962592&r2=962593&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java Fri Jul 9 16:24:32 2010
@@ -36,7 +36,7 @@ import javax.servlet.ServletContext;
import org.apache.click.ActionEventDispatcher;
import org.apache.click.ActionListener;
import org.apache.click.Behavior;
-import org.apache.click.CallbackDispatcher;
+import org.apache.click.ControlRegistry;
import org.apache.click.Context;
import org.apache.click.Control;
import org.apache.click.Page;
@@ -257,7 +257,7 @@ public abstract class AbstractControl im
// Register control here in case behavior was added *after* the onInit event.
// This can occur if the behavior is added in a listener event or during
// onRender.
- CallbackDispatcher.registerAjaxTarget(this);
+ ControlRegistry.registerAjaxTarget(this);
}
}
@@ -592,7 +592,7 @@ public abstract class AbstractControl im
// to ensure this code is called *before* onProcess. Leaving the code
// here opens problems if subclass does not call super.onInit
if (hasBehaviors()) {
- CallbackDispatcher.registerAjaxTarget(this);
+ ControlRegistry.registerAjaxTarget(this);
}
}
Modified: click/trunk/click/mock/src/org/apache/click/MockContainer.java
URL: http://svn.apache.org/viewvc/click/trunk/click/mock/src/org/apache/click/MockContainer.java?rev=962593&r1=962592&r2=962593&view=diff
==============================================================================
--- click/trunk/click/mock/src/org/apache/click/MockContainer.java (original)
+++ click/trunk/click/mock/src/org/apache/click/MockContainer.java Fri Jul 9 16:24:32 2010
@@ -665,7 +665,7 @@ public class MockContainer {
response.reset();
}
ActionEventDispatcher.getDispatcherStack().clear();
- CallbackDispatcher.getDispatcherStack().clear();
+ ControlRegistry.getDispatcherStack().clear();
}
/**
Modified: click/trunk/click/mock/src/org/apache/click/MockContext.java
URL: http://svn.apache.org/viewvc/click/trunk/click/mock/src/org/apache/click/MockContext.java?rev=962593&r1=962592&r2=962593&view=diff
==============================================================================
--- click/trunk/click/mock/src/org/apache/click/MockContext.java (original)
+++ click/trunk/click/mock/src/org/apache/click/MockContext.java Fri Jul 9 16:24:32 2010
@@ -240,12 +240,12 @@ public class MockContext extends Context
* @param response the mock response
* @param clickServlet the mock clickServlet
* @param actionEventDispatcher action and behavior dispatcher
- * @param callbackDispatcher the control callback dispatcher
+ * @param controlRegistry the control registry
* @return new Context instance
*/
public static MockContext initContext(MockServletConfig servletConfig,
MockRequest request, MockResponse response, ClickServlet clickServlet,
- ActionEventDispatcher actionEventDispatcher, CallbackDispatcher callbackDispatcher) {
+ ActionEventDispatcher actionEventDispatcher, ControlRegistry controlRegistry) {
try {
//Sanity checks
@@ -287,12 +287,12 @@ public class MockContext extends Context
actionEventDispatcher = new ActionEventDispatcher(configService);
}
- if (callbackDispatcher == null) {
- callbackDispatcher = new CallbackDispatcher(configService);
+ if (controlRegistry == null) {
+ controlRegistry = new ControlRegistry(configService);
}
ActionEventDispatcher.pushThreadLocalDispatcher(actionEventDispatcher);
- CallbackDispatcher.pushThreadLocalDispatcher(callbackDispatcher);
+ ControlRegistry.pushThreadLocalDispatcher(controlRegistry);
Context.pushThreadLocalContext(mockContext);
if (ClickUtils.getLogService() instanceof ConsoleLogService) {
@@ -333,27 +333,27 @@ public class MockContext extends Context
* Execute the preResponse callback event for all registered callbacks.
*/
public void executePreResponseCallbackEvent() {
- CallbackDispatcher dispatcher = CallbackDispatcher.getThreadLocalDispatcher();
+ ControlRegistry registry = ControlRegistry.getThreadLocalDispatcher();
- dispatcher.processPreResponse(this);
+ registry.processPreResponse(this);
}
/**
* Execute the preGetHeadElements callback event for all registered callbacks.
*/
public void executePreGetHeadElementsCallbackEvent() {
- CallbackDispatcher dispatcher = CallbackDispatcher.getThreadLocalDispatcher();
+ ControlRegistry registry = ControlRegistry.getThreadLocalDispatcher();
- dispatcher.processPreGetHeadElements(this);
+ registry.processPreGetHeadElements(this);
}
/**
* Execute the preDestroy callback event for all registered callbacks.
*/
public void executePreDestroyCallbackEvent() {
- CallbackDispatcher dispatcher = CallbackDispatcher.getThreadLocalDispatcher();
+ ControlRegistry registry = ControlRegistry.getThreadLocalDispatcher();
- dispatcher.processPreDestroy(this);
+ registry.processPreDestroy(this);
}
/**
@@ -373,8 +373,8 @@ public class MockContext extends Context
* method will remove any references to objects, thus freeing up memory.
*/
public void reset() {
- CallbackDispatcher callbackDispatcher = CallbackDispatcher.getThreadLocalDispatcher();
- callbackDispatcher.clear();
+ ControlRegistry registry = ControlRegistry.getThreadLocalDispatcher();
+ registry.clear();
ActionEventDispatcher actionEventDispatcher = ActionEventDispatcher.getThreadLocalDispatcher();
actionEventDispatcher.clear();
Modified: click/trunk/click/mock/test/org/apache/click/MockContextTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/mock/test/org/apache/click/MockContextTest.java?rev=962593&r1=962592&r2=962593&view=diff
==============================================================================
--- click/trunk/click/mock/test/org/apache/click/MockContextTest.java (original)
+++ click/trunk/click/mock/test/org/apache/click/MockContextTest.java Fri Jul 9 16:24:32 2010
@@ -213,7 +213,7 @@ public class MockContextTest extends Tes
preResponseCalled = false;
preDestroyCalled = false;
- CallbackDispatcher.registerCallback(submit, new Callback() {
+ ControlRegistry.registerCallback(submit, new Callback() {
public void preDestroy(Control source) {
preDestroyCalled = true;
@@ -228,10 +228,10 @@ public class MockContextTest extends Tes
}
});
- CallbackDispatcher dispatcher = CallbackDispatcher.getThreadLocalDispatcher();
+ ControlRegistry registry = ControlRegistry.getThreadLocalDispatcher();
// Assert there is one callback registered
- assertEquals(1, dispatcher.getCallbacks().size());
+ assertEquals(1, registry.getCallbacks().size());
// Process the preResponse callback event
context.executePreResponseCallbackEvent();
@@ -249,7 +249,7 @@ public class MockContextTest extends Tes
// The reason the callbacks are not automatically removed is because the
// last callback is onDestroy, which is right before the request goes out
// of scope
- assertEquals(1, dispatcher.getCallbacks().size());
+ assertEquals(1, registry.getCallbacks().size());
}
/**
@@ -264,7 +264,7 @@ public class MockContextTest extends Tes
preResponseCalled = false;
preDestroyCalled = false;
- CallbackDispatcher.registerCallback(submit, new Callback() {
+ ControlRegistry.registerCallback(submit, new Callback() {
public void preDestroy(Control source) {
preDestroyCalled = true;
@@ -279,10 +279,10 @@ public class MockContextTest extends Tes
}
});
- CallbackDispatcher dispatcher = CallbackDispatcher.getThreadLocalDispatcher();
+ ControlRegistry registry = ControlRegistry.getThreadLocalDispatcher();
// Assert there is one callback registered
- assertEquals(1, dispatcher.getCallbacks().size());
+ assertEquals(1, registry.getCallbacks().size());
// Context reset should clear the dispatcher
context.reset();
@@ -291,7 +291,7 @@ public class MockContextTest extends Tes
// The reason the callbacks are not automatically removed is because the
// last callback is onDestroy, which is right before the request goes out
// of scope
- assertEquals(0, dispatcher.getCallbacks().size());
+ assertEquals(0, registry.getCallbacks().size());
}
// Callback + Behavior tests ----------------------------------------------
@@ -353,11 +353,11 @@ public class MockContextTest extends Tes
// Assert there are no behaviors registered after reset is invoked
assertEquals(0, eventDispatcher.getBehaviorSourceSet().size());
- CallbackDispatcher callbackDispatcher = CallbackDispatcher.getThreadLocalDispatcher();
+ ControlRegistry registry = ControlRegistry.getThreadLocalDispatcher();
// Assert that the submit control is registered as a callback
- assertEquals(1, callbackDispatcher.getAjaxTargetControls().size());
- assertSame(submit, callbackDispatcher.getAjaxTargetControls().iterator().next());
+ assertEquals(1, registry.getAjaxTargetControls().size());
+ assertSame(submit, registry.getAjaxTargetControls().iterator().next());
// Process the preResponse callback event
context.executePreResponseCallbackEvent();
@@ -372,12 +372,12 @@ public class MockContextTest extends Tes
assertTrue("preDestroy callback event was not processed", preDestroyCalled);
// Assert that the callback was not removed after all events was processed
- assertEquals(1, callbackDispatcher.getAjaxTargetControls().size());
+ assertEquals(1, registry.getAjaxTargetControls().size());
// Test that reset will clear the callback dispatcher
context.reset();
// Assert that the callback was removed after reset
- assertEquals(0, callbackDispatcher.getAjaxTargetControls().size());
+ assertEquals(0, registry.getAjaxTargetControls().size());
}
}