aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2020-07-03 11:39:41 +0300
committerGitHub <noreply@github.com>2020-07-03 11:39:41 +0300
commit40570e17319d96adcfebaaa8c98b1e16f58902f0 (patch)
treea46553c609af2933f2a1dea5f6f4416a6a95db97 /server
parentbafced6af34e398d52ef466b5752b34a8fd3684a (diff)
downloadvaadin-framework-40570e17319d96adcfebaaa8c98b1e16f58902f0.tar.gz
vaadin-framework-40570e17319d96adcfebaaa8c98b1e16f58902f0.zip
Ensure type safety and serializable nature of all the listeners (#12045)
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/data/provider/DataProviderListener.java4
-rw-r--r--server/src/main/java/com/vaadin/event/ContextClickEvent.java2
-rw-r--r--server/src/main/java/com/vaadin/event/EventRouter.java134
-rw-r--r--server/src/main/java/com/vaadin/event/ListenerMethod.java221
-rw-r--r--server/src/main/java/com/vaadin/event/MethodEventSource.java90
-rw-r--r--server/src/main/java/com/vaadin/event/SortEvent.java2
-rw-r--r--server/src/main/java/com/vaadin/event/UIEvents.java2
-rw-r--r--server/src/main/java/com/vaadin/server/AbstractClientConnector.java168
-rw-r--r--server/src/main/java/com/vaadin/server/BootstrapListener.java7
-rw-r--r--server/src/main/java/com/vaadin/server/Page.java15
-rw-r--r--server/src/main/java/com/vaadin/ui/Button.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/HasComponents.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/LoginForm.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/Notification.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/PopupView.java3
-rw-r--r--server/src/main/java/com/vaadin/ui/TabSheet.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/Upload.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/Window.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/ColumnReorderListener.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/ColumnResizeListener.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/ColumnVisibilityChangeListener.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/EditorCancelListener.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/EditorOpenListener.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/EditorSaveListener.java5
24 files changed, 651 insertions, 67 deletions
diff --git a/server/src/main/java/com/vaadin/data/provider/DataProviderListener.java b/server/src/main/java/com/vaadin/data/provider/DataProviderListener.java
index 4ee35013f9..a5b6823808 100644
--- a/server/src/main/java/com/vaadin/data/provider/DataProviderListener.java
+++ b/server/src/main/java/com/vaadin/data/provider/DataProviderListener.java
@@ -15,7 +15,7 @@
*/
package com.vaadin.data.provider;
-import java.io.Serializable;
+import com.vaadin.event.SerializableEventListener;
/**
* Interface for listening for a data change events fired by a
@@ -28,7 +28,7 @@ import java.io.Serializable;
* the data type
*/
@FunctionalInterface
-public interface DataProviderListener<T> extends Serializable {
+public interface DataProviderListener<T> extends SerializableEventListener {
/**
* Invoked when this listener receives a data change event from a data
diff --git a/server/src/main/java/com/vaadin/event/ContextClickEvent.java b/server/src/main/java/com/vaadin/event/ContextClickEvent.java
index c9ed77f001..774b17f8f8 100644
--- a/server/src/main/java/com/vaadin/event/ContextClickEvent.java
+++ b/server/src/main/java/com/vaadin/event/ContextClickEvent.java
@@ -46,7 +46,7 @@ public class ContextClickEvent extends ClickEvent {
* Listener for {@link ContextClickEvent ContextClickEvents}.
*/
@FunctionalInterface
- public interface ContextClickListener extends Serializable {
+ public interface ContextClickListener extends SerializableEventListener {
/**
* Called when the context click happens.
diff --git a/server/src/main/java/com/vaadin/event/EventRouter.java b/server/src/main/java/com/vaadin/event/EventRouter.java
index 34f71afb21..d1164c0542 100644
--- a/server/src/main/java/com/vaadin/event/EventRouter.java
+++ b/server/src/main/java/com/vaadin/event/EventRouter.java
@@ -24,6 +24,8 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import com.vaadin.server.ErrorEvent;
import com.vaadin.server.ErrorHandler;
@@ -52,10 +54,13 @@ public class EventRouter implements MethodEventSource {
* events generated by this component. Don't add a JavaDoc comment here, we
* use the default documentation from implemented interface.
*/
+ @Deprecated
@Override
public Registration addListener(Class<?> eventType, Object object,
Method method) {
Objects.requireNonNull(object, "Listener must not be null.");
+ getLogger().log(Level.WARNING, "Adding listeners with type Object is"
+ + " deprecated, event listener should extend SerializableEventListener");
if (listenerList == null) {
listenerList = new LinkedHashSet<>();
}
@@ -65,6 +70,24 @@ public class EventRouter implements MethodEventSource {
return () -> listenerList.remove(listenerMethod);
}
+ /*
+ * Registers a new listener with the specified activation method to listen
+ * events generated by this component. Don't add a JavaDoc comment here, we
+ * use the default documentation from implemented interface.
+ */
+ @Override
+ public Registration addListener(Class<?> eventType,
+ SerializableEventListener listener, Method method) {
+ Objects.requireNonNull(listener, "Listener must not be null.");
+ if (listenerList == null) {
+ listenerList = new LinkedHashSet<>();
+ }
+ ListenerMethod listenerMethod = new ListenerMethod(eventType, listener,
+ method);
+ listenerList.add(listenerMethod);
+ return () -> listenerList.remove(listenerMethod);
+ }
+
/**
* Registers a new event listener with the specified activation method to
* listen events generated by this component. If the activation method does
@@ -87,7 +110,11 @@ public class EventRouter implements MethodEventSource {
* For more information on the inheritable event mechanism see the
* {@link com.vaadin.event com.vaadin.event package documentation}.
* </p>
- *
+ *
+ * @deprecated As of 8.12. Use
+ * {@link #addListener(Class, SerializableEventListener, Method, String, SharedState)}
+ * instead
+ *
* @param eventType
* the type of the listened event. Events of this type or its
* subclasses activate the listener.
@@ -106,9 +133,11 @@ public class EventRouter implements MethodEventSource {
* if {@code target} is {@code null}
* @since 8.2
*/
+ @Deprecated
public Registration addListener(Class<?> eventType, Object target,
Method method, String eventIdentifier, SharedState state) {
- Objects.requireNonNull(target, "Listener must not be null.");
+ getLogger().log(Level.WARNING, "Adding listeners with type Object is"
+ + " deprecated, event listener should extend SerializableEventListener");
if (listenerList == null) {
listenerList = new LinkedHashSet<>();
}
@@ -127,15 +156,80 @@ public class EventRouter implements MethodEventSource {
};
}
+ /**
+ * Registers a new event listener with the specified activation method to
+ * listen events generated by this component. If the activation method does
+ * not have any arguments the event object will not be passed to it when
+ * it's called.
+ *
+ * <p>
+ * This method additionally informs the event-api to stop routing events
+ * with the given {@code eventIdentifier} to the components handleEvent
+ * function call.
+ * </p>
+ *
+ * <p>
+ * The only way to remove the listener is to use the returned
+ * {@link Registration}. The other methods, e.g.
+ * {@link #removeAllListeners()} do not do that.
+ * </p>
+ *
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.vaadin.event com.vaadin.event package documentation}.
+ * </p>
+ *
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param listener
+ * the listener instance who owns the activation method.
+ * @param method
+ * the activation method.
+ * @param eventIdentifier
+ * the identifier of the event to listen for
+ * @param state
+ * The component State
+ * @return a registration object for removing the listener
+ * @throws IllegalArgumentException
+ * unless {@code method} has exactly one match in {@code target}
+ * @throws NullPointerException
+ * if {@code target} is {@code null}
+ * @since 8.12
+ */
+ public Registration addListener(Class<?> eventType,
+ SerializableEventListener listener, Method method,
+ String eventIdentifier, SharedState state) {
+ if (listenerList == null) {
+ listenerList = new LinkedHashSet<>();
+ }
+ ListenerMethod listenerMethod = new ListenerMethod(eventType, listener,
+ method);
+ listenerList.add(listenerMethod);
+
+ Registration registration = ComponentStateUtil
+ .addRegisteredEventListener(state, eventIdentifier);
+
+ return () -> {
+ listenerList.remove(listenerMethod);
+ if (!hasListeners(eventType)) {
+ registration.remove();
+ }
+ };
+ }
+
/*
* Registers a new listener with the specified named activation method to
* listen events generated by this component. Don't add a JavaDoc comment
* here, we use the default documentation from implemented interface.
*/
+ @Deprecated
@Override
public Registration addListener(Class<?> eventType, Object object,
String methodName) {
Objects.requireNonNull(object, "Listener must not be null.");
+ getLogger().log(Level.WARNING, "Adding listeners with type Object is"
+ + " deprecated, event listener should extend SerializableEventListener");
if (listenerList == null) {
listenerList = new LinkedHashSet<>();
}
@@ -146,11 +240,30 @@ public class EventRouter implements MethodEventSource {
}
/*
+ * Registers a new listener with the specified named activation method to
+ * listen events generated by this component. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
+ */
+ @Override
+ public Registration addListener(Class<?> eventType,
+ SerializableEventListener listener, String methodName) {
+ Objects.requireNonNull(listener, "Listener must not be null.");
+ if (listenerList == null) {
+ listenerList = new LinkedHashSet<>();
+ }
+ ListenerMethod listenerMethod = new ListenerMethod(eventType, listener,
+ methodName);
+ listenerList.add(listenerMethod);
+ return () -> listenerList.remove(listenerMethod);
+ }
+
+ /*
* Removes all registered listeners matching the given parameters. Don't add
* a JavaDoc comment here, we use the default documentation from implemented
* interface.
*/
@Override
+ @Deprecated
public void removeListener(Class<?> eventType, Object target) {
if (listenerList != null) {
final Iterator<ListenerMethod> i = listenerList.iterator();
@@ -165,11 +278,23 @@ public class EventRouter implements MethodEventSource {
}
/*
+ * Removes all registered listeners matching the given parameters. Don't add
+ * a JavaDoc comment here, we use the default documentation from implemented
+ * interface.
+ */
+ @Override
+ public void removeListener(Class<?> eventType,
+ SerializableEventListener listener) {
+ removeListener(eventType, (Object) listener);
+ }
+
+ /*
* Removes the event listener methods matching the given given parameters.
* Don't add a JavaDoc comment here, we use the default documentation from
* implemented interface.
*/
@Override
+ @Deprecated
public void removeListener(Class<?> eventType, Object target,
Method method) {
if (listenerList != null) {
@@ -190,6 +315,7 @@ public class EventRouter implements MethodEventSource {
* implemented interface.
*/
@Override
+ @Deprecated
public void removeListener(Class<?> eventType, Object target,
String methodName) {
@@ -314,4 +440,8 @@ public class EventRouter implements MethodEventSource {
}
return listeners;
}
+
+ private static final Logger getLogger() {
+ return Logger.getLogger(EventRouter.class.getName());
+ }
}
diff --git a/server/src/main/java/com/vaadin/event/ListenerMethod.java b/server/src/main/java/com/vaadin/event/ListenerMethod.java
index 0648d2741f..e83efd4775 100644
--- a/server/src/main/java/com/vaadin/event/ListenerMethod.java
+++ b/server/src/main/java/com/vaadin/event/ListenerMethod.java
@@ -171,9 +171,9 @@ public class ListenerMethod implements EventListener, Serializable {
* will not be passed to the trigger method, though it is still
* called.
* @throws IllegalArgumentException
- * if <code>method</code> is not a member of <code>target</code>
- * .
+ * if <code>method</code> is not a member of <code>target</code>.
*/
+ @Deprecated
public ListenerMethod(Class<?> eventType, Object target, Method method,
Object[] arguments, int eventArgumentIndex)
throws IllegalArgumentException {
@@ -209,6 +209,45 @@ public class ListenerMethod implements EventListener, Serializable {
/**
* <p>
+ * Constructs a new event listener from a trigger method, it's arguments and
+ * the argument index specifying which one is replaced with the event object
+ * when the trigger method is called.
+ * </p>
+ *
+ * <p>
+ * This constructor gets the trigger method as a parameter so it does not
+ * need to reflect to find it out.
+ * </p>
+ *
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param listener
+ * the listener instance that contains the trigger method
+ * @param method
+ * the trigger method
+ * @param arguments
+ * the arguments to be passed to the trigger method
+ * @param eventArgumentIndex
+ * An index to the argument list. This index points out the
+ * argument that is replaced with the event object before the
+ * argument set is passed to the trigger method. If the
+ * eventArgumentIndex is negative, the triggering event object
+ * will not be passed to the trigger method, though it is still
+ * called.
+ * @throws IllegalArgumentException
+ * if <code>method</code> is not a member of <code>target</code>.
+ */
+ public ListenerMethod(Class<?> eventType,
+ SerializableEventListener listener, Method method,
+ Object[] arguments, int eventArgumentIndex)
+ throws IllegalArgumentException {
+ this(eventType, (Object) listener, method, arguments,
+ eventArgumentIndex);
+ }
+
+ /**
+ * <p>
* Constructs a new event listener from a trigger method name, it's
* arguments and the argument index specifying which one is replaced with
* the event object. The actual trigger method is reflected from
@@ -238,6 +277,7 @@ public class ListenerMethod implements EventListener, Serializable {
* unless exactly one match <code>methodName</code> is found in
* <code>target</code>.
*/
+ @Deprecated
public ListenerMethod(Class<?> eventType, Object target, String methodName,
Object[] arguments, int eventArgumentIndex)
throws IllegalArgumentException {
@@ -277,6 +317,45 @@ public class ListenerMethod implements EventListener, Serializable {
/**
* <p>
+ * Constructs a new event listener from a trigger method name, it's
+ * arguments and the argument index specifying which one is replaced with
+ * the event object. The actual trigger method is reflected from
+ * <code>object</code>, and <code>java.lang.IllegalArgumentException</code>
+ * is thrown unless exactly one match is found.
+ * </p>
+ *
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param listener
+ * the listener instance that contains the trigger method.
+ * @param methodName
+ * the name of the trigger method. If the object does not contain
+ * the method or it contains more than one matching methods
+ * <code>java.lang.IllegalArgumentException</code> is thrown.
+ * @param arguments
+ * the arguments to be passed to the trigger method.
+ * @param eventArgumentIndex
+ * An index to the argument list. This index points out the
+ * argument that is replaced with the event object before the
+ * argument set is passed to the trigger method. If the
+ * eventArgumentIndex is negative, the triggering event object
+ * will not be passed to the trigger method, though it is still
+ * called.
+ * @throws IllegalArgumentException
+ * unless exactly one match <code>methodName</code> is found in
+ * <code>target</code>.
+ */
+ public ListenerMethod(Class<?> eventType,
+ SerializableEventListener listener, String methodName,
+ Object[] arguments, int eventArgumentIndex)
+ throws IllegalArgumentException {
+ this(eventType, (Object) listener, methodName, arguments,
+ eventArgumentIndex);
+ }
+
+ /**
+ * <p>
* Constructs a new event listener from the trigger method and it's
* arguments. Since the the index to the replaced parameter is not specified
* the event triggering this listener will not be passed to the trigger
@@ -298,9 +377,9 @@ public class ListenerMethod implements EventListener, Serializable {
* @param arguments
* the arguments to be passed to the trigger method.
* @throws IllegalArgumentException
- * if <code>method</code> is not a member of <code>target</code>
- * .
+ * if <code>method</code> is not a member of <code>target</code>.
*/
+ @Deprecated
public ListenerMethod(Class<?> eventType, Object target, Method method,
Object[] arguments) throws IllegalArgumentException {
@@ -320,6 +399,37 @@ public class ListenerMethod implements EventListener, Serializable {
/**
* <p>
+ * Constructs a new event listener from the trigger method and it's
+ * arguments. Since the the index to the replaced parameter is not specified
+ * the event triggering this listener will not be passed to the trigger
+ * method.
+ * </p>
+ *
+ * <p>
+ * This constructor gets the trigger method as a parameter so it does not
+ * need to reflect to find it out.
+ * </p>
+ *
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param listener
+ * the listener instance that contains the trigger method.
+ * @param method
+ * the trigger method.
+ * @param arguments
+ * the arguments to be passed to the trigger method.
+ * @throws IllegalArgumentException
+ * if <code>method</code> is not a member of <code>target</code>.
+ */
+ public ListenerMethod(Class<?> eventType,
+ SerializableEventListener listener, Method method,
+ Object[] arguments) throws IllegalArgumentException {
+ this(eventType, (Object) listener, method, arguments);
+ }
+
+ /**
+ * <p>
* Constructs a new event listener from a trigger method name and it's
* arguments. Since the the index to the replaced parameter is not specified
* the event triggering this listener will not be passed to the trigger
@@ -347,6 +457,7 @@ public class ListenerMethod implements EventListener, Serializable {
* unless exactly one match <code>methodName</code> is found in
* <code>object</code>.
*/
+ @Deprecated
public ListenerMethod(Class<?> eventType, Object target, String methodName,
Object[] arguments) throws IllegalArgumentException {
@@ -370,6 +481,41 @@ public class ListenerMethod implements EventListener, Serializable {
/**
* <p>
+ * Constructs a new event listener from a trigger method name and it's
+ * arguments. Since the the index to the replaced parameter is not specified
+ * the event triggering this listener will not be passed to the trigger
+ * method.
+ * </p>
+ *
+ * <p>
+ * The actual trigger method is reflected from <code>listener</code>, and
+ * <code>java.lang.IllegalArgumentException</code> is thrown unless exactly
+ * one match is found.
+ * </p>
+ *
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param listener
+ * the listener instance that contains the trigger method.
+ * @param methodName
+ * the name of the trigger method. If the object does not contain
+ * the method or it contains more than one matching methods
+ * <code>java.lang.IllegalArgumentException</code> is thrown.
+ * @param arguments
+ * the arguments to be passed to the trigger method.
+ * @throws IllegalArgumentException
+ * unless exactly one match <code>methodName</code> is found in
+ * <code>object</code>.
+ */
+ public ListenerMethod(Class<?> eventType,
+ SerializableEventListener listener, String methodName,
+ Object[] arguments) throws IllegalArgumentException {
+ this(eventType, (Object) listener, methodName, arguments);
+ }
+
+ /**
+ * <p>
* Constructs a new event listener from a trigger method. Since the argument
* list is unspecified no parameters are passed to the trigger method when
* the listener is triggered.
@@ -388,9 +534,9 @@ public class ListenerMethod implements EventListener, Serializable {
* @param method
* the trigger method.
* @throws IllegalArgumentException
- * if <code>method</code> is not a member of <code>object</code>
- * .
+ * if <code>method</code> is not a member of <code>object</code>.
*/
+ @Deprecated
public ListenerMethod(Class<?> eventType, Object target, Method method)
throws IllegalArgumentException {
@@ -422,6 +568,34 @@ public class ListenerMethod implements EventListener, Serializable {
/**
* <p>
+ * Constructs a new event listener from a trigger method. Since the argument
+ * list is unspecified no parameters are passed to the trigger method when
+ * the listener is triggered.
+ * </p>
+ *
+ * <p>
+ * This constructor gets the trigger method as a parameter so it does not
+ * need to reflect to find it out.
+ * </p>
+ *
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param listener
+ * the listener instance that contains the trigger method.
+ * @param method
+ * the trigger method.
+ * @throws IllegalArgumentException
+ * if <code>method</code> is not a member of <code>object</code>.
+ */
+ public ListenerMethod(Class<?> eventType,
+ SerializableEventListener listener, Method method)
+ throws IllegalArgumentException {
+ this(eventType, (Object) listener, method);
+ }
+
+ /**
+ * <p>
* Constructs a new event listener from a trigger method name. Since the
* argument list is unspecified no parameters are passed to the trigger
* method when the listener is triggered.
@@ -446,6 +620,7 @@ public class ListenerMethod implements EventListener, Serializable {
* unless exactly one match <code>methodName</code> is found in
* <code>target</code>.
*/
+ @Deprecated
public ListenerMethod(Class<?> eventType, Object target, String methodName)
throws IllegalArgumentException {
@@ -480,6 +655,38 @@ public class ListenerMethod implements EventListener, Serializable {
}
/**
+ * <p>
+ * Constructs a new event listener from a trigger method name. Since the
+ * argument list is unspecified no parameters are passed to the trigger
+ * method when the listener is triggered.
+ * </p>
+ *
+ * <p>
+ * The actual trigger method is reflected from <code>listener</code>, and
+ * <code>java.lang.IllegalArgumentException</code> is thrown unless exactly
+ * one match is found.
+ * </p>
+ *
+ * @param eventType
+ * the event type that is listener listens to. All events of this
+ * kind (or its subclasses) result in calling the trigger method.
+ * @param listener
+ * the listener instance that contains the trigger method.
+ * @param methodName
+ * the name of the trigger method. If the object does not contain
+ * the method or it contains more than one matching methods
+ * <code>java.lang.IllegalArgumentException</code> is thrown.
+ * @throws IllegalArgumentException
+ * unless exactly one match <code>methodName</code> is found in
+ * <code>target</code>.
+ */
+ public ListenerMethod(Class<?> eventType,
+ SerializableEventListener listener, String methodName)
+ throws IllegalArgumentException {
+ this(eventType, (Object) listener, methodName);
+ }
+
+ /**
* Receives one event from the <code>EventRouter</code> and calls the
* trigger method if it matches with the criteria defined for the listener.
* Only the events of the same or subclass of the specified event class
@@ -555,7 +762,7 @@ public class ListenerMethod implements EventListener, Serializable {
* @return <code>true</code> if <code>target</code> is the same object as
* the one stored in this object, <code>eventType</code> equals with
* the event type stored in this object and <code>method</code>
- * equals with the method stored in this object
+ * equals with the method stored in this object.
*/
public boolean matches(Class<?> eventType, Object target, Method method) {
return (this.target == target) && (eventType.equals(this.eventType)
diff --git a/server/src/main/java/com/vaadin/event/MethodEventSource.java b/server/src/main/java/com/vaadin/event/MethodEventSource.java
index 33e61b842e..a4dfa89332 100644
--- a/server/src/main/java/com/vaadin/event/MethodEventSource.java
+++ b/server/src/main/java/com/vaadin/event/MethodEventSource.java
@@ -62,10 +62,40 @@ public interface MethodEventSource extends Serializable {
* if {@code object} is {@code null}
* @since 8.0
*/
+ @Deprecated
public Registration addListener(Class<?> eventType, Object object,
Method method);
/**
+ * Registers a new event listener with the specified activation method to
+ * listen events generated by this component. If the activation method does
+ * not have any arguments the event object will not be passed to it when
+ * it's called.
+ *
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.vaadin.event com.vaadin.event package documentation}.
+ * </p>
+ *
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param listener
+ * the listener instance who owns the activation method.
+ * @param method
+ * the activation method.
+ * @return a registration object for removing the listener
+ * @throws IllegalArgumentException
+ * unless <code>method</code> has exactly one match in
+ * <code>object</code>
+ * @throws NullPointerException
+ * if {@code object} is {@code null}
+ * @since 8.12
+ */
+ public Registration addListener(Class<?> eventType,
+ SerializableEventListener listener, Method method);
+
+ /**
* Registers a new listener with the specified activation method to listen
* events generated by this component. If the activation method does not
* have any arguments the event object will not be passed to it when it's
@@ -98,10 +128,47 @@ public interface MethodEventSource extends Serializable {
* if {@code object} is {@code null}
* @since 8.0
*/
+ @Deprecated
public Registration addListener(Class<?> eventType, Object object,
String methodName);
/**
+ * Registers a new listener with the specified activation method to listen
+ * events generated by this component. If the activation method does not
+ * have any arguments the event object will not be passed to it when it's
+ * called.
+ *
+ * <p>
+ * This version of <code>addListener</code> gets the name of the activation
+ * method as a parameter. The actual method is reflected from
+ * <code>listener</code>, and unless exactly one match is found,
+ * <code>java.lang.IllegalArgumentException</code> is thrown.
+ * </p>
+ *
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.vaadin.event com.vaadin.event package documentation}.
+ * </p>
+ *
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param listener
+ * the listener instance who owns the activation method.
+ * @param methodName
+ * the name of the activation method.
+ * @return a registration object for removing the listener
+ * @throws IllegalArgumentException
+ * unless <code>method</code> has exactly one match in
+ * <code>object</code>
+ * @throws NullPointerException
+ * if {@code object} is {@code null}
+ * @since 8.12
+ */
+ public Registration addListener(Class<?> eventType,
+ SerializableEventListener object, String methodName);
+
+ /**
* Removes all registered listeners matching the given parameters. Since
* this method receives the event type and the listener object as
* parameters, it will unregister all <code>object</code>'s methods that are
@@ -119,9 +186,32 @@ public interface MethodEventSource extends Serializable {
* the target object that has registered to listen to events of
* type <code>eventType</code> with one or more methods.
*/
+ @Deprecated
public void removeListener(Class<?> eventType, Object target);
/**
+ * Removes all registered listeners matching the given parameters. Since
+ * this method receives the event type and the listener object as
+ * parameters, it will unregister all <code>object</code>'s methods that are
+ * registered to listen to events of type <code>eventType</code> generated
+ * by this component.
+ *
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.vaadin.event com.vaadin.event package documentation}.
+ * </p>
+ *
+ * @param eventType
+ * the exact event type the <code>object</code> listens to.
+ * @param listener
+ * the listener that has registered to listen to events of type
+ * <code>eventType</code> with one or more methods.
+ * @since 8.12
+ */
+ public void removeListener(Class<?> eventType,
+ SerializableEventListener listener);
+
+ /**
* Removes one registered listener method. The given method owned by the
* given object will no longer be called when the specified events are
* generated by this component.
diff --git a/server/src/main/java/com/vaadin/event/SortEvent.java b/server/src/main/java/com/vaadin/event/SortEvent.java
index dc3211bda7..ace8683959 100644
--- a/server/src/main/java/com/vaadin/event/SortEvent.java
+++ b/server/src/main/java/com/vaadin/event/SortEvent.java
@@ -80,7 +80,7 @@ public class SortEvent<T extends SortOrder<?>> extends Component.Event
* the type of the sorting information
*/
@FunctionalInterface
- public interface SortListener<T extends SortOrder<?>> extends Serializable {
+ public interface SortListener<T extends SortOrder<?>> extends SerializableEventListener {
/**
* Called when the sort order has changed.
*
diff --git a/server/src/main/java/com/vaadin/event/UIEvents.java b/server/src/main/java/com/vaadin/event/UIEvents.java
index db282917d8..5f754c8518 100644
--- a/server/src/main/java/com/vaadin/event/UIEvents.java
+++ b/server/src/main/java/com/vaadin/event/UIEvents.java
@@ -40,7 +40,7 @@ public interface UIEvents {
* @author Vaadin Ltd
*/
@FunctionalInterface
- public interface PollListener extends Serializable {
+ public interface PollListener extends SerializableEventListener {
public static final Method POLL_METHOD = ReflectTools
.findMethod(PollListener.class, "poll", PollEvent.class);
diff --git a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
index 912aa5b10b..fe16736465 100644
--- a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
+++ b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java
@@ -34,6 +34,7 @@ import java.util.WeakHashMap;
import com.vaadin.event.EventRouter;
import com.vaadin.event.MethodEventSource;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.shared.Registration;
import com.vaadin.shared.communication.ClientRpc;
import com.vaadin.shared.communication.ServerRpc;
@@ -720,8 +721,6 @@ public abstract class AbstractClientConnector
}
}
- /* Listener code starts. Should be refactored. */
-
/**
* Registers a new listener with the specified activation method to listen
* events generated by this component. If the activation method does not
@@ -737,6 +736,10 @@ public abstract class AbstractClientConnector
* For more information on the inheritable event mechanism see the
* {@link com.vaadin.event com.vaadin.event package documentation}.
* </p>
+ *
+ * @deprecated As of 8.12. Use strongly typed
+ * {@link #addListener(String, Class, SerializableEventListener, Method)}
+ * method instead.
*
* @param eventIdentifier
* the identifier of the event to listen for
@@ -750,6 +753,7 @@ public abstract class AbstractClientConnector
* @return a registration object for removing the listener
* @since 8.0
*/
+ @Deprecated
protected Registration addListener(String eventIdentifier,
Class<?> eventType, Object target, Method method) {
if (eventRouter == null) {
@@ -760,6 +764,44 @@ public abstract class AbstractClientConnector
}
/**
+ * Registers a new listener with the specified activation method to listen
+ * events generated by this component. If the activation method does not
+ * have any arguments the event object will not be passed to it when it's
+ * called.
+ *
+ * <p>
+ * This method additionally informs the event-api to route events with the
+ * given eventIdentifier to the components handleEvent function call.
+ * </p>
+ *
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.vaadin.event com.vaadin.event package documentation}.
+ * </p>
+ *
+ * @param eventIdentifier
+ * the identifier of the event to listen for
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param listener
+ * the listener instance who owns the activation method.
+ * @param method
+ * the activation method.
+ * @return a registration object for removing the listener
+ * @since 8.12
+ */
+ protected Registration addListener(String eventIdentifier,
+ Class<?> eventType, SerializableEventListener listener,
+ Method method) {
+ if (eventRouter == null) {
+ eventRouter = new EventRouter();
+ }
+ return eventRouter.addListener(eventType, listener, method,
+ eventIdentifier, getState());
+ }
+
+ /**
* Checks if the given {@link Event} type is listened for this component.
*
* @param eventType
@@ -823,6 +865,10 @@ public abstract class AbstractClientConnector
* For more information on the inheritable event mechanism see the
* {@link com.vaadin.event com.vaadin.event package documentation}.
* </p>
+ *
+ * @deprecated As of 8.12. Use strongly typed
+ * {@link #addListener(Class, SerializableEventListener, Method)}
+ * method instead.
*
* @param eventType
* the type of the listened event. Events of this type or its
@@ -834,6 +880,7 @@ public abstract class AbstractClientConnector
* @return a registration object for removing the listener
*/
@Override
+ @Deprecated
public Registration addListener(Class<?> eventType, Object target,
Method method) {
if (eventRouter == null) {
@@ -843,6 +890,37 @@ public abstract class AbstractClientConnector
}
/**
+ * Registers a new listener with the specified activation method to listen
+ * events generated by this component. If the activation method does not
+ * have any arguments the event object will not be passed to it when it's
+ * called.
+ *
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.vaadin.event com.vaadin.event package documentation}.
+ * </p>
+ *
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param listener
+ * the listener instance who owns the activation method.
+ * @param method
+ * the activation method.
+ * @return a registration object for removing the listener
+ * @since 8.12
+ */
+
+ @Override
+ public Registration addListener(Class<?> eventType,
+ SerializableEventListener listener, Method method) {
+ if (eventRouter == null) {
+ eventRouter = new EventRouter();
+ }
+ return eventRouter.addListener(eventType, listener, method);
+ }
+
+ /**
* Convenience method for registering a new listener with the specified
* activation method to listen events generated by this component. If the
* activation method does not have any arguments the event object will not
@@ -874,8 +952,10 @@ public abstract class AbstractClientConnector
* the name of the activation method.
* @return a registration object for removing the listener
* @deprecated As of 7.0. This method should be avoided. Use
- * {@link #addListener(Class, Object, Method)} or
- * {@link #addListener(String, Class, Object, Method)} instead.
+ * {@link #addListener(Class, SerializableEventListener, Method)}
+ * or
+ * {@link #addListener(String, Class, SerializableEventListener, Method)}
+ * instead.
* @since 8.0
*/
@Override
@@ -889,6 +969,56 @@ public abstract class AbstractClientConnector
}
/**
+ * Convenience method for registering a new listener with the specified
+ * activation method to listen events generated by this component. If the
+ * activation method does not have any arguments the event object will not
+ * be passed to it when it's called.
+ *
+ * <p>
+ * This version of <code>addListener</code> gets the name of the activation
+ * method as a parameter. The actual method is reflected from
+ * <code>object</code>, and unless exactly one match is found,
+ * <code>java.lang.IllegalArgumentException</code> is thrown.
+ * </p>
+ *
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.vaadin.event com.vaadin.event package documentation}.
+ * </p>
+ *
+ * <p>
+ * Note: Using this method is discouraged because it cannot be checked
+ * during compilation. Use {@link #addListener(Class, Object, Method)} or
+ * {@link #addListener(String, Class, Object, Method) instead. </p>
+ *
+ * @param eventType
+ * the type of the listened event. Events of this type or its
+ * subclasses activate the listener.
+ * @param listener
+ * the object instance who owns the activation method.
+ * @param methodName
+ * the name of the activation method.
+ * @return a registration object for removing the listener
+ * @deprecated This method has only been added for ease of migration and
+ * should be avoided in new code.
+ * Use
+ * {@link #addListener(Class, SerializableEventListener, Method)}
+ * or
+ * {@link #addListener(String, Class, SerializableEventListener, Method)}
+ * instead.
+ * @since 8.12
+ */
+ @Override
+ @Deprecated
+ public Registration addListener(Class<?> eventType,
+ SerializableEventListener listener, String methodName) {
+ if (eventRouter == null) {
+ eventRouter = new EventRouter();
+ }
+ return eventRouter.addListener(eventType, listener, methodName);
+ }
+
+ /**
* Removes all registered listeners matching the given parameters. Since
* this method receives the event type and the listener object as
* parameters, it will unregister all <code>object</code>'s methods that are
@@ -917,6 +1047,36 @@ public abstract class AbstractClientConnector
}
/**
+ * Removes all registered listeners matching the given parameters. Since
+ * this method receives the event type and the listener object as
+ * parameters, it will unregister all <code>object</code>'s methods that are
+ * registered to listen to events of type <code>eventType</code> generated
+ * by this component.
+ *
+ * <p>
+ * For more information on the inheritable event mechanism see the
+ * {@link com.vaadin.event com.vaadin.event package documentation}.
+ * </p>
+ *
+ * @param eventType
+ * the exact event type the <code>object</code> listens to.
+ * @param listener
+ * the listener that has registered to listen to events of type
+ * <code>eventType</code> with one or more methods.
+ * @deprecated use a {@link Registration} from {@link #addListener} to
+ * remove a listener
+ * @since 8.12
+ */
+ @Deprecated
+ @Override
+ public void removeListener(Class<?> eventType,
+ SerializableEventListener listener) {
+ if (eventRouter != null) {
+ eventRouter.removeListener(eventType, listener);
+ }
+ }
+
+ /**
* Removes one registered listener method. The given method owned by the
* given object will no longer be called when the specified events are
* generated by this component.
diff --git a/server/src/main/java/com/vaadin/server/BootstrapListener.java b/server/src/main/java/com/vaadin/server/BootstrapListener.java
index f525c6aa4d..24b97f12a7 100644
--- a/server/src/main/java/com/vaadin/server/BootstrapListener.java
+++ b/server/src/main/java/com/vaadin/server/BootstrapListener.java
@@ -16,11 +16,10 @@
package com.vaadin.server;
-import java.io.Serializable;
-import java.util.EventListener;
-
import javax.portlet.RenderResponse;
+import com.vaadin.event.SerializableEventListener;
+
/**
* Event listener notified when the bootstrap HTML is about to be generated and
* send to the client. The bootstrap HTML is first constructed as an in-memory
@@ -30,7 +29,7 @@ import javax.portlet.RenderResponse;
* @author Vaadin Ltd
* @since 7.0.0
*/
-public interface BootstrapListener extends EventListener, Serializable {
+public interface BootstrapListener extends SerializableEventListener {
/**
* Lets this listener make changes to the fragment that makes up the actual
* Vaadin application. In a typical Servlet deployment, this is the contents
diff --git a/server/src/main/java/com/vaadin/server/Page.java b/server/src/main/java/com/vaadin/server/Page.java
index 925df59121..0708a23000 100644
--- a/server/src/main/java/com/vaadin/server/Page.java
+++ b/server/src/main/java/com/vaadin/server/Page.java
@@ -30,6 +30,7 @@ import java.util.List;
import com.vaadin.annotations.HtmlImport;
import com.vaadin.annotations.StyleSheet;
import com.vaadin.event.EventRouter;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.BorderStyle;
import com.vaadin.shared.ui.ui.PageClientRpc;
@@ -54,7 +55,7 @@ public class Page implements Serializable {
* @see #addBrowserWindowResizeListener(BrowserWindowResizeListener)
*/
@FunctionalInterface
- public interface BrowserWindowResizeListener extends Serializable {
+ public interface BrowserWindowResizeListener extends SerializableEventListener {
/**
* Invoked when the browser window containing a UI has been resized.
*
@@ -259,7 +260,7 @@ public class Page implements Serializable {
*/
@Deprecated
@FunctionalInterface
- public interface UriFragmentChangedListener extends Serializable {
+ public interface UriFragmentChangedListener extends SerializableEventListener {
/**
* Event handler method invoked when the URI fragment of the page
* changes. Please note that the initial URI fragment has already been
@@ -286,7 +287,7 @@ public class Page implements Serializable {
* @since 8.0
*/
@FunctionalInterface
- public interface PopStateListener extends Serializable {
+ public interface PopStateListener extends SerializableEventListener {
/**
* Event handler method invoked when the URI fragment of the page
* changes. Please note that the initial URI fragment has already been
@@ -566,18 +567,18 @@ public class Page implements Serializable {
this.state = state;
}
- private Registration addListener(Class<?> eventType, Object target,
+ private Registration addListener(Class<?> eventType, SerializableEventListener listener,
Method method) {
if (!hasEventRouter()) {
eventRouter = new EventRouter();
}
- return eventRouter.addListener(eventType, target, method);
+ return eventRouter.addListener(eventType, listener, method);
}
- private void removeListener(Class<?> eventType, Object target,
+ private void removeListener(Class<?> eventType, SerializableEventListener listener,
Method method) {
if (hasEventRouter()) {
- eventRouter.removeListener(eventType, target, method);
+ eventRouter.removeListener(eventType, listener, method);
}
}
diff --git a/server/src/main/java/com/vaadin/ui/Button.java b/server/src/main/java/com/vaadin/ui/Button.java
index 8e98d73f3b..3308cba1b4 100644
--- a/server/src/main/java/com/vaadin/ui/Button.java
+++ b/server/src/main/java/com/vaadin/ui/Button.java
@@ -16,7 +16,6 @@
package com.vaadin.ui;
-import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collection;
@@ -24,6 +23,7 @@ import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
import com.vaadin.event.Action;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.event.ShortcutAction;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.event.ShortcutAction.ModifierKey;
@@ -303,7 +303,7 @@ public class Button extends AbstractFocusable
* @since 3.0
*/
@FunctionalInterface
- public interface ClickListener extends Serializable {
+ public interface ClickListener extends SerializableEventListener {
public static final Method BUTTON_CLICK_METHOD = ReflectTools
.findMethod(ClickListener.class, "buttonClick",
diff --git a/server/src/main/java/com/vaadin/ui/HasComponents.java b/server/src/main/java/com/vaadin/ui/HasComponents.java
index d4a4375dd9..6987a3e7a6 100644
--- a/server/src/main/java/com/vaadin/ui/HasComponents.java
+++ b/server/src/main/java/com/vaadin/ui/HasComponents.java
@@ -19,6 +19,7 @@ import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Iterator;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.shared.Registration;
import com.vaadin.util.ReflectTools;
@@ -98,7 +99,7 @@ public interface HasComponents extends Component, Iterable<Component> {
* Component attach listener interface.
*/
@FunctionalInterface
- public interface ComponentAttachListener extends Serializable {
+ public interface ComponentAttachListener extends SerializableEventListener {
public static final Method attachMethod = ReflectTools.findMethod(
ComponentAttachListener.class, "componentAttachedToContainer",
@@ -117,7 +118,7 @@ public interface HasComponents extends Component, Iterable<Component> {
* Component detach listener interface.
*/
@FunctionalInterface
- public interface ComponentDetachListener extends Serializable {
+ public interface ComponentDetachListener extends SerializableEventListener {
public static final Method detachMethod = ReflectTools.findMethod(
ComponentDetachListener.class, "componentDetachedFromContainer",
diff --git a/server/src/main/java/com/vaadin/ui/LoginForm.java b/server/src/main/java/com/vaadin/ui/LoginForm.java
index 2bb9fade65..a914461ad9 100644
--- a/server/src/main/java/com/vaadin/ui/LoginForm.java
+++ b/server/src/main/java/com/vaadin/ui/LoginForm.java
@@ -18,12 +18,12 @@ package com.vaadin.ui;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import java.io.Serializable;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.server.StreamResource;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.Registration;
@@ -95,7 +95,7 @@ public class LoginForm extends AbstractSingleComponentContainer {
* Listener triggered when a login occurs in a {@link LoginForm}.
*/
@FunctionalInterface
- public interface LoginListener extends Serializable {
+ public interface LoginListener extends SerializableEventListener {
/**
* Event method invoked when the login button is pressed in a login
* form.
diff --git a/server/src/main/java/com/vaadin/ui/Notification.java b/server/src/main/java/com/vaadin/ui/Notification.java
index 2204ea0b60..7832953c52 100644
--- a/server/src/main/java/com/vaadin/ui/Notification.java
+++ b/server/src/main/java/com/vaadin/ui/Notification.java
@@ -16,11 +16,11 @@
package com.vaadin.ui;
-import java.io.Serializable;
import java.lang.reflect.Method;
import com.vaadin.event.ConnectorEvent;
import com.vaadin.event.HasUserOriginated;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.server.AbstractExtension;
import com.vaadin.server.Page;
import com.vaadin.server.Resource;
@@ -572,7 +572,7 @@ public class Notification extends AbstractExtension {
* @since 8.2
*/
@FunctionalInterface
- public interface CloseListener extends Serializable {
+ public interface CloseListener extends SerializableEventListener {
/**
* Use {@link CloseEvent#getNotification()} to get a reference to the
* {@link Notification} that was closed.
diff --git a/server/src/main/java/com/vaadin/ui/PopupView.java b/server/src/main/java/com/vaadin/ui/PopupView.java
index dabcab7803..72a5cd07c4 100644
--- a/server/src/main/java/com/vaadin/ui/PopupView.java
+++ b/server/src/main/java/com/vaadin/ui/PopupView.java
@@ -24,6 +24,7 @@ import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.parser.Tag;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.popupview.PopupViewServerRpc;
import com.vaadin.shared.ui.popupview.PopupViewState;
@@ -400,7 +401,7 @@ public class PopupView extends AbstractComponent implements HasComponents {
*
*/
@FunctionalInterface
- public interface PopupVisibilityListener extends Serializable {
+ public interface PopupVisibilityListener extends SerializableEventListener {
/**
* Pass to {@link PopupView.PopupVisibilityEvent} to start listening for
* popup visibility changes.
diff --git a/server/src/main/java/com/vaadin/ui/TabSheet.java b/server/src/main/java/com/vaadin/ui/TabSheet.java
index 75b08bf5dc..e2ef441c71 100644
--- a/server/src/main/java/com/vaadin/ui/TabSheet.java
+++ b/server/src/main/java/com/vaadin/ui/TabSheet.java
@@ -24,7 +24,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Objects;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
@@ -37,6 +36,7 @@ import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.event.FieldEvents.FocusNotifier;
import com.vaadin.event.HasUserOriginated;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.server.ErrorMessage;
import com.vaadin.server.KeyMapper;
import com.vaadin.server.Resource;
@@ -851,7 +851,7 @@ public class TabSheet extends AbstractComponentContainer
* @since 3.0
*/
@FunctionalInterface
- public interface SelectedTabChangeListener extends Serializable {
+ public interface SelectedTabChangeListener extends SerializableEventListener {
/**
* Selected (shown) tab in tab sheet has has been changed.
diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java
index c47e5f1451..ca391a69c3 100644
--- a/server/src/main/java/com/vaadin/ui/Upload.java
+++ b/server/src/main/java/com/vaadin/ui/Upload.java
@@ -23,6 +23,7 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Objects;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.server.NoInputStreamException;
import com.vaadin.server.NoOutputStreamException;
import com.vaadin.server.PaintException;
@@ -535,7 +536,7 @@ public class Upload extends AbstractComponent
* @since 5.0
*/
@FunctionalInterface
- public interface StartedListener extends Serializable {
+ public interface StartedListener extends SerializableEventListener {
/**
* Upload has started.
@@ -553,7 +554,7 @@ public class Upload extends AbstractComponent
* @since 3.0
*/
@FunctionalInterface
- public interface FinishedListener extends Serializable {
+ public interface FinishedListener extends SerializableEventListener {
/**
* Upload has finished.
@@ -571,7 +572,7 @@ public class Upload extends AbstractComponent
* @since 3.0
*/
@FunctionalInterface
- public interface FailedListener extends Serializable {
+ public interface FailedListener extends SerializableEventListener {
/**
* Upload has finished unsuccessfully.
@@ -589,7 +590,7 @@ public class Upload extends AbstractComponent
* @since 3.0
*/
@FunctionalInterface
- public interface SucceededListener extends Serializable {
+ public interface SucceededListener extends SerializableEventListener {
/**
* Upload successful.
@@ -606,7 +607,7 @@ public class Upload extends AbstractComponent
* @since 7.2
*/
@FunctionalInterface
- public interface ChangeListener extends Serializable {
+ public interface ChangeListener extends SerializableEventListener {
Method FILENAME_CHANGED = ReflectTools.findMethod(ChangeListener.class,
"filenameChanged", ChangeEvent.class);
diff --git a/server/src/main/java/com/vaadin/ui/Window.java b/server/src/main/java/com/vaadin/ui/Window.java
index f53659bdd3..edfc85a4a4 100644
--- a/server/src/main/java/com/vaadin/ui/Window.java
+++ b/server/src/main/java/com/vaadin/ui/Window.java
@@ -16,7 +16,6 @@
package com.vaadin.ui;
-import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
@@ -36,6 +35,7 @@ import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.event.FieldEvents.FocusNotifier;
import com.vaadin.event.MouseEvents.ClickEvent;
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.event.ShortcutAction;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.event.ShortcutAction.ModifierKey;
@@ -496,7 +496,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
* </p>
*/
@FunctionalInterface
- public interface CloseListener extends Serializable {
+ public interface CloseListener extends SerializableEventListener {
/**
* Called when the user closes a window. Use
* {@link CloseEvent#getWindow()} to get a reference to the
@@ -599,7 +599,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
* {@link WindowMode#MAXIMIZED}) or restored ({@link WindowMode#NORMAL} ).
*/
@FunctionalInterface
- public interface WindowModeChangeListener extends Serializable {
+ public interface WindowModeChangeListener extends SerializableEventListener {
public static final Method windowModeChangeMethod = ReflectTools
.findMethod(WindowModeChangeListener.class, "windowModeChanged",
@@ -699,7 +699,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier {
* @see com.vaadin.ui.Window.ResizeEvent
*/
@FunctionalInterface
- public interface ResizeListener extends Serializable {
+ public interface ResizeListener extends SerializableEventListener {
public void windowResized(ResizeEvent e);
}
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/ColumnReorderListener.java b/server/src/main/java/com/vaadin/ui/components/grid/ColumnReorderListener.java
index e121505984..e0ee1b8826 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/ColumnReorderListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/ColumnReorderListener.java
@@ -15,8 +15,7 @@
*/
package com.vaadin.ui.components.grid;
-import java.io.Serializable;
-
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.ui.Grid;
/**
@@ -26,7 +25,7 @@ import com.vaadin.ui.Grid;
* @since 8.0
*/
@FunctionalInterface
-public interface ColumnReorderListener extends Serializable {
+public interface ColumnReorderListener extends SerializableEventListener {
/**
* Called when the columns of the grid have been reordered.
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/ColumnResizeListener.java b/server/src/main/java/com/vaadin/ui/components/grid/ColumnResizeListener.java
index fa73eb27d9..c05c5dcc2a 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/ColumnResizeListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/ColumnResizeListener.java
@@ -15,8 +15,7 @@
*/
package com.vaadin.ui.components.grid;
-import java.io.Serializable;
-
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.ui.Grid;
/**
@@ -26,7 +25,7 @@ import com.vaadin.ui.Grid;
* @since 8.0
*/
@FunctionalInterface
-public interface ColumnResizeListener extends Serializable {
+public interface ColumnResizeListener extends SerializableEventListener {
/**
* Called when the columns of the grid have been resized.
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/ColumnVisibilityChangeListener.java b/server/src/main/java/com/vaadin/ui/components/grid/ColumnVisibilityChangeListener.java
index fc7333b2ba..ba54cf76cf 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/ColumnVisibilityChangeListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/ColumnVisibilityChangeListener.java
@@ -15,8 +15,7 @@
*/
package com.vaadin.ui.components.grid;
-import java.io.Serializable;
-
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.ui.Grid;
/**
@@ -26,7 +25,7 @@ import com.vaadin.ui.Grid;
* @since 8.0
*/
@FunctionalInterface
-public interface ColumnVisibilityChangeListener extends Serializable {
+public interface ColumnVisibilityChangeListener extends SerializableEventListener {
/**
* Called when a column has become hidden or unhidden.
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorCancelListener.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorCancelListener.java
index d29a8d18a7..6588f52f5e 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/EditorCancelListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorCancelListener.java
@@ -15,8 +15,7 @@
*/
package com.vaadin.ui.components.grid;
-import java.io.Serializable;
-
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.ui.Grid;
/**
@@ -32,7 +31,7 @@ import com.vaadin.ui.Grid;
* the bean type
*/
@FunctionalInterface
-public interface EditorCancelListener<T> extends Serializable {
+public interface EditorCancelListener<T> extends SerializableEventListener {
/**
* Called when the editor is cancelled.
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorOpenListener.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorOpenListener.java
index cd9af878a3..ca888ca77b 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/EditorOpenListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorOpenListener.java
@@ -15,8 +15,7 @@
*/
package com.vaadin.ui.components.grid;
-import java.io.Serializable;
-
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.ui.Grid;
/**
@@ -32,7 +31,7 @@ import com.vaadin.ui.Grid;
* @see Editor#addOpenListener(EditorOpenListener)
*/
@FunctionalInterface
-public interface EditorOpenListener<T> extends Serializable {
+public interface EditorOpenListener<T> extends SerializableEventListener {
/**
* Called when the editor is opened.
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorSaveListener.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorSaveListener.java
index 3e22a11aa7..a267c01b71 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/EditorSaveListener.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorSaveListener.java
@@ -15,8 +15,7 @@
*/
package com.vaadin.ui.components.grid;
-import java.io.Serializable;
-
+import com.vaadin.event.SerializableEventListener;
import com.vaadin.ui.Grid;
/**
@@ -29,7 +28,7 @@ import com.vaadin.ui.Grid;
* @see Editor#addSaveListener(EditorSaveListener)
*/
@FunctionalInterface
-public interface EditorSaveListener<T> extends Serializable {
+public interface EditorSaveListener<T> extends SerializableEventListener {
/**
* Called when the editor is saved.