diff options
author | Artur Signell <artur@vaadin.com> | 2012-04-02 22:54:24 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-04-05 00:08:21 +0300 |
commit | 8079a7d0148a96d1048904c4b4eba25708a22a15 (patch) | |
tree | c9c99d33949e6bd59f2ba6ab1d8e789bf78ac54d /src/com/vaadin/ui/AbstractComponent.java | |
parent | 56c932f02679d525da5a1ec3de3669a0482456ad (diff) | |
download | vaadin-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.java | 24 |
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. * |