How To create a service

To fulfill #306, r905 provides all the classes and modifications needed to create a new stateless service (where this varies from stateful services is also detailed). In brief, a service provider must create an interface, an implementation of that interface, a Spring configuration file, as well as modify the server configuration and the central service factory (These last two points stand to change with #314).


With the creation of OMERO.blitz, there are several other locations which need to be modified. These are also listed below.

Files to create

the interface which will be made available to client and server alike (which is why all interfaces must be located in the /common component). Only serializable and client-available types should enter or exit the API. Must subclass ``ome.api.ServiceInterface``.

the implementation which will usually subclass AbstractLevel{1,2}Service or AbstractBean (See more below on super-classes) This is class obviously requires the most work, both to fulfill the interface’s contract and to provide all the metadata (annotations) necessary to properly deploy the service.

a Spring configuration file, which can “inject” any value available in the server (Omero)context into the implementation. Two short definitions are the minimum. (Currently not definable with annotations.) As explained in the file, the name of the file is not required and in fact the two definitions can be added to any of the files which fall within the lookup definition in the server’s beanRefContext.xml file (see below).

a Ice “servant” implementation which can use on of several methods for delegating to the ome.api.IConfig interface, but all of which support throttling.

Files to edit (not strictly necessary, see #314)

our central API factory, needs an additional method for looking up the new interface (get<interface name>Service()) server Spring

configurations, which makes the use of JNDI and JAAS significantly simpler. (blitz)

a ZeroC slice definition file, which provides cross-language mappings. Add the same service method to ServiceFactoryI as to (blitz)

a Spring configuration, which defines a mapping between Ice servants and Java services. (blitz)

a ZeroC slice definition file, which provides constants needed for looking up services, etc. (blitz)

the central session in a blitz. Should always be edited parallel to Also optional in that MyServicePrxHelper.uncheckedCast( serviceFactoryI.getByName(String) ) can be used instead.

Files involved

Singleton definitions which allow for the static location of the active context. These do not need to be edited, but in the case of the server beanRefContext.xml, it does define which files will be used to create the new context (of importance is the line classpath*:ome/services/service-*.xml). blitz’s beanRefContext.xml defines the pattern classpath*:ome/services/blitz-*.xml to allow for blitz-specific configuration.

And do not forget the tests

tests only the implementation without a container.

blitz: Currently, testing blitz is outside the scope of this document.

Things to be aware of

Local APIs

Several services implement a server-side subclass of the ome.api interface rather than the interface itself. These interfaces are typically in ome.api.local. Such local interfaces can provide methods that should not be made available to clients, but which are needed within the server. Though not currently used, the @Local() annotation on the implementation can list the local interface for future use. See UpdateImpl for an example.

Stateful services

Currently all stateful services are in their own component (renderer and romio) but their interface will still need to be under common for them to be accessible to clients. To be done.