Creating a Custom Service
To create a service that can be accessed through the ServiceFactory
, there are a couple of things that need to be configured, below you will see this process using an example service HelloWorldApi
:
Create an interface that extends
ExposedApi
.If you would like your service to be accessible remotely it needs to support being used via jmx. Attivio provides JMX interactivity to classes which use annotations seen above (used appropriately per method depending on desired type of interactivity)
Create an implementation of your service that you intend to be used at runtime.
Register the implementation as a bean in the
beans.xml
file (located in thesrc/main/resources
folder of the project).If desired, create a mock implementation of your service.
Mock implementations are used when testing. They are not strictly necessary if the runtime implementation of a service works in a testing environment.
Register your mock in
attivio.test.json
.If no mock is created, the runtime implementation must be specified in this file so that the
ServiceFactory
knows what service implementation to use during testingAccess your service using the
ServiceFactory
.
The service should now work whether it is being used in the node process, remotely in a separate process (for example aie-exec
), or in a junit test.
The implementation in the test association in the attivio.test.json
file will run during testing.
Last updated
Was this helpful?