Permalink
Browse files

Revert Serializable changes on existing Callback interfaces and add new

ones explicitly requiring Serializable. Altered Events utility class on
this. API should make more clear which ones really need to be
serializable. This also reduces unnecessary and potentially confusing
serialVersionUID mess.
  • Loading branch information...
1 parent 9313941 commit 83b9c6e5920d5fa62be3bd8b3fe37824371e7f46 @BalusC BalusC committed Apr 7, 2015
@@ -172,7 +172,7 @@ public Cache() {
// Execute the following code in PreRenderView, since at construction time the "useBuffer" and "key" attributes
// have not been set, and there is no @PostContruct for UIComponents.
- subscribeToViewEvent(PRE_RENDER, new Callback.Void() {
+ subscribeToViewEvent(PRE_RENDER, new Callback.SerializableVoid() {
private static final long serialVersionUID = 1L;
@@ -193,9 +193,6 @@ public void invoke() {
// After the RENDER_RESPONSE phase, copy the area we need to cache from the response buffer
// and insert it into our cache
subscribeToRequestAfterPhase(RENDER_RESPONSE, new Callback.Void() {
-
- private static final long serialVersionUID = 1L;
-
@Override
public void invoke() {
String content = null;
@@ -214,9 +214,6 @@ protected void process(final FacesContext context, final PhaseId phaseId) {
}
process(context, getModel(phaseId), new Callback.Returning<Void>() {
-
- private static final long serialVersionUID = 1L;
-
@Override
public Void invoke() {
processTreeNode(context, phaseId);
@@ -238,9 +235,6 @@ public boolean visitTree(final VisitContext context, final VisitCallback callbac
}
return process(context.getFacesContext(), getModel(PhaseId.ANY_PHASE), new Callback.Returning<Boolean>() {
-
- private static final long serialVersionUID = 1L;
-
@Override
public Boolean invoke() {
VisitResult result = context.invokeVisitCallback(Tree.this, callback);
@@ -271,9 +265,6 @@ public void broadcast(FacesEvent event) throws AbortProcessingException {
final FacesEvent wrapped = treeEvent.getWrapped();
process(context, treeEvent.getNode(), new Callback.Returning<Void>() {
-
- private static final long serialVersionUID = 1L;
-
@Override
public Void invoke() {
wrapped.getComponent().broadcast(wrapped);
@@ -298,9 +289,6 @@ public Void invoke() {
*/
protected void processTreeNode(final FacesContext context, final PhaseId phaseId) {
processTreeNode(phaseId, new Callback.ReturningWithArgument<Void, TreeNode>() {
-
- private static final long serialVersionUID = 1L;
-
@Override
public Void invoke(TreeNode treeNode) {
if (treeNode != null) {
@@ -325,9 +313,6 @@ public Void invoke(TreeNode treeNode) {
*/
protected boolean visitTreeNode(final VisitContext context, final VisitCallback callback) {
return processTreeNode(PhaseId.ANY_PHASE, new Callback.ReturningWithArgument<Boolean, TreeNode>() {
-
- private static final long serialVersionUID = 1L;
-
@Override
public Boolean invoke(TreeNode treeNode) {
if (treeNode != null) {
@@ -95,9 +95,6 @@ protected void process(final FacesContext context, final PhaseId phaseId) {
}
process(context, new Callback.ReturningWithArgument<Void, Tree>() {
-
- private static final long serialVersionUID = 1L;
-
@Override
public Void invoke(Tree tree) {
if (tree.getCurrentModelNode() != null) {
@@ -134,9 +131,6 @@ public boolean visitTree(final VisitContext context, final VisitCallback callbac
}
return process(context.getFacesContext(), new Callback.ReturningWithArgument<Boolean, Tree>() {
-
- private static final long serialVersionUID = 1L;
-
@Override
public Boolean invoke(Tree tree) {
if (tree.getCurrentModelNode() != null) {
@@ -151,7 +145,6 @@ public Boolean invoke(Tree tree) {
return false;
}
-
});
}
@@ -32,7 +32,7 @@
import javax.faces.view.facelets.FaceletContext;
import org.omnifaces.el.ReadOnlyValueExpression;
-import org.omnifaces.util.Callback.Returning;
+import org.omnifaces.util.Callback.SerializableReturning;
import org.omnifaces.util.Components;
import org.omnifaces.util.State;
@@ -135,7 +135,7 @@ public void doProcess() {
}
}
- public static class ComponentClientIdResolver implements Returning<Object> {
+ public static class ComponentClientIdResolver implements SerializableReturning<Object> {
private static final long serialVersionUID = 1L;
@@ -68,15 +68,13 @@
private enum Type {
LT(new Callback.ReturningWithArgument<Boolean, List<Comparable>>() {
- private static final long serialVersionUID = 1L;
@Override
public Boolean invoke(List<Comparable> values) {
return new ArrayList<>(new TreeSet<>(values)).equals(values);
}
}),
LTE(new Callback.ReturningWithArgument<Boolean, List<Comparable>>() {
- private static final long serialVersionUID = 1L;
@Override
public Boolean invoke(List<Comparable> values) {
List<Comparable> sortedValues = new ArrayList<>(values);
@@ -86,7 +84,6 @@ public Boolean invoke(List<Comparable> values) {
}),
GT(new Callback.ReturningWithArgument<Boolean, List<Comparable>>() {
- private static final long serialVersionUID = 1L;
@Override
public Boolean invoke(List<Comparable> values) {
List<Comparable> sortedValues = new ArrayList<>(new TreeSet<>(values));
@@ -96,7 +93,6 @@ public Boolean invoke(List<Comparable> values) {
}),
GTE(new Callback.ReturningWithArgument<Boolean, List<Comparable>>() {
- private static final long serialVersionUID = 1L;
@Override
public Boolean invoke(List<Comparable> values) {
List<Comparable> sortedValues = new ArrayList<>(values);
@@ -33,10 +33,10 @@
private static final long serialVersionUID = 1L;
private Callback.ReturningWithArgument<Object, ELContext> callbackWithArgument;
- private Callback.Returning<Object> callbackReturning;
+ private Callback.SerializableReturning<Object> callbackReturning;
private Class<?> expectedType;
- public ReadOnlyValueExpression(Class<?> expectedType, Callback.Returning<Object> callbackReturning) {
+ public ReadOnlyValueExpression(Class<?> expectedType, Callback.SerializableReturning<Object> callbackReturning) {
this(expectedType);
this.callbackReturning = callbackReturning;
}
@@ -123,11 +123,11 @@ public int hashCode() {
public boolean isLiteralText() {
return true;
}
-
+
/**
* Returns the functional interface that will be called when the value expression is resolved
* and which receives the proper ELContext.
- *
+ *
* @return the functional interface that will be called when the value expression is resolved
* @since 2.1
*/
@@ -137,32 +137,32 @@ public boolean isLiteralText() {
/**
* Sets the functional interface that will be called when the value expression is resolved and
- * which receives the proper ELContext.
- *
+ * which receives the proper ELContext.
+ *
* @param callbackWithArgument functional interface returning what the value expression will return
* @since 2.1
*/
public void setCallbackWithArgument(Callback.ReturningWithArgument<Object, ELContext> callbackWithArgument) {
this.callbackWithArgument = callbackWithArgument;
}
-
+
/**
* Returns the functional interface that will be called when the value expression is resolved
- *
+ *
* @return the functional interface that will be called when the value expression is resolved
* @since 2.1
*/
- public Callback.Returning<Object> getCallbackReturning() {
+ public Callback.SerializableReturning<Object> getCallbackReturning() {
return callbackReturning;
}
/**
* Sets the functional interface that will be called when the value expression is resolved
- *
+ *
* @param callbackReturning functional interface returning what the value expression will return
* @since 2.1
*/
- public void setCallbackReturning(Callback.Returning<Object> callbackReturning) {
+ public void setCallbackReturning(Callback.SerializableReturning<Object> callbackReturning) {
this.callbackReturning = callbackReturning;
}
@@ -99,9 +99,12 @@ public void apply(FaceletContext context, final UIComponent parent) throws IOExc
// We can't use hasInvokedSubmit() before the component is added to view, because the client ID isn't available.
// Hence, we subscribe this check to after phase of restore view.
- subscribeToRequestAfterPhase(RESTORE_VIEW, new Callback.Void() { private static final long serialVersionUID = 1L; @Override public void invoke() {
- processIgnoreValidationFailed((UICommand) parent);
- }});
+ subscribeToRequestAfterPhase(RESTORE_VIEW, new Callback.Void() {
+ @Override
+ public void invoke() {
+ processIgnoreValidationFailed((UICommand) parent);
+ }
+ });
}
/**
@@ -220,7 +220,7 @@ public void apply(FaceletContext context, final UIComponent parent) throws IOExc
// We can't use getCurrentForm() or hasInvokedSubmit() before the component is added to view, because the client ID isn't available.
// Hence, we subscribe this check to after phase of restore view.
- subscribeToRequestAfterPhase(RESTORE_VIEW, new Callback.Void() { private static final long serialVersionUID = 1L; @Override public void invoke() {
+ subscribeToRequestAfterPhase(RESTORE_VIEW, new Callback.Void() { @Override public void invoke() {
processValidateBean(parent);
}});
}
@@ -266,7 +266,7 @@ protected void processValidateBean(UIComponent component) {
* After update model values phase, validate actual bean. But don't proceed to render response on fail.
*/
private void validateActualBean(final UIForm form, final Object bean, final String groups) {
- ValidateBeanCallback validateActualBean = new ValidateBeanCallback() { private static final long serialVersionUID = 1L; @Override public void run() {
+ ValidateBeanCallback validateActualBean = new ValidateBeanCallback() { @Override public void run() {
FacesContext context = FacesContext.getCurrentInstance();
validate(context, form, bean, groups, false);
}};
@@ -283,18 +283,18 @@ private void validateActualBean(final UIForm form, final Object bean, final Stri
private void validateCopiedBean(final UIForm form, final Object bean, final String copier, final String groups) {
final Map<String, Object> properties = new HashMap<>();
- ValidateBeanCallback collectBeanProperties = new ValidateBeanCallback() { private static final long serialVersionUID = 1L; @Override public void run() {
+ ValidateBeanCallback collectBeanProperties = new ValidateBeanCallback() { @Override public void run() {
FacesContext context = FacesContext.getCurrentInstance();
- forEachInputWithMatchingBase(context, form, bean, new Operation() { private static final long serialVersionUID = 1L; @Override public void run(EditableValueHolder v, ValueReference vr) {
+ forEachInputWithMatchingBase(context, form, bean, new Operation() { @Override public void run(EditableValueHolder v, ValueReference vr) {
addCollectingValidator(v, vr, properties);
}});
}};
- ValidateBeanCallback checkConstraints = new ValidateBeanCallback() { private static final long serialVersionUID = 1L; @Override public void run() {
+ ValidateBeanCallback checkConstraints = new ValidateBeanCallback() { @Override public void run() {
FacesContext context = FacesContext.getCurrentInstance();
- forEachInputWithMatchingBase(context, form, bean, new Operation() { private static final long serialVersionUID = 1L; @Override public void run(EditableValueHolder v, ValueReference vr) {
+ forEachInputWithMatchingBase(context, form, bean, new Operation() { @Override public void run(EditableValueHolder v, ValueReference vr) {
removeCollectingValidator(v);
}});
@@ -311,7 +311,7 @@ private void validateCopiedBean(final UIForm form, final Object bean, final Stri
* Before validations phase of current request, subscribe the {@link BeanValidationEventListener} to validate the form based on groups.
*/
private void validateForm(final String validationGroups, final boolean disabled) {
- ValidateBeanCallback validateForm = new ValidateBeanCallback() { private static final long serialVersionUID = 1L; @Override public void run() {
+ ValidateBeanCallback validateForm = new ValidateBeanCallback() { @Override public void run() {
SystemEventListener listener = new BeanValidationEventListener(validationGroups, disabled);
subscribeToViewEvent(PreValidateEvent.class, listener);
subscribeToViewEvent(PostValidateEvent.class, listener);
@@ -326,7 +326,7 @@ private static void forEachInputWithMatchingBase(final FacesContext context, UIC
forEachComponent(context)
.fromRoot(form)
.ofTypes(EditableValueHolder.class)
- .invoke(new Callback.WithArgument<UIComponent>() { private static final long serialVersionUID = 1L; @Override public void invoke(UIComponent component) {
+ .invoke(new Callback.WithArgument<UIComponent>() { @Override public void invoke(UIComponent component) {
ValueExpression valueExpression = component.getValueExpression("value");
@@ -427,8 +427,6 @@ public void validate(FacesContext context, UIComponent component, Object value)
private abstract static class ValidateBeanCallback implements Callback.Void {
- private static final long serialVersionUID = 1L;
-
@Override
public void invoke() {
try {
@@ -452,8 +450,6 @@ public void invoke() {
private abstract static class Operation implements Callback.WithArgument<Object[]> {
- private static final long serialVersionUID = 1L;
-
@Override
public void invoke(Object[] args) {
run((EditableValueHolder) args[0], (ValueReference) args[1]);
@@ -218,8 +218,6 @@ else if (sendRedirect != null && sendError != null) {
}
subscribeToRequestComponentEvent(parent, PostValidateEvent.class, new Callback.WithArgument<ComponentSystemEvent>() {
- private static final long serialVersionUID = 1L;
-
@Override
public void invoke(ComponentSystemEvent event) {
processViewParamValidationFailed(event);
Oops, something went wrong.

0 comments on commit 83b9c6e

Please sign in to comment.