The ACME Project

From GCube System
Jump to: navigation, search

Let us start with a very simple service and use it to cycle quickly through all the phases of service development: configuration, implementation, building, deployment, and testing. Let us call it SampleService and think of it as a produce of the notorious ACME.

A first important question to settle concerns the organisation you should give to the implementation components. Creating a SampleService in Eclipse allocates a folder for them under the build location. Say we call this folder the service location. But how should you organise things right below the service location? The advice is to stick to the following folder structure which besides being as simple as it gets, it is perfectly aligned with the build facilities offered by gCore:

  • a folder etc for all the configuration files of the service.
  • a folder schema for the interfaces and supporting type definitions of the service port-types.
  • a folder src for the Java implementation hierarchy.

Note: Eclipse creates new projects with a src and a bin folder by default, of course. bin collects the binaries but will play no role in our build strategy and so you can largely ignore it. Eclipse helps you here, as it excludes it by default in the package view.

You may have noticed that there is no provision for service dependencies (typically, jar archives of classpath resources, typically classes). In a word, you may be wondering where is the classic lib folder. First, notice that there are two broad kinds of dependencies to consider:

  • the standard dependencies, i.e. dependencies to binaries which ship with the gCore distribution and can be found below the gCore location ($GCUBE_LOCATION/lib). The first and foremost dependency of this kind is of course to the gCF jar (org.gcube.common.core.jar), though there are plenty more pontentially available.
  • the custom dependencies, i.e. the dependencies which are specific to the service and whose binaries cannot be guaranteed to be part of a gCore installation. The first and foremost custom dependency of every service is to its own stubs.

Clearly we need to worry only about custom dependencies. Standard dependencies are already somewhere and all we need to do is to point Eclipse to them. A clean way of doing this requires to:

  • create a user library, say GCORELIBS, at the workspace level (Preferences/Java/Build Path/User Libraries/New...) and populate it with all the binaries in $GCUBE_LOCATION/lib (Preferences/Java/Build Path/User Libraries/Add Jars...).
  • specify a single dependency to GCORELIBS in each and very service in the workspace (Properties/Java Build Path/Libraries/Add Library.../UserLibrary).

So, back to custom dependencies. The idea is to follow an unconventional strategy and keep them outside the service location. The main reason for this is that there are tools for the management of custom dependencies to other gCube services which are most conveniently used if we keep those dependencies outside the service location. This will become clear later on, when we will look at those tools. For the time being, just take our word for it. So:

  • create a generic Eclipse project Dependencies and a folder SampleService right under it. The idea here is to have a single project to group the custom dependencies of all the service in the workspace, to dedicate its sub-folders to individual services, and to place custom dependencies in each folder as they become manifest during service development.
  • create another user library SAMPLESERVICEDEPS in Eclipse and add it as a single dependency to SampleService. For the time being this library is empty, but we will populate it with all the custom dependencies we place in Dependencies/SampleService.

You should end up with something like this: