Directory structure for the Services layer source code

This document describes the directory structure for the source code for CollectionSpace's Services layer.

Contents

Top level

At the top level services directory, the structure is as follows.

services
|-- build.xml
|-- pom.xml
|-- 3rdparty
|-- docs
|-- services

The services/3rdparty directory contains third-party libraries need to run a CollectionSpace instance. Note that usually, Maven will resolve and package third-party libraries' related dependencies. However, this additional set of libraries are required for some specific needs, such as initializing the OSGI container in the Nuxeo client.

The services/services directory contains all the CollectionSpace services.

Individual service

The directory structure for an individual service follows the Maven-specified directory layout. Each service in services/services typically has the following top-level files and sub-modules:

my-service
|-- build.xml
|-- pom.xml
|-- 3rdparty
|-- client
|-- jaxb
|-- service
  • build.xml is the Ant build file. You can identify the available Ant targets at any level in the source code tree containing a build.xml file by running:
 
ant -p

That will return output similar to the following:

Buildfile: build.xml

        collectionobject service

Main targets:

 clean     Delete target directories
 deploy    deploy collectionobject service
 dist      distribute collectionobject service}
 install   Install
 package   Package CollectionSpace Services
 test      Run tests
 undeploy  undeploy collectionobject service

Ant targets such as clean, install, package, and test call corresponding Maven targets.

  • pom.xml is the service project's Maven Project Object Model (POM) file.
  • The 3rdparty sub-module contains third-party specific code for a service, for example, a Nuxeo document type definition. (In CollectionSpace versions 4.0 and higher, some of the code and configuration that formerly appeared in this sub-module is now automatically generated from configuration in CollectionSpace's Application layer.)
  • The client sub-module contains the source code for the client/consumer-side Java library code and tests written using TestNG.
  • The jaxb sub-module contains the XML schema for the common entity schema object of the service. This may be relevant only for entity services, such as those dealing with objects, procedures, and authority terms. The schemas are compiled using the JAXB compiler and relevant Java bindings are automatically generated.
  • The services sub-module contains the server side code of the service.

Typically, in both the client and services sub-modules, the src/main/java directory contains the service's source code, while the src/test/java directory contains the client-side or server-side test code, respectively.

Sub-modules of each service

3rdparty

The following is an example of a 3rdparty sub-module's structure:


3rdparty
|-- build.xml
|-- pom.xml
`-- nuxeo-platform-cs-collectionobject
    |-- build.xml
    |-- pom.xml
    |-- src
    |   `-- main
    |       `-- resources
    |           `-- META-INF
    |           `-- OSGI-INF
    |           `-- schemas

client

The client sub-module's structure would be as follows.


client
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |       `-- org
    |           `-- collectionspace
    |               `-- services
    |                   `-- client
    |                       `-- collectionobject
    `-- test
        `-- java
            `-- com
                `-- collectionspace
                    `-- services
                        `-- collectionobject
                            `-- CollectionObjectServiceTest.java

jaxb

The jaxb sub-module's structure would be as follows.


jaxb
|-- pom.xml
`-- src
    |-- main
    |   `-- resources
    |       `-- collectionobject.xsd
    

service

The service sub-module has the following structure. Let's use the CollectionObject service as an example:

service
|-- build.xml
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |       `-- org
    |           `-- collectionspace
    |               `-- services
    |                   `-- collectionobject
    `-- test
        `-- java
            `-- com
                `-- collectionspace
                    `-- services
                        `-- collectionobject
                            `-- ServiceSideTest.java