Skip navigation
Toggle Sidebar

Project Documentation

Hooray!  more user instructions/ docs exist below....  in a nutshell: goto to the downloads link and download the zip file. and watch the screencast referenced on the main page to see how one can build new openspaces projects.

Read on for more explanation... 

Definition and basic introduction

Command Line Project Creator (CPC) increases users productivity by supplying a template-based: code, directory structure, and configuration generator. 

CPC generates the java source tree, the openspaces processing-unit configuration file, the eclipse project and classpath files, and an ant buid.xml file with predefined tasks for compiling and deploying openspaces projects.

In other words, it generates all of this:

The term 'Domain' refers to the types commonly shared between multiple services such as Messages or Tasks.  In the above image, the 'TestObject' type is a domain class that is passed to the space by a feed or publisher to be processed by other services such as the 'MyService' - a worker.

CPC supports the sharing of a single copy of the domain source code between multiple projects which is a common need.  In this way, as new projects are created, they may reuse existing types already defined by selecting an existing Domain directory.  In the image above, the project '7d83518_CommonDomain' contains the source code for the TestObject type.  Generated projects and others can decide to use that commonDomain and add additional source files and types to it, or simply reuse what is already there. 

By sharing the domain project, we ensure that multiple projects are using the same types and will not have class conflicts.

The mechanism of communication between services that use a space is not normally direct service-API calls, but rather the indirect passing of messages back and forth using the space as a reliable delivery and coordination system.

Instead of one service invoking:    MarketMaker.processThis(Stock)
The OpenSpaces programmer will normally have their services address the space by doing essentially:   Space.write(Stock)
Then, very soon after, the OpenSpaces container will take the Stock object from the space and call MarketMaker.dataProcessed(Stock)

In this way, the services are highly decoupled and never have to know anything but the types they share in order to facilitate work being done.

CPC helps to automate the creation of popular services that utilize the OpenSpaces programming model.
The two most common of the service types are the Worker and the Master (or Publisher).

To this end, CPC includes several template files that have variable tokens in them.  The variables get replaced at creation time based on the arguments you pass to the startup of the CPC scripts and the answers you give to a few questions.

Currently, the supplied service templates are :
A) Worker  --takes work in the form of objects and writes back results or nothing
B) Master/Publisher -- publishes work in the form of objects
C) Listener -- listens for activity - writing, updating, taking etc... and receives a copy of the related object which it can use to determine whether to write something back to the space, or do nothing

Installation Instructions

This project has a downloadable version (goto Downloads).  watch the screencast... : )

Usage Instructions

To get started with CPC you need:

Eclipse 3.3 (Europa) or higher [with the spring plugin]
GigaSpacesXAP6.0 or higher
Java JDK 1.5 or higher

BASIC USER STEPS

1) Download the binary distribution from the Downloads page
2) unzip it to a place with no spaces in the path eg: c:\wip\openspaces\CPC
3) edit the  commonsetup.cmd file and set the following variables to match your environment:

rem Personal Settings (these change according to each machine environment)
rem Relative Location of projectcreator.jar to this script [probably OK as is]
set JAR_FILE_LOCATION=./projectcreator.jar
rem parent directory for generated projects -- also parent of shared Domain directories
set OUTPUT_DIRECTORY=c:\wip\openspaces\CPC\out
rem standard JAVA_HOME variable
set JAVA_HOME=c:\java\jdk1.6
rem JSHOMEDIR refers to the installation directory of GigaSpacesXAP6.0
if "%JSHOMEDIR%." == "." set JSHOMEDIR=c:\GigaSpacesXAP6.0

4) Execute the createPollingWorker.cmd and creatPublisher.cmd scripts and answer the questions they ask you...

If you accept all defaults, a complete application is generated see example in Examples below

5) Import the resulting eclipse projects into eclipse

Finished! 

Examples

Here is an example printout of the execution of the createPollingWorker.cmd script
%% my comments are surrounded by two percent signs and are not part of the actual printout %%

%% script started %%

Welcome to the GigaSpaces Project Creator
To create a new project, please answer the following questions:

