@Override
    public void compile(ProtoModule module, Proto proto) throws IOException
    {
        String javaPackageName = proto.getJavaPackageName();

        StringTemplateGroup modelTemplateGroup = getSTG("java_bean_model_model");
        StringTemplateGroup schemaTemplateGroup = getSTG("java_bean_model_schema");

        // Enum blocks as is
        for (EnumGroup eg : proto.getEnumGroups())
        {
            if (eg.getAnnotation("Transient") != null)
                continue;

            Writer writer = CompilerUtil.newWriter(module, javaPackageName, eg.getName() + ".java");
            AutoIndentWriter out = new AutoIndentWriter(writer);

            StringTemplate enumBlock = schemaTemplateGroup.getInstanceOf("enum_block");
            enumBlock.setAttribute("eg", eg);
            enumBlock.setAttribute("module", module);
            enumBlock.setAttribute("options", module.getOptions());

            enumBlock.write(out);
            writer.close();
        }

        // Messages and Schemas
        for (Message m : proto.getMessages())
        {
            if (m.getAnnotation("Transient") != null)
                continue;

            // Generate model
            boolean generateModel = shouldGenerateModel(module, proto, m);
            if (generateModel)
            {
                // Get model name
                String modelFullName = getRemoteModelName(modelTemplateGroup, m);
                // Default package and name for model
                String modelPackage = javaPackageName;
                String modelName = modelFullName;
                // Detect if there is a package
                if (modelFullName.lastIndexOf('.') > -1)
                {
                    int lastDotIndex = modelFullName.lastIndexOf('.');
                    modelPackage = modelFullName.substring(0, lastDotIndex);
                    modelName = modelFullName.substring(lastDotIndex + 1);
                }

                Writer writer = CompilerUtil.newWriter(module, modelPackage, modelName + ".java");
                AutoIndentWriter out = new AutoIndentWriter(writer);

                StringTemplate messageBlock = modelTemplateGroup.getInstanceOf("message_block");
                messageBlock.setAttribute("message", m);
                messageBlock.setAttribute("module", module);
                messageBlock.setAttribute("options", module.getOptions());

                messageBlock.write(out);
                writer.close();
            }

            // Generate schema
            {
                Writer writer = CompilerUtil.newWriter(module, javaPackageName,
                        getRemoteModelSchemaName(schemaTemplateGroup, m) + ".java");
                AutoIndentWriter out = new AutoIndentWriter(writer);

                StringTemplate messageBlock = schemaTemplateGroup.getInstanceOf("message_block");
                messageBlock.setAttribute("message", m);
                messageBlock.setAttribute("module", module);
                messageBlock.setAttribute("options", module.getOptions());

                messageBlock.write(out);
                writer.close();
            }
        }
    }
Compiles proto files to protobuf java messages (pojos). Generates a {@code Schema} from the proto files.
<ul>
<li>Schemas are always separated from messages</li>
<li>Schemas are able to be inherited</li>
<li>Schemas have a lot of Annotation/Options to configure compiler output</li>
<li>@Transient support for Messages/Enumerations</li>
</ul>

@author Ivan Prisyazhniy
@created Mar 9, 2012
protostuff-compiler/src/main/java/io/protostuff/compiler/ProtoToJavaBeanModelCompiler.java