aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/ui/AbstractComponent.java
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-04-02 22:54:24 +0300
committerArtur Signell <artur@vaadin.com>2012-04-05 00:08:21 +0300
commit8079a7d0148a96d1048904c4b4eba25708a22a15 (patch)
treec9c99d33949e6bd59f2ba6ab1d8e789bf78ac54d /src/com/vaadin/ui/AbstractComponent.java
parent56c932f02679d525da5a1ec3de3669a0482456ad (diff)
downloadvaadin-framework-8079a7d0148a96d1048904c4b4eba25708a22a15.tar.gz
vaadin-framework-8079a7d0148a96d1048904c4b4eba25708a22a15.zip
Simplified Rpc registration on server side (#8591)
Diffstat (limited to 'src/com/vaadin/ui/AbstractComponent.java')
-rw-r--r--src/com/vaadin/ui/AbstractComponent.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/com/vaadin/ui/AbstractComponent.java b/src/com/vaadin/ui/AbstractComponent.java
index 7acdc296e4..189142519d 100644
--- a/src/com/vaadin/ui/AbstractComponent.java
+++ b/src/com/vaadin/ui/AbstractComponent.java
@@ -1615,13 +1615,33 @@ public abstract class AbstractComponent implements Component, MethodEventSource
* RPC interface class for which the implementation should be
* registered
*/
- protected <T> void registerRpcImplementation(T implementation,
- Class<T> rpcInterfaceType) {
+ protected <T> void registerRpc(T implementation, Class<T> rpcInterfaceType) {
rpcManagerMap.put(rpcInterfaceType, new ServerRpcManager<T>(this,
implementation, rpcInterfaceType));
}
/**
+ * Registers an RPC interface implementation for this component.
+ *
+ * A component can listen to multiple RPC interfaces, and subclasses can
+ * register additional implementations.
+ *
+ * @since 7.0
+ *
+ * @param implementation
+ * RPC interface implementation. Also used to deduce the type.
+ */
+ protected <T> void registerRpc(T implementation) {
+ Class<?>[] interfaces = implementation.getClass().getInterfaces();
+ if (interfaces.length != 1) {
+ throw new RuntimeException(
+ "Use registerRpc(T implementation, Class<T> rpcInterfaceType) if the Rpc implementation implements more than one interface");
+ }
+ Class<T> type = (Class<T>) interfaces[0];
+ registerRpc(implementation, type);
+ }
+
+ /**
* Returns an RPC proxy for a given server to client RPC interface for this
* component.
*