What would you like to name your project \[7d8325_Worker\]?
%% The 'System' or 'Worker' often is the Hub where work is done and information stored %%
Root directory for project creation \[C:\_D\temp\projectcreator\out\]?
GigaSpaces root directory \[c:\GigaSpacesXAP6.0\]?
Is Space embedded in this PU? \[yes\] default =yes
%% selecting yes means that the services written in this project will run in the same VM and have extremely low latency interactions with the space %%
Name of space \[gigaspace\]
%% gigaspace is fine as a default, you might choose something like stockSpace which helps to describe the business function of the space %%
Do you wish to create the common domain \[yes\], \[no\] default=no?
%% 'no' means an existing domain project will be reused for this project.  Specifying yes would mean a new directory would be generated and populated with an empty domain class according to the package name and classname given next.   %%
\*
Found the following existing domain directories:
{1=7d8321a_CommonDomain}
\*
Enter the number corresponding to the domain directory listed above: default=1
        NOTE: Set following as your shared domain : 7d8321a_CommonDomain

\**\*
CPC found the following domain package names:
{1=com.test.common}
\*
Package name for the common domain?
\[select a package by corresponding #\], or enter a new package name?
default=com.test.common
%% if you specify a new package name, the CPC will use the package name to build a directory structure %%
\**\*
CPC found the following domain class names:
{1=TestObject}
%% if you specify a new class name, the CPC will generate a new Class based on the basic domain object template -- other templates can be specified %%


\*
Name of Common Object you wish to use?
\[select a class by corresponding #\], or enter a new class name?
default=TestObject
\*
Package name for generated service \[com.test\], or enter a new one?
\*
ClassName of Service \[MyService\], or enter a new one?


About to create the project...  hit enter to continue.

Created directory C:\_D\temp\projectcreator\out\7d8325_Worker
DomainCreationHandler: DEBUG... commonDomainFilePath=7d8321a_CommonDomain\src\java
Utility DEBUG: createIfnotExist?true, recent.domain.package.properties, C:\_D\temp\projectcreator\out, {1=com.test.common}
Utility DEBUG: createIfnotExist?true, recent.domain.class.properties, C:\_D\temp\projectcreator\out, {1=TestObject}
Utility DEBUG: createIfnotExist?true, domain.history.properties, C:\_D\temp\projectcreator\out, {1=7d8321a_CommonDomain}

C:\_D\temp\projectcreator\out\7d8325_Worker\..\7d8321a_CommonDomain\src\java\com\test\common\TestObject.java already exists; skipping
Created directory C:\_D\temp\projectcreator\out\7d8325_Worker\src
Created directory C:\_D\temp\projectcreator\out\7d8325_Worker\src\test
Created directory C:\_D\temp\projectcreator\out\7d8325_Worker\src\java
Created directory C:\_D\temp\projectcreator\out\7d8325_Worker\src\java\com\test
Created file C:\_D\temp\projectcreator\out\7d8325_Worker\src\java\com\test\MyService.java
Created directory C:\_D\temp\projectcreator\out\7d8325_Worker\pu\7d8325_Worker\META-INF\spring
Created directory C:\_D\temp\projectcreator\out\7d8325_Worker\pu\7d8325_Worker\META-INF\spring\mode
Created directory C:\_D\temp\projectcreator\out\7d8325_Worker\src\java\META-INF\spring
Created file C:\_D\temp\projectcreator\out\7d8325_Worker\pu\7d8325_Worker\META-INF\spring\pu.xml
Created file C:\_D\temp\projectcreator\out\7d8325_Worker\src\java\META-INF\spring\pu.xml
Created file C:\_D\temp\projectcreator\out\7d8325_Worker\build.xml
Created directory C:\_D\temp\projectcreator\out\7d8325_Worker\.eclipse
Created file C:\_D\temp\projectcreator\out\7d8325_Worker\.eclipse\7d8325_Worker.launch
EclipseTemplatePath= templates/eclipse/
Created file C:\_D\temp\projectcreator\out\7d8325_Worker\.project
Created file C:\_D\temp\projectcreator\out\7d8325_Worker\.classpath


        THE END.
        (We have completed all processing possible...)
        Hit Enter to continue...

 

CPC has created the new project pointed it to the existing domain project and, using the default template files for the pu.xml and service.java, has created the worker and wired it to a polling container to remove and process TestObjects from the space.
 



Screenshots


Screenshots
(view as slideshow)
       
     
 
         
       
 


 
*

*




*


*
File|Import|Existing Projects into Workspace...





Roadmap

Wish List:

1) implement junit basic test templates that match the basic services and domain objects selected

Adaptavist Theme Builder Powered by Atlassian Confluence