summaryrefslogtreecommitdiffstats
path: root/client-compiler
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2012-08-22 17:12:54 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2012-08-22 17:12:54 +0300
commit7e3d95735858ba8726a7dc472a054ba279d7af21 (patch)
treebbc3556e8b0b20d03e1ccd1678d831010bdc96ef /client-compiler
parent3f36eee94aa400b85a4b322d3247b72a9eee25d0 (diff)
parent88776600733901f3f9891aa90a11a5aeb2b97ef4 (diff)
downloadvaadin-framework-7e3d95735858ba8726a7dc472a054ba279d7af21.tar.gz
vaadin-framework-7e3d95735858ba8726a7dc472a054ba279d7af21.zip
Merge branch 'master' into root-cleanup
Conflicts: client/src/com/vaadin/terminal/gwt/client/ui/root/RootConnector.java
Diffstat (limited to 'client-compiler')
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java7
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java24
-rw-r--r--client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java30
3 files changed, 52 insertions, 9 deletions
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java
index a54798e5d6..6d322c734e 100644
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/RpcProxyGenerator.java
@@ -29,6 +29,7 @@ import com.google.gwt.core.ext.typeinfo.JParameter;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
+import com.vaadin.shared.annotations.Delayed;
import com.vaadin.shared.communication.MethodInvocation;
import com.vaadin.shared.communication.ServerRpc;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
@@ -129,6 +130,10 @@ public class RpcProxyGenerator extends Generator {
writer.println(" {");
writer.indent();
+ Delayed delayedAnnotation = m.getAnnotation(Delayed.class);
+ boolean delayed = delayedAnnotation != null;
+ boolean lastonly = delayed && delayedAnnotation.lastonly();
+
writer.print("this.connector.getConnection().addMethodInvocationToQueue(new MethodInvocation(this.connector.getConnectorId(), \""
+ requestedType.getQualifiedBinaryName() + "\", \"");
writer.print(m.getName());
@@ -145,7 +150,7 @@ public class RpcProxyGenerator extends Generator {
writer.print(p.getName());
}
- writer.println("}), true);");
+ writer.println("}), " + delayed + ", " + lastonly + ");");
writer.outdent();
writer.println("}");
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
index 2fc9645940..cc92551846 100644
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/SerializerGenerator.java
@@ -32,6 +32,7 @@ import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JEnumConstant;
import com.google.gwt.core.ext.typeinfo.JEnumType;
import com.google.gwt.core.ext.typeinfo.JMethod;
+import com.google.gwt.core.ext.typeinfo.JPackage;
import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.core.ext.typeinfo.TypeOracleException;
@@ -59,8 +60,6 @@ import com.vaadin.terminal.gwt.client.communication.SerializerMap;
public class SerializerGenerator extends Generator {
private static final String SUBTYPE_SEPARATOR = "___";
- private static String serializerPackageName = SerializerMap.class
- .getPackage().getName();
@Override
public String generate(TreeLogger logger, GeneratorContext context,
@@ -75,8 +74,8 @@ public class SerializerGenerator extends Generator {
String serializerClassName = getSerializerSimpleClassName(type);
try {
// Generate class source code
- generateClass(logger, context, type, serializerPackageName,
- serializerClassName);
+ generateClass(logger, context, type,
+ getSerializerPackageName(type), serializerClassName);
} catch (Exception e) {
logger.log(TreeLogger.ERROR, "SerializerGenerator failed for "
+ type.getQualifiedSourceName(), e);
@@ -465,6 +464,21 @@ public class SerializerGenerator extends Generator {
}
public static String getFullyQualifiedSerializerClassName(JClassType type) {
- return serializerPackageName + "." + getSerializerSimpleClassName(type);
+ return getSerializerPackageName(type) + "."
+ + getSerializerSimpleClassName(type);
+ }
+
+ private static String getSerializerPackageName(JClassType type) {
+ JPackage typePackage = type.getPackage();
+ if (typePackage == null) {
+ return SerializerMap.class.getPackage().getName();
+ } else {
+ String packageName = typePackage.getName();
+ // Dev mode classloader gets unhappy for some java packages
+ if (packageName.startsWith("java.")) {
+ packageName = "com.vaadin." + packageName;
+ }
+ return packageName;
+ }
}
}
diff --git a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java
index dae6f2821e..1f5b301802 100644
--- a/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java
+++ b/client-compiler/src/com/vaadin/terminal/gwt/widgetsetutils/WidgetMapGenerator.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.Map;
import java.util.TreeSet;
import com.google.gwt.core.ext.Generator;
@@ -116,8 +117,10 @@ public class WidgetMapGenerator extends Generator {
* Logger object
* @param context
* Generator context
+ * @throws UnableToCompleteException
*/
- private void generateClass(TreeLogger logger, GeneratorContext context) {
+ private void generateClass(TreeLogger logger, GeneratorContext context)
+ throws UnableToCompleteException {
// get print writer that receives the source code
PrintWriter printWriter = null;
printWriter = context.tryCreate(logger, packageName, className);
@@ -147,7 +150,7 @@ public class WidgetMapGenerator extends Generator {
logConnectors(logger, context, connectors);
// generator constructor source code
- generateImplementationDetector(sourceWriter, connectors);
+ generateImplementationDetector(logger, sourceWriter, connectors);
generateInstantiatorMethod(sourceWriter, connectors);
// close generated class
sourceWriter.outdent();
@@ -369,13 +372,18 @@ public class WidgetMapGenerator extends Generator {
/**
*
+ * @param logger
+ * logger to print messages to
* @param sourceWriter
* Source writer to output source code
* @param paintablesHavingWidgetAnnotation
+ * @throws UnableToCompleteException
*/
private void generateImplementationDetector(
+ TreeLogger logger,
SourceWriter sourceWriter,
- Collection<Class<? extends ServerConnector>> paintablesHavingWidgetAnnotation) {
+ Collection<Class<? extends ServerConnector>> paintablesHavingWidgetAnnotation)
+ throws UnableToCompleteException {
sourceWriter
.println("public Class<? extends "
+ serverConnectorClassName
@@ -385,8 +393,24 @@ public class WidgetMapGenerator extends Generator {
sourceWriter
.println("fullyQualifiedName = fullyQualifiedName.intern();");
+ // Keep track of encountered mappings to detect conflicts
+ Map<Class<? extends ClientConnector>, Class<? extends ServerConnector>> mappings = new HashMap<Class<? extends ClientConnector>, Class<? extends ServerConnector>>();
+
for (Class<? extends ServerConnector> connectorClass : paintablesHavingWidgetAnnotation) {
Class<? extends ClientConnector> clientConnectorClass = getClientConnectorClass(connectorClass);
+
+ // Check for conflicts
+ Class<? extends ServerConnector> prevousMapping = mappings.put(
+ clientConnectorClass, connectorClass);
+ if (prevousMapping != null) {
+ logger.log(Type.ERROR,
+ "Both " + connectorClass.getName() + " and "
+ + prevousMapping.getName()
+ + " have @Connect referring to "
+ + clientConnectorClass.getName() + ".");
+ throw new UnableToCompleteException();
+ }
+
sourceWriter.print("if ( fullyQualifiedName == \"");
sourceWriter.print(clientConnectorClass.getName());
sourceWriter.print("\" ) { ensureInstantiator("