[id='generating_proto_marshallers']
= Generating Serialization Context Initializers
{brandname} provides an `protostream-processor` artifact that can generate
`.proto` schemas and `SerializationContextInitializer` implementations from
annotated Java classes.

.Procedure

. Add the `protostream-processor` dependency to your `pom.xml`.
+
[source,xml]
----
include::dependencies_maven/protostream-processor.xml[]
----
+
. Annotate the Java objects that you want to marshall with `@ProtoField` and `@ProtoFactory`.
+
[source,java]
.Book.java
----
include::code_examples/Book.java[]
----
+
[source,java]
.Author.java
----
include::code_examples/Author.java[]
----
+
. Define an interface that extends `SerializationContextInitializer` and is annotated with `@AutoProtoSchemaBuilder`.
+
[source,java]
----
include::code_examples/LibraryInitializer.java[]
----
+
<1> names the generated `.proto` schema file.
<2> sets the path under `target/classes` where the schema file is generated.

During compile-time, `protostream-processor` generates a concrete
implementation of the interface that you can use to initialize a ProtoStream
`SerializationContext`. By default, implementation names are the annotated
class name with an "Impl" suffix.

.Examples

The following are examples of a generated schema file and implementation:

[source,protobuf]
.target/classes/proto/library.proto
----
include::config_examples/generated_library.proto[]
----

[source,java]
.LibraryInitializerImpl.java
----
include::code_examples/LibraryInitializerImpl.java[]
----
