Automation

Contributing New Input-Output Types

Updated: October 16, 2020

This pages explains how to add new input/output types to the Automation Service.

Default input/output types are blob, document or void. You can extend the input/output types by contributing the new marshalling logic to automation.

Marshalling and operation binding logic is done by selecting client and server side using the JSON type name. At this stage, we're always using the Java type simple name in lowercase. This makes the operation binding logic happy.

The logic you need to provide is as follow:

  • The JSON type name,
  • The POJO class,
  • A writing method that puts data extracted from the POJO object into the JSON object,
  • A reading method that gets data from the JSON object and builds a POJO object from it,
  • A reference builder that extracts the server reference from a POJO object,
  • A reference resolver that provides access to a POJO object giving a server reference.

Server and client do not share classes, so you need to provide two marshalling implementation classes.

Server side, you should provide a codec. The implementation class is to be contributed to the automation server component using the codecs extension point.

  <extension target="org.nuxeo.ecm.automation.server.AutomationServer"
        point="codecs">
        <codec class="org.nuxeo.ecm.automation.server.test.MyObjectCodec" />
  </extension>

MyObjectCodec class should extend org.nuxeo.ecm.automation.server.jaxrs.io.ObjectCodec. The most common codecs provided by default into the Nuxeo server are implemented into org.nuxeo.ecm.automation.server.jaxrs.io.ObjectCodecService.

Client side, you should implement the org.nuxeo.ecm.automation.client.jaxrs.spi.JsonMarshaller<T> interface. The implementation class is to be registered to the automation client marshalling framework by invoking the static method org.nuxeo.ecm.automation.client.jaxrs.spi.AbstractAutomationClient#registerPojoMarshaller(Clazz marshaller).

Here is an example of the org.nuxeo.ecm.automation.client.jaxrs.spi.marshallers.BooleanMarshaller.