// Path: src/net/zschech/gwt/comet/client/SerialMode.java
// public enum SerialMode {
// 	RPC, DE_RPC
// }


import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.List;
import net.zschech.gwt.comet.client.SerialMode;
import net.zschech.gwt.comet.client.SerialTypes;
import com.google.gwt.core.ext.GeneratorContextExt;
import com.google.gwt.core.ext.GeneratorExt;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JField;
import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.core.ext.typeinfo.NotFoundException;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.dev.javac.rebind.RebindResult;
import com.google.gwt.dev.javac.rebind.RebindStatus;
import com.google.gwt.dev.util.collect.Lists;
import com.google.gwt.rpc.linker.RpcDataArtifact;
import com.google.gwt.user.client.rpc.impl.Serializer;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
import com.google.gwt.user.rebind.rpc.SerializableTypeOracle;
import com.google.gwt.user.rebind.rpc.SerializableTypeOracleBuilder;
import com.google.gwt.user.rebind.rpc.SerializationUtils;
import com.google.gwt.user.rebind.rpc.TypeSerializerCreator;

				writer.write("===================================\n\n");
				writer.flush();
				typesSentFromBrowserBuilder.setLogOutputWriter(writer);
				SerializableTypeOracle typesSentToBrowser = typesSentToBrowserBuilder.build(logger);
				
				writer.close();
				
				if (pathInfo != null) {
					context.commitResource(logger, pathInfo).setPrivate(true);
				}
				
				// Create the serializer
				String modifiedTypeName = typeName.replace('.', '_') + "Serializer";
				TypeSerializerCreator tsc = new TypeSerializerCreator(logger, typesSentFromBrowser, typesSentToBrowser, context, "comet." + modifiedTypeName, modifiedTypeName);
				String realize = tsc.realize(logger);
				
				// Create the CometSerializer impl
				ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);
				
				composerFactory.addImport(Serializer.class.getName());
				composerFactory.addImport(SerialMode.class.getName());
				
				composerFactory.setSuperclass(typeName);
				// TODO is the SERIALIZER required for DE RPC?
				SourceWriter sourceWriter = composerFactory.createSourceWriter(context, printWriter);
				sourceWriter.print("private Serializer SERIALIZER = new " + realize + "();");
				sourceWriter.print("protected Serializer getSerializer() {return SERIALIZER;}");
				sourceWriter.print("public SerialMode getMode() {return SerialMode." + annotation.mode().name() + ";}");
				sourceWriter.commit(logger);
				

// Path: src/net/zschech/gwt/comet/client/SerialMode.java
// public enum SerialMode {
// 	RPC, DE_RPC
// }


// Path: src/net/zschech/gwt/comet/rebind/CometSerializerGenerator.java
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.List;
import net.zschech.gwt.comet.client.SerialMode;
import net.zschech.gwt.comet.client.SerialTypes;
import com.google.gwt.core.ext.GeneratorContextExt;
import com.google.gwt.core.ext.GeneratorExt;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JField;
import com.google.gwt.core.ext.typeinfo.JType;
import com.google.gwt.core.ext.typeinfo.NotFoundException;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
import com.google.gwt.dev.javac.rebind.RebindResult;
import com.google.gwt.dev.javac.rebind.RebindStatus;
import com.google.gwt.dev.util.collect.Lists;
import com.google.gwt.rpc.linker.RpcDataArtifact;
import com.google.gwt.user.client.rpc.impl.Serializer;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
import com.google.gwt.user.rebind.SourceWriter;
import com.google.gwt.user.rebind.rpc.SerializableTypeOracle;
import com.google.gwt.user.rebind.rpc.SerializableTypeOracleBuilder;
import com.google.gwt.user.rebind.rpc.SerializationUtils;
import com.google.gwt.user.rebind.rpc.TypeSerializerCreator;

				writer.write("===================================\n\n");
				writer.flush();
				typesSentFromBrowserBuilder.setLogOutputWriter(writer);
				SerializableTypeOracle typesSentToBrowser = typesSentToBrowserBuilder.build(logger);
				
				writer.close();
				
				if (pathInfo != null) {
					context.commitResource(logger, pathInfo).setPrivate(true);
				}
				
				// Create the serializer
				String modifiedTypeName = typeName.replace('.', '_') + "Serializer";
				TypeSerializerCreator tsc = new TypeSerializerCreator(logger, typesSentFromBrowser, typesSentToBrowser, context, "comet." + modifiedTypeName, modifiedTypeName);
				String realize = tsc.realize(logger);
				
				// Create the CometSerializer impl
				ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className);
				
				composerFactory.addImport(Serializer.class.getName());
				composerFactory.addImport(SerialMode.class.getName());
				
				composerFactory.setSuperclass(typeName);
				// TODO is the SERIALIZER required for DE RPC?
				SourceWriter sourceWriter = composerFactory.createSourceWriter(context, printWriter);
				sourceWriter.print("private Serializer SERIALIZER = new " + realize + "();");
				sourceWriter.print("protected Serializer getSerializer() {return SERIALIZER;}");
				sourceWriter.print("public SerialMode getMode() {return SerialMode." + annotation.mode().name() + ";}");
				sourceWriter.commit(logger);
				

				if (annotation.mode() == SerialMode.DE_RPC) {
