--- /dev/null
+package com.vaadin.terminal.gwt.client.communication;
+
+
+public class FieldRpc {
+ public interface FocusServerRpc extends ServerRpc {
+ public void focus();
+ }
+
+ public interface BlurServerRpc extends ServerRpc {
+ public void blur();
+ }
+
+ public interface FocusAndBlurServerRpc extends FocusServerRpc,
+ BlurServerRpc {
+
+ }
+}
--- /dev/null
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+package com.vaadin.terminal.gwt.client.communication;
+
+import com.vaadin.terminal.gwt.client.ServerConnector;
+
+/**
+ * Initialization support for client to server RPC interfaces.
+ *
+ * This is in a separate interface used by the GWT generator class. The init
+ * method is not in {@link ServerRpc} because then also server side proxies
+ * would have to implement the initialization method.
+ *
+ * @since 7.0
+ */
+public interface InitializableServerRpc extends ServerRpc {
+ /**
+ * Associates the RPC proxy with a connector. Called by generated code.
+ * Should never be called manually.
+ *
+ * @param connector
+ * The connector the ServerRPC instance is assigned to.
+ */
+ public void initRpc(ServerConnector connector);
+}
\ No newline at end of file
import java.io.Serializable;
-import com.vaadin.terminal.gwt.client.ApplicationConnection;
-
/**
* Interface to be extended by all client to server RPC interfaces.
*
- * The nested interface InitializableClientToServerRpc has an
- * {@link #initRpc(String, ApplicationConnection)} method, which is created
- * automatically by a GWT generator and must be called on the client side before
- * generated implementations of the interface are used to perform RPC calls.
- *
* @since 7.0
*/
public interface ServerRpc extends Serializable {
- /**
- * Initialization support for client to server RPC interfaces.
- *
- * This is in a separate interface instead of {@link ServerRpc} because
- * otherwise also server side proxies would have to implement the
- * initialization method.
- *
- * @since 7.0
- */
- public interface InitializableClientToServerRpc extends ServerRpc {
- public void initRpc(String connectorId, ApplicationConnection client);
- }
}
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
import com.vaadin.terminal.gwt.client.ServerConnector;
+import com.vaadin.terminal.gwt.client.communication.InitializableServerRpc;
import com.vaadin.terminal.gwt.client.communication.RpcProxy.RpcProxyCreator;
import com.vaadin.terminal.gwt.client.communication.ServerRpc;
-import com.vaadin.terminal.gwt.client.communication.ServerRpc.InitializableClientToServerRpc;
public class RpcProxyCreatorGenerator extends Generator {
composer.addImport(GWT.class.getCanonicalName());
composer.addImport(ServerRpc.class.getCanonicalName());
composer.addImport(ServerConnector.class.getCanonicalName());
- composer.addImport(InitializableClientToServerRpc.class
- .getCanonicalName());
+ composer.addImport(InitializableServerRpc.class.getCanonicalName());
composer.addImport(IllegalArgumentException.class.getCanonicalName());
composer.addImplementedInterface(RpcProxyCreator.class
.getCanonicalName());
sourceWriter
.println("throw new IllegalArgumentException(\"RpcInterface and/or connector cannot be null\");");
sourceWriter.outdent();
- sourceWriter
- .println("} else if (connector.getConnectorId() == null) {");
- sourceWriter.indent();
- sourceWriter
- .println("throw new IllegalArgumentException(\"Connector must be initialized before creating Rpc instances.\");");
- sourceWriter.outdent();
JClassType initializableInterface = typeOracle.findType(ServerRpc.class
.getCanonicalName());
for (JClassType rpcType : initializableInterface.getSubtypes()) {
String rpcClassName = rpcType.getQualifiedSourceName();
- if (InitializableClientToServerRpc.class.getCanonicalName().equals(
+ if (InitializableServerRpc.class.getCanonicalName().equals(
rpcClassName)) {
// InitializableClientToServerRpc is a special marker interface
// that should not get a generated class
sourceWriter.indent();
sourceWriter.println(rpcClassName + " rpc = GWT.create("
+ rpcClassName + ".class);");
- sourceWriter
- .println("((InitializableClientToServerRpc) rpc).initRpc(connector.getConnectorId(), connector.getConnection());");
+ sourceWriter.println("((" + InitializableServerRpc.class.getName()
+ + ") rpc).initRpc(connector);");
sourceWriter.println("return (T) rpc;");
sourceWriter.outdent();
}
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.ServerConnector;
+import com.vaadin.terminal.gwt.client.communication.InitializableServerRpc;
import com.vaadin.terminal.gwt.client.communication.MethodInvocation;
import com.vaadin.terminal.gwt.client.communication.ServerRpc;
-import com.vaadin.terminal.gwt.client.communication.ServerRpc.InitializableClientToServerRpc;
/**
* GWT generator that creates client side proxy classes for making RPC calls
+ requestedType.getName().replaceAll("[$.]", "_");
JClassType initializableInterface = typeOracle
- .findType(InitializableClientToServerRpc.class
+ .findType(InitializableServerRpc.class
.getCanonicalName());
ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
.findType(ApplicationConnection.class.getCanonicalName());
// fields
- writer.println("private String connectorId;");
- writer.println("private "
- + applicationConnectionClass.getQualifiedSourceName()
- + " client;");
+ writer.println("private " + ServerConnector.class.getName()
+ + " connector;");
// init method from the RPC interface
- writer.println("public void initRpc(String connectorId, "
- + applicationConnectionClass.getQualifiedSourceName()
- + " client) {");
+ writer.println("public void initRpc(" + ServerConnector.class.getName()
+ + " connector) {");
writer.indent();
-
- writer.println("this.connectorId = connectorId;");
- writer.println("this.client = client;");
-
+ writer.println("this.connector = connector;");
writer.outdent();
writer.println("}");
}
writer.println(" {");
writer.indent();
- writer.print("client.addMethodInvocationToQueue(new MethodInvocation(connectorId, \""
+ writer.print("connector.getConnection().addMethodInvocationToQueue(new MethodInvocation(connector.getConnectorId(), \""
+ requestedType.getQualifiedBinaryName() + "\", \"");
writer.print(m.getName());
writer.print("\", new Object[] {");