From d1c55ddd236de43ebe836c01b7d6c8b8943a79a8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 6 Nov 2012 17:51:39 +0200 Subject: [PATCH] Added AbstractConnector.getRpcProxy helper (#10143) Change-Id: I52ca9908763cc7416a2c50971252429cd8c294e8 --- .../vaadin/client/ui/AbstractConnector.java | 26 +++++++++++++++++++ .../AbsoluteLayoutConnector.java | 6 +---- .../client/ui/button/ButtonConnector.java | 13 +++------- .../client/ui/checkbox/CheckBoxConnector.java | 13 +++------- .../ui/csslayout/CssLayoutConnector.java | 6 +---- .../client/ui/embedded/EmbeddedConnector.java | 6 +---- .../ui/gridlayout/GridLayoutConnector.java | 5 +--- .../client/ui/image/ImageConnector.java | 6 +---- .../nativebutton/NativeButtonConnector.java | 11 +++----- .../AbstractOrderedLayoutConnector.java | 6 +---- .../client/ui/panel/PanelConnector.java | 6 +---- .../ProgressIndicatorConnector.java | 6 +---- .../AbstractSplitPanelConnector.java | 10 +++---- .../com/vaadin/client/ui/ui/UIConnector.java | 10 +++---- .../client/ui/window/WindowConnector.java | 6 +---- .../client/SerializerTestConnector.java | 4 +-- .../HelloWorldExtensionConnector.java | 4 +-- .../v7a3/RefresherConnector.java | 5 +--- .../v7b1/CapsLockWarningWithRpcConnector.java | 4 +-- 19 files changed, 58 insertions(+), 95 deletions(-) diff --git a/client/src/com/vaadin/client/ui/AbstractConnector.java b/client/src/com/vaadin/client/ui/AbstractConnector.java index d0bba797e2..aac9b76d59 100644 --- a/client/src/com/vaadin/client/ui/AbstractConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractConnector.java @@ -29,12 +29,14 @@ import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.VConsole; +import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Type; import com.vaadin.client.metadata.TypeData; import com.vaadin.shared.communication.ClientRpc; +import com.vaadin.shared.communication.ServerRpc; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.communication.URLReference; @@ -59,6 +61,12 @@ public abstract class AbstractConnector implements ServerConnector, private SharedState state; private ServerConnector parent; + /** + * A map from client-to-server RPC interface class to the RPC proxy that + * sends outgoing RPC calls for that interface. + */ + private Map, ServerRpc> rpcProxyMap = new HashMap, ServerRpc>(); + /** * Temporary storage for last enabled state to be able to see if it has * changed. Can be removed once we are able to listen specifically for @@ -159,6 +167,24 @@ public abstract class AbstractConnector implements ServerConnector, } } + /** + * Returns an RPC proxy object which can be used to invoke the RPC method on + * the server. + * + * @param + * The type of the ServerRpc interface + * @param rpcInterface + * The ServerRpc interface to retrieve a proxy object for + * @return A proxy object which can be used to invoke the RPC method on the + * server. + */ + public T getRpcProxy(Class rpcInterface) { + if (!rpcProxyMap.containsKey(rpcInterface)) { + rpcProxyMap.put(rpcInterface, RpcProxy.create(rpcInterface, this)); + } + return (T) rpcProxyMap.get(rpcInterface); + } + @Override public Collection getRpcImplementations( String rpcInterfaceId) { diff --git a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java index e4b2440ef7..106aee7ace 100644 --- a/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java @@ -23,7 +23,6 @@ import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.DirectionalManagedLayout; import com.vaadin.client.Util; import com.vaadin.client.VCaption; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.AbstractComponentContainerConnector; @@ -52,7 +51,7 @@ public class AbsoluteLayoutConnector extends @Override protected LayoutClickRpc getLayoutClickRPC() { - return rpc; + return getRpcProxy(AbsoluteLayoutServerRpc.class); }; }; @@ -72,8 +71,6 @@ public class AbsoluteLayoutConnector extends } }; - private AbsoluteLayoutServerRpc rpc; - /* * (non-Javadoc) * @@ -82,7 +79,6 @@ public class AbsoluteLayoutConnector extends @Override protected void init() { super.init(); - rpc = RpcProxy.create(AbsoluteLayoutServerRpc.class, this); } /** diff --git a/client/src/com/vaadin/client/ui/button/ButtonConnector.java b/client/src/com/vaadin/client/ui/button/ButtonConnector.java index c3aa66b285..bc1e7b0e69 100644 --- a/client/src/com/vaadin/client/ui/button/ButtonConnector.java +++ b/client/src/com/vaadin/client/ui/button/ButtonConnector.java @@ -28,7 +28,6 @@ import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.vaadin.client.EventHelper; import com.vaadin.client.MouseEventDetailsBuilder; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.AbstractComponentConnector; @@ -47,10 +46,6 @@ import com.vaadin.ui.Button; public class ButtonConnector extends AbstractComponentConnector implements BlurHandler, FocusHandler, ClickHandler, ShortcutActionTarget { - private ButtonServerRpc rpc = RpcProxy.create(ButtonServerRpc.class, this); - private FocusAndBlurServerRpc focusBlurProxy = RpcProxy.create( - FocusAndBlurServerRpc.class, this); - private HandlerRegistration focusHandlerRegistration = null; private HandlerRegistration blurHandlerRegistration = null; @@ -143,14 +138,14 @@ public class ButtonConnector extends AbstractComponentConnector implements public void onFocus(FocusEvent event) { // EventHelper.updateFocusHandler ensures that this is called only when // there is a listener on server side - focusBlurProxy.focus(); + getRpcProxy(FocusAndBlurServerRpc.class).focus(); } @Override public void onBlur(BlurEvent event) { // EventHelper.updateFocusHandler ensures that this is called only when // there is a listener on server side - focusBlurProxy.blur(); + getRpcProxy(FocusAndBlurServerRpc.class).blur(); } @Override @@ -163,14 +158,14 @@ public class ButtonConnector extends AbstractComponentConnector implements // generally supported. getState().enabled = false; super.updateEnabledState(false); - rpc.disableOnClick(); + getRpcProxy(ButtonServerRpc.class).disableOnClick(); } // Add mouse details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getNativeEvent(), getWidget() .getElement()); - rpc.click(details); + getRpcProxy(ButtonServerRpc.class).click(details); } diff --git a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java index 35816039da..cf771bed0d 100644 --- a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java +++ b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java @@ -27,7 +27,6 @@ import com.google.gwt.user.client.Event; import com.vaadin.client.EventHelper; import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.VTooltip; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.client.ui.Icon; @@ -45,11 +44,6 @@ public class CheckBoxConnector extends AbstractFieldConnector implements private HandlerRegistration focusHandlerRegistration; private HandlerRegistration blurHandlerRegistration; - private CheckBoxServerRpc rpc = RpcProxy.create(CheckBoxServerRpc.class, - this); - private FocusAndBlurServerRpc focusBlurRpc = RpcProxy.create( - FocusAndBlurServerRpc.class, this); - @Override public boolean delegateCaptionHandling() { return false; @@ -132,14 +126,14 @@ public class CheckBoxConnector extends AbstractFieldConnector implements public void onFocus(FocusEvent event) { // EventHelper.updateFocusHandler ensures that this is called only when // there is a listener on server side - focusBlurRpc.focus(); + getRpcProxy(FocusAndBlurServerRpc.class).focus(); } @Override public void onBlur(BlurEvent event) { // EventHelper.updateFocusHandler ensures that this is called only when // there is a listener on server side - focusBlurRpc.blur(); + getRpcProxy(FocusAndBlurServerRpc.class).blur(); } @Override @@ -152,7 +146,8 @@ public class CheckBoxConnector extends AbstractFieldConnector implements MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getNativeEvent(), getWidget() .getElement()); - rpc.setChecked(getWidget().getValue(), details); + getRpcProxy(CheckBoxServerRpc.class).setChecked(getWidget().getValue(), + details); } } diff --git a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java index cfdda3dd1c..1a83ae90b4 100644 --- a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java @@ -26,7 +26,6 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.Util; import com.vaadin.client.VCaption; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractLayoutConnector; import com.vaadin.client.ui.LayoutClickEventHandler; @@ -54,12 +53,10 @@ public class CssLayoutConnector extends AbstractLayoutConnector { @Override protected LayoutClickRpc getLayoutClickRPC() { - return rpc; + return getRpcProxy(CssLayoutServerRpc.class); }; }; - private CssLayoutServerRpc rpc; - private Map childToCaption = new HashMap(); /* @@ -70,7 +67,6 @@ public class CssLayoutConnector extends AbstractLayoutConnector { @Override protected void init() { super.init(); - rpc = RpcProxy.create(CssLayoutServerRpc.class, this); } /* diff --git a/client/src/com/vaadin/client/ui/embedded/EmbeddedConnector.java b/client/src/com/vaadin/client/ui/embedded/EmbeddedConnector.java index 1b56a56fe8..a15803beb7 100644 --- a/client/src/com/vaadin/client/ui/embedded/EmbeddedConnector.java +++ b/client/src/com/vaadin/client/ui/embedded/EmbeddedConnector.java @@ -32,7 +32,6 @@ import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; import com.vaadin.client.VConsole; import com.vaadin.client.VTooltip; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.shared.MouseEventDetails; @@ -46,12 +45,9 @@ import com.vaadin.ui.Embedded; public class EmbeddedConnector extends AbstractComponentConnector implements Paintable { - EmbeddedServerRpc rpc; - @Override protected void init() { super.init(); - rpc = RpcProxy.create(EmbeddedServerRpc.class, this); } @Override @@ -233,7 +229,7 @@ public class EmbeddedConnector extends AbstractComponentConnector implements @Override protected void fireClick(NativeEvent event, MouseEventDetails mouseDetails) { - rpc.click(mouseDetails); + getRpcProxy(EmbeddedServerRpc.class).click(mouseDetails); } }; diff --git a/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java b/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java index d235413d8c..1dfeadc1ff 100644 --- a/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java @@ -27,7 +27,6 @@ import com.vaadin.client.DirectionalManagedLayout; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; import com.vaadin.client.VCaption; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractComponentContainerConnector; import com.vaadin.client.ui.LayoutClickEventHandler; @@ -55,18 +54,16 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector @Override protected LayoutClickRpc getLayoutClickRPC() { - return rpc; + return getRpcProxy(GridLayoutServerRpc.class); }; }; - private GridLayoutServerRpc rpc; private boolean needCaptionUpdate = false; @Override public void init() { super.init(); - rpc = RpcProxy.create(GridLayoutServerRpc.class, this); getLayoutManager().registerDependency(this, getWidget().spacingMeasureElement); } diff --git a/client/src/com/vaadin/client/ui/image/ImageConnector.java b/client/src/com/vaadin/client/ui/image/ImageConnector.java index 17ce058c5d..e3fdd74aab 100644 --- a/client/src/com/vaadin/client/ui/image/ImageConnector.java +++ b/client/src/com/vaadin/client/ui/image/ImageConnector.java @@ -3,7 +3,6 @@ package com.vaadin.client.ui.image; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.LoadEvent; import com.google.gwt.event.dom.client.LoadHandler; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.ClickEventHandler; @@ -16,12 +15,9 @@ import com.vaadin.shared.ui.image.ImageState; @Connect(com.vaadin.ui.Image.class) public class ImageConnector extends AbstractComponentConnector { - ImageServerRpc rpc; - @Override protected void init() { super.init(); - rpc = RpcProxy.create(ImageServerRpc.class, this); getWidget().addHandler(new LoadHandler() { @Override @@ -62,7 +58,7 @@ public class ImageConnector extends AbstractComponentConnector { @Override protected void fireClick(NativeEvent event, MouseEventDetails mouseDetails) { - rpc.click(mouseDetails); + getRpcProxy(ImageServerRpc.class).click(mouseDetails); } }; diff --git a/client/src/com/vaadin/client/ui/nativebutton/NativeButtonConnector.java b/client/src/com/vaadin/client/ui/nativebutton/NativeButtonConnector.java index 6bcb2c8cbf..fa523e65c5 100644 --- a/client/src/com/vaadin/client/ui/nativebutton/NativeButtonConnector.java +++ b/client/src/com/vaadin/client/ui/nativebutton/NativeButtonConnector.java @@ -22,7 +22,6 @@ import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; import com.vaadin.client.EventHelper; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.Icon; @@ -39,15 +38,11 @@ public class NativeButtonConnector extends AbstractComponentConnector implements private HandlerRegistration focusHandlerRegistration; private HandlerRegistration blurHandlerRegistration; - private FocusAndBlurServerRpc focusBlurRpc = RpcProxy.create( - FocusAndBlurServerRpc.class, this); - @Override public void init() { super.init(); - getWidget().buttonRpcProxy = RpcProxy.create(ButtonServerRpc.class, - this); + getWidget().buttonRpcProxy = getRpcProxy(ButtonServerRpc.class); getWidget().client = getConnection(); getWidget().paintableId = getConnectorId(); } @@ -123,14 +118,14 @@ public class NativeButtonConnector extends AbstractComponentConnector implements public void onFocus(FocusEvent event) { // EventHelper.updateFocusHandler ensures that this is called only when // there is a listener on server side - focusBlurRpc.focus(); + getRpcProxy(FocusAndBlurServerRpc.class).focus(); } @Override public void onBlur(BlurEvent event) { // EventHelper.updateFocusHandler ensures that this is called only when // there is a listener on server side - focusBlurRpc.blur(); + getRpcProxy(FocusAndBlurServerRpc.class).blur(); } } diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index 8fb9f8c0e8..3b72af966b 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -24,7 +24,6 @@ import com.google.gwt.user.client.Element; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.Util; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.AbstractFieldConnector; @@ -49,8 +48,6 @@ import com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState; public abstract class AbstractOrderedLayoutConnector extends AbstractLayoutConnector { - AbstractOrderedLayoutServerRpc rpc; - /* * Handlers & Listeners */ @@ -66,7 +63,7 @@ public abstract class AbstractOrderedLayoutConnector extends @Override protected LayoutClickRpc getLayoutClickRPC() { - return rpc; + return getRpcProxy(AbstractOrderedLayoutServerRpc.class); }; }; @@ -182,7 +179,6 @@ public abstract class AbstractOrderedLayoutConnector extends @Override public void init() { super.init(); - rpc = RpcProxy.create(AbstractOrderedLayoutServerRpc.class, this); getWidget().setLayoutManager(getLayoutManager()); } diff --git a/client/src/com/vaadin/client/ui/panel/PanelConnector.java b/client/src/com/vaadin/client/ui/panel/PanelConnector.java index 695e06e0f2..679a046518 100644 --- a/client/src/com/vaadin/client/ui/panel/PanelConnector.java +++ b/client/src/com/vaadin/client/ui/panel/PanelConnector.java @@ -25,7 +25,6 @@ import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.LayoutManager; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.ui.AbstractComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.PostLayoutListener; @@ -51,18 +50,15 @@ public class PanelConnector extends AbstractComponentContainerConnector @Override protected void fireClick(NativeEvent event, MouseEventDetails mouseDetails) { - rpc.click(mouseDetails); + getRpcProxy(PanelServerRpc.class).click(mouseDetails); } }; private Integer uidlScrollLeft; - private PanelServerRpc rpc; - @Override public void init() { super.init(); - rpc = RpcProxy.create(PanelServerRpc.class, this); VPanel panel = getWidget(); LayoutManager layoutManager = getLayoutManager(); diff --git a/client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java b/client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java index a92fea55f9..6e7a556629 100644 --- a/client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java +++ b/client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java @@ -17,7 +17,6 @@ package com.vaadin.client.ui.progressindicator; import com.google.gwt.user.client.Timer; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractFieldConnector; import com.vaadin.shared.ui.Connect; @@ -33,14 +32,11 @@ public class ProgressIndicatorConnector extends AbstractFieldConnector { return (ProgressIndicatorState) super.getState(); } - ProgressIndicatorServerRpc rpc = RpcProxy.create( - ProgressIndicatorServerRpc.class, this); - private Timer poller = new Timer() { @Override public void run() { - rpc.poll(); + getRpcProxy(ProgressIndicatorServerRpc.class).poll(); } }; diff --git a/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java b/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java index 501752ed18..a4aac4fea3 100644 --- a/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java +++ b/client/src/com/vaadin/client/ui/splitpanel/AbstractSplitPanelConnector.java @@ -29,7 +29,6 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.LayoutManager; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.AbstractComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; @@ -45,12 +44,9 @@ import com.vaadin.shared.ui.splitpanel.AbstractSplitPanelState.SplitterState; public abstract class AbstractSplitPanelConnector extends AbstractComponentContainerConnector implements SimpleManagedLayout { - private AbstractSplitPanelRpc rpc; - @Override protected void init() { super.init(); - rpc = RpcProxy.create(AbstractSplitPanelRpc.class, this); // TODO Remove getWidget().client = getConnection(); @@ -71,7 +67,8 @@ public abstract class AbstractSplitPanelConnector extends position.length() - 2)); } - rpc.setSplitterPosition(pos); + getRpcProxy(AbstractSplitPanelRpc.class).setSplitterPosition( + pos); } }, SplitterMoveEvent.TYPE); @@ -115,7 +112,8 @@ public abstract class AbstractSplitPanelConnector extends @Override protected void fireClick(NativeEvent event, MouseEventDetails mouseDetails) { - rpc.splitterClick(mouseDetails); + getRpcProxy(AbstractSplitPanelRpc.class) + .splitterClick(mouseDetails); } }; diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index f2c54c0a21..e4da9afb24 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -42,7 +42,6 @@ import com.vaadin.client.Focusable; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; import com.vaadin.client.VConsole; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; import com.vaadin.client.ui.AbstractComponentContainerConnector; @@ -65,8 +64,6 @@ import com.vaadin.ui.UI; public class UIConnector extends AbstractComponentContainerConnector implements Paintable, MayScrollChildren { - private UIServerRpc rpc = RpcProxy.create(UIServerRpc.class, this); - private HandlerRegistration childStateChangeHandlerRegistration; private final StateChangeHandler childStateChangeHandler = new StateChangeHandler() { @@ -90,8 +87,9 @@ public class UIConnector extends AbstractComponentContainerConnector implements getWidget().addResizeHandler(new ResizeHandler() { @Override public void onResize(ResizeEvent event) { - rpc.resize(event.getHeight(), event.getWidth(), - Window.getClientWidth(), Window.getClientHeight()); + getRpcProxy(UIServerRpc.class).resize(event.getHeight(), + event.getWidth(), Window.getClientWidth(), + Window.getClientHeight()); if (getState().immediate) { getConnection().sendPendingVariableChanges(); } @@ -322,7 +320,7 @@ public class UIConnector extends AbstractComponentContainerConnector implements @Override protected void fireClick(NativeEvent event, MouseEventDetails mouseDetails) { - rpc.click(mouseDetails); + getRpcProxy(UIServerRpc.class).click(mouseDetails); } }; diff --git a/client/src/com/vaadin/client/ui/window/WindowConnector.java b/client/src/com/vaadin/client/ui/window/WindowConnector.java index 3091ab82d0..6b1f4b9697 100644 --- a/client/src/com/vaadin/client/ui/window/WindowConnector.java +++ b/client/src/com/vaadin/client/ui/window/WindowConnector.java @@ -31,7 +31,6 @@ import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.LayoutManager; import com.vaadin.client.Paintable; import com.vaadin.client.UIDL; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.ui.AbstractComponentContainerConnector; import com.vaadin.client.ui.ClickEventHandler; import com.vaadin.client.ui.PostLayoutListener; @@ -53,12 +52,10 @@ public class WindowConnector extends AbstractComponentContainerConnector @Override protected void fireClick(NativeEvent event, MouseEventDetails mouseDetails) { - rpc.click(mouseDetails); + getRpcProxy(WindowServerRpc.class).click(mouseDetails); } }; - private WindowServerRpc rpc; - boolean minWidthChecked = false; @Override @@ -69,7 +66,6 @@ public class WindowConnector extends AbstractComponentContainerConnector @Override protected void init() { super.init(); - rpc = RpcProxy.create(WindowServerRpc.class, this); getLayoutManager().registerDependency(this, getWidget().contentPanel.getElement()); diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java index 7783178a3b..6822edb34c 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java @@ -26,7 +26,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.shared.Connector; @@ -37,8 +36,7 @@ import com.vaadin.tests.widgetset.server.SerializerTestExtension; @Connect(SerializerTestExtension.class) public class SerializerTestConnector extends AbstractExtensionConnector { - private SerializerTestRpc rpc = RpcProxy.create(SerializerTestRpc.class, - this); + private SerializerTestRpc rpc = getRpcProxy(SerializerTestRpc.class); public SerializerTestConnector() { registerRpc(SerializerTestRpc.class, new SerializerTestRpc() { diff --git a/uitest/src/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java index 76dbdd5370..a0a6911eb2 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/helloworldfeature/HelloWorldExtensionConnector.java @@ -19,14 +19,12 @@ import com.google.gwt.user.client.Window; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.VConsole; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.shared.ui.Connect; import com.vaadin.tests.extensions.HelloWorldExtension; @Connect(HelloWorldExtension.class) public class HelloWorldExtensionConnector extends AbstractExtensionConnector { - HelloWorldRpc rpc = RpcProxy.create(HelloWorldRpc.class, this); @Override public HelloWorldState getState() { @@ -56,6 +54,6 @@ public class HelloWorldExtensionConnector extends AbstractExtensionConnector { VConsole.log(msg); String response = Window.prompt(msg, ""); - rpc.onMessageSent(response); + getRpcProxy(HelloWorldRpc.class).onMessageSent(response); } } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherConnector.java index 26fa22a667..2deef7e1ba 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7a3/RefresherConnector.java @@ -1,7 +1,6 @@ package com.vaadin.tests.widgetset.client.minitutorials.v7a3; import com.google.gwt.user.client.Timer; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.shared.ui.Connect; @@ -10,12 +9,10 @@ import com.vaadin.tests.minitutorials.v7a3.Refresher; @Connect(Refresher.class) public class RefresherConnector extends AbstractExtensionConnector { - private RefresherRpc rpc = RpcProxy.create(RefresherRpc.class, this); - private Timer timer = new Timer() { @Override public void run() { - rpc.refresh(); + getRpcProxy(RefresherRpc.class).refresh(); } }; diff --git a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java index b7dead9819..c587f53968 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/minitutorials/v7b1/CapsLockWarningWithRpcConnector.java @@ -6,7 +6,6 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ServerConnector; -import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.client.ui.VOverlay; import com.vaadin.shared.ui.Connect; @@ -15,8 +14,7 @@ import com.vaadin.tests.minitutorials.v7b1.CapsLockWarningWithRpc; @Connect(CapsLockWarningWithRpc.class) public class CapsLockWarningWithRpcConnector extends AbstractExtensionConnector { - private CapsLockWarningRpc rpc = RpcProxy.create(CapsLockWarningRpc.class, - this); + private CapsLockWarningRpc rpc = getRpcProxy(CapsLockWarningRpc.class); @Override protected void extend(ServerConnector target) { -- 2.39.5