Author: konstantin.mishin
Date: 2008-06-18 12:26:52 -0400 (Wed, 18 Jun 2008)
New Revision: 9099
Modified:
trunk/framework/api/src/main/java/org/richfaces/event/ComponentPhaseEventHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptorPhaseEventHandler.java
trunk/framework/impl/src/main/java/org/richfaces/event/ComponentViewPhaseListener.java
trunk/framework/impl/src/main/java/org/richfaces/util/ComponentPhaseEventHandlerUtils.java
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerViewPhaseListener.java
Log:
RF-2815
Modified:
trunk/framework/api/src/main/java/org/richfaces/event/ComponentPhaseEventHandler.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/event/ComponentPhaseEventHandler.java 2008-06-18
15:21:17 UTC (rev 9098)
+++
trunk/framework/api/src/main/java/org/richfaces/event/ComponentPhaseEventHandler.java 2008-06-18
16:26:52 UTC (rev 9099)
@@ -1,11 +1,9 @@
package org.richfaces.event;
-import java.io.Serializable;
-
import javax.faces.component.UIComponent;
import javax.faces.event.PhaseEvent;
-public interface ComponentPhaseEventHandler extends Serializable {
+public interface ComponentPhaseEventHandler {
Object beforePhaseBegin(PhaseEvent event);
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptorPhaseEventHandler.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptorPhaseEventHandler.java 2008-06-18
15:21:17 UTC (rev 9098)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptorPhaseEventHandler.java 2008-06-18
16:26:52 UTC (rev 9099)
@@ -11,11 +11,6 @@
public class UIDataAdaptorPhaseEventHandler implements
ComponentPhaseEventHandler {
- /**
- *
- */
- private static final long serialVersionUID = -1356035330152521515L;
-
/* (non-Javadoc)
* @see
org.richfaces.event.ComponentPhaseEventHandler#bcomponentEnd(javax.faces.component.UIComponent,
javax.faces.event.PhaseEvent, java.lang.Object)
*/
Modified:
trunk/framework/impl/src/main/java/org/richfaces/event/ComponentViewPhaseListener.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/event/ComponentViewPhaseListener.java 2008-06-18
15:21:17 UTC (rev 9098)
+++
trunk/framework/impl/src/main/java/org/richfaces/event/ComponentViewPhaseListener.java 2008-06-18
16:26:52 UTC (rev 9099)
@@ -18,19 +18,17 @@
*/
private static final long serialVersionUID = -2437433246178955788L;
- private static ComponentPhaseEventHandler[] handlers =
ComponentPhaseEventHandlerUtils.getHandlers();
- private static Object[] states = null;
-
public void afterPhase(PhaseEvent event) {
}
- private void beforePhase(PhaseEvent event, UIComponent component) {
+ private void beforePhase(PhaseEvent event, UIComponent component,
+ ComponentPhaseEventHandler[] handlers, Object[] states) {
for (int i = 0; i < handlers.length; i++) {
handlers[i].componentBegin(component, event, states[i]);
}
Iterator<UIComponent> children = component.getFacetsAndChildren();
while (children.hasNext()) {
- beforePhase(event, children.next());
+ beforePhase(event, children.next(), handlers, states);
}
for (int i = 0; i < handlers.length; i++) {
handlers[i].componentEnd(component, event, states[i]);
@@ -38,19 +36,19 @@
}
public void beforePhase(PhaseEvent event) {
- states = new Object[handlers.length];
+ ComponentPhaseEventHandler[] handlers = ComponentPhaseEventHandlerUtils.getHandlers();
+ Object[] states = new Object[handlers.length];
for (int i = 0; i < handlers.length; i++) {
states[i] = handlers[i].beforePhaseBegin(event);
}
FacesContext facesContext = event.getFacesContext();
UIViewRoot viewRoot = facesContext.getViewRoot();
if (viewRoot != null && handlers != null) {
- beforePhase(event, viewRoot);
+ beforePhase(event, viewRoot, handlers, states);
}
for (int i = 0; i < handlers.length; i++) {
handlers[i].beforePhaseEnd(event, states[i]);
}
- states = null;
}
public PhaseId getPhaseId() {
Modified:
trunk/framework/impl/src/main/java/org/richfaces/util/ComponentPhaseEventHandlerUtils.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/util/ComponentPhaseEventHandlerUtils.java 2008-06-18
15:21:17 UTC (rev 9098)
+++
trunk/framework/impl/src/main/java/org/richfaces/util/ComponentPhaseEventHandlerUtils.java 2008-06-18
16:26:52 UTC (rev 9099)
@@ -5,9 +5,11 @@
import java.net.URL;
import java.util.Enumeration;
import java.util.LinkedList;
+import java.util.Map;
import java.util.Scanner;
import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
import org.ajax4jsf.resource.util.URLToStreamHelper;
import org.ajax4jsf.util.ServicesUtils;
@@ -15,22 +17,25 @@
public class ComponentPhaseEventHandlerUtils{
- static private ComponentPhaseEventHandler[] handlers = null;
-
+ private static final String KEY = ComponentPhaseEventHandlerUtils.class.getName();
+
private ComponentPhaseEventHandlerUtils() {}
public static ComponentPhaseEventHandler[] getHandlers() {
- if (handlers == null) {
- synchronized(ComponentPhaseEventHandlerUtils.class) {
- if (handlers == null) {
- init();
- }
- }
+ FacesContext context = FacesContext.getCurrentInstance();
+ Map<String, Object> applicationMap =
context.getExternalContext().getApplicationMap();
+ ComponentPhaseEventHandler[] handlers;
+ synchronized(applicationMap) {
+ handlers = (ComponentPhaseEventHandler[])applicationMap.get(KEY);
+ if (handlers == null) {
+ handlers = init();
+ applicationMap.put(KEY, handlers);
+ }
}
return handlers;
}
- private static void init() {
+ private static ComponentPhaseEventHandler[] init() {
LinkedList<ComponentPhaseEventHandler> list = new
LinkedList<ComponentPhaseEventHandler>();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
String resource =
"META-INF/services/org.richfaces.component.ComponentPhaseEventHandler";
@@ -56,6 +61,6 @@
} catch (IOException e) {
throw new FacesException("Error load resource "+ resource, e);
}
- handlers = list.toArray(new ComponentPhaseEventHandler[list.size()]);
+ return list.toArray(new ComponentPhaseEventHandler[list.size()]);
}
}
Modified:
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerViewPhaseListener.java
===================================================================
---
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerViewPhaseListener.java 2008-06-18
15:21:17 UTC (rev 9098)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerViewPhaseListener.java 2008-06-18
16:26:52 UTC (rev 9099)
@@ -51,11 +51,6 @@
public class DataScrollerViewPhaseListener implements ComponentPhaseEventHandler {
- /**
- *
- */
- private static final long serialVersionUID = -3614288642745891577L;
-
private static final Log log = LogFactory.getLog(DataScrollerViewPhaseListener.class);
private static final class ComponentConnections {