Difference between revisions of "The ACME Project"

From GCube System
Jump to: navigation, search
Line 8: Line 8:
 
* a folder '''etc''' for all the configuration files of the service.
 
* 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 '''schema''' for the interfaces and supporting type definitions of the service port-types.
* a folder for the actual  Java implementation hierarchy named in accordance with its package structure.
+
* a folder '''src''' for the Java implementation hierarchy.
 
+
If we assume ACME to own the namespace ''acme.org'', then it makes sense to consider a package structure for ''SampleService'' rooted in ''org.acme.sample':
+
  
 
<pre>
 
<pre>
 
|-etc
 
|-etc
|-org
+
|-src
|--acme
+
|---sample
+
 
|-schema
 
|-schema
 
</pre>
 
</pre>
Line 22: Line 18:
 
== Organising Dependencies ==
 
== Organising Dependencies ==
  
You may have noticed that the proposed structure seems to ignore service dependencies (typically, ''jar'' archives of
+
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  
 
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:
 
two broad kinds of dependencies to consider:
Line 31: Line 27:
 
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:
 
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...'').  
+
* 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'').
 
* 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 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:
+
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 ''ServiceLibs'' 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 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 '''SAMPLESERVICELIBS''' 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 "ServiceLibs/SampleService''.
+
* 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:
 
You should end up with something like this:
Line 48: Line 44:
 
|--etc
 
|--etc
 
|--org
 
|--org
|---acme
+
|--src
|----sample
+
 
|--schema
 
|--schema
 
|
 
|
|-ServiceLibs
+
|-Dependencies
 
|--SampleService
 
|--SampleService
 
</pre>
 
</pre>

Revision as of 18:27, 10 April 2008

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

Structuring the Service

A first important question to settle concerns the organisation you should give to the implementation components. Creating a 'SampleService project for it in Eclipse allocates a folder for them under $BUILD_LOCATION, say we call it 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.
|-etc
|-src
|-schema

Organising Dependencies

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, as we shall see soon.

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:

|- SampleService
|--etc
|--org
|--src
|--schema
|
|-Dependencies
|--SampleService