[id='protostuff_marshalling']
= Using the Protostuff Marshaller
{brandname} provides a marshalling implementation that uses Protostuff
libraries.

.Prerequisites for {brandname} Servers

To use Protostuff marshalling with {brandname} servers, add a JAR that includes
the runtime class files for the Protostuff marshalling implementation as
follows:

//Community
ifndef::productized[]
. Download the
link:http://central.maven.org/maven2/org/infinispan/infinispan-marshaller-protostuff-bundle/{infinispanversion}/infinispan-marshaller-protostuff-bundle-{infinispanversion}.jar[Protostuff Bundle JAR].
endif::productized[]
//Product
ifdef::productized[]
. Copy `infinispan-marshaller-protostuff-bundle.jar` from the {brandname} Maven
repository.
endif::productized[]
. Add the JAR file to the `server/lib` directory in your {brandname} server installation directory.

.Prerequisites for {brandname} Library Mode

To use Protostuff marshalling with {brandname} as an embedded library in your application, do the following:

. Add the `infinispan-marshaller-protostuff` dependency to your `pom.xml`.
+
[source,xml]
----
include::dependencies_maven/marshaller-protostuff.xml[]
----
+
. Specify the `org.infinispan.marshaller.protostuff.ProtostuffMarshaller` class
as the marshaller.
+
[source,java]
----
GlobalConfigurationBuilder builder = new GlobalConfigurationBuilder();
builder.serialization()
       .marshaller(new org.infinispan.marshaller.protostuff.ProtostuffMarshaller());
----

.Procedure

Do one of the following to register custom Protostuff schemas for object
marshalling:

* Call the `register()` method.
+
[source,java]
----
include::code_examples/RegisterCustomProtostuffSchema.java[]
----

* Implement a service provider for the `SerializerRegistryService.java` interface that places all schema registrations in the `register()` method.
+
You should then specify the full path of implementing classes in your deployment JAR file within:
+
----
META-INF/services/org/infinispan/marshaller/protostuff/SchemaRegistryService
----

.Reference

* link:#deserialization_allowlist-marshallers[Adding Java Classes to Deserialization Allow Lists]
* link:https://github.com/protostuff/protostuff[Protostuff on GitHub]
