Archive for the 'JavaSpaces' Category

« Previous PageNext Page »

version .02 Update to project-creator.jar –Make your own templates!

September 7th, 2007

I have made another fix to the project-creator.jar found here.

This fix allows you to specify

-templateDir X

where

X = path relative to the directory from which the script is invoked

or

X = Absolute path

example:

Let’s say I want to create a new template for my data Object so that it always has a defined String property.

I create a file called “dataObject.javasrc” (because that is currently the only name available for the dataObject template file)

The file could look like this:

***

package @packageName.common;

public class @dataObjectName {

private String dummyValue;

public void setDummyValue(String val){dummyValue=val;}

public String getDummyValue(){return dummyValue};

}

***

I save that file in:

c:\tmp\openspaces\mytemplates

in c:\tmp\openspaces I have a script that looks like this: (changes from previous examples are in different font)



****

rem Personal Settings (these change according to each machine environment)

set JAR_FILE_LOCATION=./project-creator.jar

set OUTPUT_DIRECTORY=c:/tmp/openspaces/output

set JAVA_HOME=c:\java\jdk1.5.0_07

if “%JSHOMEDIR%.” == “.” set JSHOMEDIR=c:\GigaSpacesXAP6.0

rem Script-specific Configuration Settings:

set PROJECT_NAME=Worker

if “%IDE%.” == “.” set IDE=-eclipse

set SERVICE_TEMPLATE_NAME=service.javasrc_myversion

set PU_TEMPLATE_NAME=pu.xmlsrc

set TEMPLATE_DIR=-templateDir ./mytemplates



rem General Options

rem elect to overwrite existing projects with same name:

set OVERWRITE_OPTION=-overwrite

call %JAVA_HOME%\bin\java -jar %JAR_FILE_LOCATION% %IDE% %OVERWRITE_OPTION% -project %PROJECT_NAME% -out %OUTPUT_DIRECTORY% -setServiceTemplateName %SERVICE_TEMPLATE_NAME% -setPUTemplateName %PU_TEMPLATE_NAME% -gigaHome %JSHOMEDIR% %TEMPLATE_DIR%

****

If I call that script from the c:\tmp\openspaces directory all will be well and it will find my new version of the dataObject.javasrc file.

If I do not want to call it from that dir everytime, I can instead provide the arg:

set TEMPLATE_DIR=-templateDir c:/tmp/openspaces/mytemplates






and call the script from anywhere.

If the template needed for an operation is not provided in your specified TEMPLATE_DIR, projectcreator will look for it in the jar file as usual.

The template directory structure is as follows:

/%templateDir%

/%templateDir%/eclipse

/%templateDir%/intellij

All the templates are stored in the root of the templateDir except the files used for eclipse and intellij.

Some of the templates you can create must have certain names such as:

build.xml

any of the eclipse or intellij files

dataObject.javasrc

The template files used for the Service.java and pu.xml files can be given any name you like.

Within the templates you create you can currently use any of the following as replacement tokens: (consult the source code found here for more details)

@projectName (Name of the project you want to build)

@spaceName (Name of the space you want to connect to ex: MySpace)

@propertySpaceName (Name of the space with a lowercased first letter – derived from @spaceName ex: mySpace)

@varGSHome (Path to [and including] Root Directory of your XAP installation)

@spaceUrl (This is derived from the @spaceName and your choice of remote or embedded)

@packageName (You specify this as the package for your first service in this Project)

@packageDir (This is derived from the @packageName)

@serviceName (You specify this as the name of your service class)

@dataObjectName (You specify this as the name of your data class (note the package name will set to @packageName.common to ensure this class is packaged in a separate jar file for classloading purposes)

I hope this addition makes this utility even more fun to use.

Cheers,

Owen.

Project Creator Demo: tutorial (Webcast -no sound)

September 6th, 2007

I have created a webcast tutorial that should prove instructive to those seeking to utilize the projectcreator utility.

It demonstrates how to create the scripts, get the jar, build a simple application and run it.

It is my hope this will encourage more successful use of this tool and of the OpenSpaces platform.

Note that the webcast moves very quickly so you may want to ready the pause button to catch all the details. . . uh.. “there is no pause button…”

Sorry. Let me know if it is unusable the way it is.

You can watch the webcast by clicking the following link: projectcreator_tutorial_noSound

Remember: project-creator is *not* supported by GigaSpaces, but OpenSpaces and GigaSpaces are.



: )

–if you have questions regarding the use of the GigaSpaces core services or the OpenSpaces Spring abstraction layer, check out the award-winning documentation found: here .

And if you still have concerns, you can register with the online users forum and post them to the GigaSpaces Forum.

HTH

Cheers,

Owen.

Alternate Script to create projects using ProjectCreator and update to jar

September 5th, 2007

Hi,

I have made a small adjustment to one of the template files in the project-creator.jar. This means that *all* eclipse projects will be generated with a classpath that includes the variable GS_HOME . This variable will point to whatever you (the owner of the running eclipse instance) determines it should point to.

BTW: It needs to point to the home directory for your installation of GigaSpacesXAP6.0

To accomplish this:

1) create the project using projectcreator

2) import the project into eclipse version 3.3 (europa)

3) right-click on the project and select

Build Path | Configure Build Path…

4) select

Add Variable | Configure Variables…

5) select

New…

6) enter the following in the two fields

Name: GS_HOME

Path: [browse_to_the_home_directory_of_your_installation_of_GigaSpacesXAP6.0]

(

On my system, in eclipse I have configured GS_HOME to point to

c:\GigaSpacesXAP6.0

)

7) click OK
8) do a rebuild

9) ignore the warning that the path is not a jar file (we know that already)

10) Find your way back to the project and look: the red x is gone!

The Variable GS_HOME should now be resolved and reusable for future projects in eclipse.

In addition, I noticed mucho redundancy in the scripts I offered in my previous posts.

The eclipse and intellij versions are now identical except for the value provided for the IDE variable.

The following scripts are hopefully clearer alternates you can use to create the various projects:



____________________________

file: createPublisher.cmd

____________________________

rem #### if you are using intellij: before calling this script, configure the following:

rem #### set IDE=-intellij

rem ####

rem This script starts the projectCreator so as to create a PU containing a TimerTask – a SpringBean that gets invoked over and over again by a Timer. Configure how often to do this in the PU.xml Note this is good for a feed or driver and usually means you will elect to have a remote space.

rem In addition: if the IDE is set to -eclipse:

rem ProjectCreator determines that the classpath in the eclipse project uses an eclipse-specific GS_HOME variable in the same way the examples that come with the product do – this makes for a more portable project. Note that the build.xml file created as part of the project will still use an explicit path and will need to be edited if the project is used in a new environment and the ant tasks are invoked.

rem Personal Settings (these change according to each machine environment)

set JAR_FILE_LOCATION=./project-creator.jar

set OUTPUT_DIRECTORY=C:\tmp\projectcreator

set JAVA_HOME=c:\java\jdk1.5.0_07

if “%JSHOMEDIR%.” == “.” set JSHOMEDIR=c:\GigaSpacesXAP6.0

rem Script-specific Configuration Settings:

set PROJECT_NAME=Publisher

if “%IDE%.” == “.” set IDE=-eclipse

set SERVICE_TEMPLATE_NAME=service.javasrc_timerTask

set PU_TEMPLATE_NAME=pu.xmlsrc_timerTask

rem General Options

rem elect to overwrite existing projects with same name:

set OVERWRITE_OPTION=-overwrite

call %JAVA_HOME%\bin\java -jar %JAR_FILE_LOCATION% %IDE% %OVERWRITE_OPTION% -project %PROJECT_NAME% -out %OUTPUT_DIRECTORY% -setServiceTemplateName %SERVICE_TEMPLATE_NAME% -setPUTemplateName %PU_TEMPLATE_NAME% -gigaHome %JSHOMEDIR%

____________________________

____________________________

file: createNotifyListener.cmd

____________________________

rem #### if you are using intellij: before calling this script, configure the following:

rem #### set IDE=-intellij

rem ####

rem This script starts the projectCreator so as to create a PU containing a NotifyContainer – a SpringBean with a default method that gets invoked when a matching object appears or is modified in the space. Note this is good for a listener (a take is not performed as part of the NotifyContainer operation) and could be implemented with either a remote or embedded space.

rem In addition: if the IDE is set to -eclipse:

rem ProjectCreator determines that the classpath in the eclipse project uses an eclipse-specific GS_HOME variable in the same way the examples that come with the product do – this makes for a more portable project. Note that the build.xml file created as part of the project will still use an explicit path and will need to be edited if the project is used in a new environment and the ant tasks are invoked.

rem Personal Settings (these change according to each machine environment)

set JAR_FILE_LOCATION=./project-creator.jar

set OUTPUT_DIRECTORY=C:\tmp\projectcreator

set JAVA_HOME=c:\java\jdk1.5.0_07

if “%JSHOMEDIR%.” == “.” set JSHOMEDIR=c:\GigaSpacesXAP6.0

rem Script-specific Configuration Settings:

set PROJECT_NAME=NotifyListener

if “%IDE%.” == “.” set IDE=-eclipse

set SERVICE_TEMPLATE_NAME=service.javasrc

set PU_TEMPLATE_NAME=pu.xmlsrc_notifyContainer

rem General Options

rem elect to overwrite existing projects with same name:

set OVERWRITE_OPTION=-overwrite

call %JAVA_HOME%\bin\java -jar %JAR_FILE_LOCATION% %IDE% %OVERWRITE_OPTION% -project %PROJECT_NAME% -out %OUTPUT_DIRECTORY% -setServiceTemplateName %SERVICE_TEMPLATE_NAME% -setPUTemplateName %PU_TEMPLATE_NAME% -gigaHome %JSHOMEDIR%

_______________________________

file: createPollingWorker.cmd

____________________________

rem #### if you are using intellij: before calling this script, configure the following:

rem #### set IDE=-intellij

rem ####

rem This script starts the projectCreator so as to create a PU containing a PollingContainer – a SpringBean with a default method that gets invoked when a matching object appears or is modified in the space. NB: The PollingContainer removes (takes) the interesting information from the Space!

rem Note this is good for a worker and usually means you will elect to have an embedded space.

rem In addition: if the IDE is set to -eclipse:

rem ProjectCreator determines that the classpath in the eclipse project uses an eclipse-specific GS_HOME variable in the same way the examples that come with the product do – this makes for a more portable project. Note that the build.xml file created as part of the project will still use an explicit path and will need to be edited if the project is used in a new environment and the ant tasks are invoked.

rem Personal Settings (these change according to each machine environment)

set JAR_FILE_LOCATION=./project-creator.jar

set OUTPUT_DIRECTORY=C:\tmp\projectcreator

set JAVA_HOME=c:\java\jdk1.5.0_07

if “%JSHOMEDIR%.” == “.” set JSHOMEDIR=c:\GigaSpacesXAP6.0

rem Script-specific Configuration Settings:

set PROJECT_NAME=PollingWorker

if “%IDE%.” == “.” set IDE=-eclipse

set SERVICE_TEMPLATE_NAME=service.javasrc

set PU_TEMPLATE_NAME=pu.xmlsrc

rem General Options

rem elect to overwrite existing projects with same name:

set OVERWRITE_OPTION=-overwrite

call %JAVA_HOME%\bin\java -jar %JAR_FILE_LOCATION% %IDE% %OVERWRITE_OPTION% -project %PROJECT_NAME% -out %OUTPUT_DIRECTORY% -setServiceTemplateName %SERVICE_TEMPLATE_NAME% -setPUTemplateName %PU_TEMPLATE_NAME% -gigaHome %JSHOMEDIR%

________________________________

Cheers,

Owen.

ProjectCreator now supports IntelliJ & Eclipse !

August 29th, 2007

Well, it is time to announce another update to the project creator utility.

This latest project-creator jar can be found HERE.

It now supports the creation of projects for intellij as well as eclipse… Hooray!









..

Please note that with this change, the scripts I published have one change that is necessary for both eclipse and intellij and one option that enables the intellij project creation.

The change for all scripts is the use of -gigaHome in place of -gigaHomeVar

The option for intellij is -intellij (in place of the still available -eclipse)

Here follows some example scripts for the creation of OpenSpaces projects :





rem ……

……

……

___________________________________________

NOTIFYCONTAINER_INTELLIJ (listener)

___________________________________________

rem Intellij Version

rem This script starts the projectCreator so as to create a PU containing a NotifyContainer – a SpringBean with a default method that gets invoked when a matching object appears or is modified in the space. Note this is good for a listener (a take is not performed as part of the NotifyContainer operation) and could be implemented with either a remote or embedded space.

set JAVA_HOME=c:\java\jdk1.5.0_07

call %JAVA_HOME%\bin\java -jar project-creator.jar -intellij -overwrite -project test -out C:\tmp\projectcreator -setServiceTemplateName service.javasrc -setPUTemplateName pu.xmlsrc_notifyContainer -gigaHome c:\GigaSpacesXAP6.0

rem ##end of script##

___________________________________________

NOTIFYCONTAINER_ECLIPSE (listener)

___________________________________________

rem Eclipse Version

rem This script starts the projectCreator so as to create a PU containing a NotifyContainer – a SpringBean with a default method that gets invoked when a matching object appears or is modified in the space. Note this is good for a listener (a take is not performed as part of the NotifyContainer operation) and could be implemented with either a remote or embedded space.

rem In addition: This script specifies that the classpath in the eclipse project uses a GS_HOME variable in the same way the examples that come with the product do – this makes for a more portable project. Note that the build.xml file created as part of the project will still use an explicit path and will need to be edited if the project is used in a new environment and the ant tasks are invoked.

set JAVA_HOME=c:\java\jdk1.5.0_07

call %JAVA_HOME%\bin\java -jar project-creator.jar -eclipse -overwrite -project test -out C:\tmp\projectcreator -setServiceTemplateName service.javasrc -setPUTemplateName pu.xmlsrc_notifyContainer -gigaHome c:\GigaSpacesXAP6.0

rem ##end of script##

___________________________________________

POLLINGCONTAINER_INTELLIJ (worker)

___________________________________________

rem Intellij Version

rem This script starts the projectCreator so as to create a PU containing a PollingContainer – a SpringBean with a default method that gets invoked when a matching object appears or is modified in the space. Note this is good for a worker and usually means you will elect to have an embedded space.

set JAVA_HOME=c:\java\jdk1.5.0_07

call %JAVA_HOME%\bin\java -jar project-creator.jar -intellij -overwrite -project test -out C:\tmp\projectcreator -setServiceTemplateName service.javasrc -setPUTemplateName pu.xmlsrc -gigaHome c:\GigaSpacesXAP6.0

rem ##end of script##

___________________________________________

POLLINGCONTAINER_ECLIPSE (worker)

___________________________________________

rem Eclipse Version

rem This script starts the projectCreator so as to create a PU containing a PollingContainer – a SpringBean with a default method that gets invoked when a matching object appears or is modified in the space. Note this is good for a worker and usually means you will elect to have an embedded space.

rem In addition: This script specifies that the classpath in the eclipse project uses a GS_HOME variable in the same way the examples that come with the product do – this makes for a more portable project. Note that the build.xml file created as part of the project will still use an explicit path and will need to be edited if the project is used in a new environment and the ant tasks are invoked.

set JAVA_HOME=c:\java\jdk1.5.0_07

call %JAVA_HOME%\bin\java -jar project-creator.jar -eclipse -overwrite -project test -out C:\tmp\projectcreator -setServiceTemplateName service.javasrc -setPUTemplateName pu.xmlsrc -gigaHome c:\GigaSpacesXAP6.0

rem ##end of script##

___________________________________________

TIMERTASK_INTELLIJ (publisher)

___________________________________________

rem Intellij Version

rem This script starts the projectCreator so as to create a PU containing a TimerTask – a SpringBean that gets invoked over and over again by a Timer. Configure how often to do this in the PU.xml Note this is good for a feed or driver and usually means you will elect to have a remote space.

set JAVA_HOME=c:\java\jdk1.5.0_07

call %JAVA_HOME%\bin\java -jar project-creator.jar -intellij -overwrite -project test -out C:\tmp\projectcreator -setServiceTemplateName service.javasrc_timerTask -setPUTemplateName pu.xmlsrc_timerTask -gigaHome c:\GigaSpacesXAP6.0

rem ##end of script##

___________________________________________

TIMERTASK_ECLIPSE (publisher)

___________________________________________

rem Eclipse Version

rem This script starts the projectCreator so as to create a PU containing a TimerTask – a SpringBean that gets invoked over and over again by a Timer. Configure how often to do this in the PU.xml Note this is good for a feed or driver and usually means you will elect to have a remote space.

rem In addition: This script specifies that the classpath in the eclipse project uses a GS_HOME variable in the same way the examples that come with the product do – this makes for a more portable project. Note that the build.xml file created as part of the project will still use an explicit path and will need to be edited if the project is used in a new environment and the ant tasks are invoked.

set JAVA_HOME=c:\java\jdk1.5.0_07

call %JAVA_HOME%\bin\java -jar project-creator.jar -eclipse -overwrite -project test -out C:\tmp\projectcreator -setServiceTemplateName service.javasrc_timerTask -setPUTemplateName pu.xmlsrc_timerTask -gigaHome c:\GigaSpacesXAP6.0

rem ##end of script##

___________________________________________






It is my hope that those of you who held off trying out OpenSpaces to this point will download the XAP 6.0 version of GigaSpaces and the project-creator jar found

HERE and get to work building the next greatest software solution!



Cheers,



Owen.

Update to project-creator.jar

August 21st, 2007

Hi Again,

I have updated the jar file found Here.

The changes are:

1) Added a NotifyContainer template — to use this execute the following script:

rem This script starts the projectCreator so as to create a PU containing a NotifyContainer – a SpringBean with a default method that gets invoked when a matching object appears or is modified in the space. Note this is good for a listener (a take is not performed as part of the NotifyContainer operation) and could be implemented with either a remote or embedded space.

rem In addition: This script specifies that the classpath in the eclipse project uses a GS_HOME variable in the same way the examples that come with the product do – this makes for a more portable project. Note that the build.xml file created as part of the project will still use an explicit path and will need to be edited if the project is used in a new environment and the ant tasks are invoked.

set JAVA_HOME=c:\java\jdk1.5.0_07

call %JAVA_HOME%\bin\java -jar project-creator.jar -eclipse -overwrite -project test -out C:\tmp\projectcreator -setServiceTemplateName service.javasrc -setPUTemplateName pu.xmlsrc_notifyContainer -gigaHomeVar c:\GigaSpacesXAP6.0

Notice that other than the change to the -setPUTemplateName, this script is identical to the one used for the pollingcontainer.

2) Fixed two bugs:

a) Extra HelloWorld directory is no longer created inside the processing unit directory

b) The FIXME properties offered in the templates for the pollingcontainer and notifycontainer are now inside comments in the XML so they will not break your build if you simply ignore them.

Added these simple print statements to the java templates so you can see activity as soon as you build and deploy it:

TimerTask:

System.out.println(this.getClass().getName()+” Wrote @dataObjectName “+obj);

(note: you need to uncomment the sample code block in the execute method to enable this behavior)

PollingService:

System.out.println(this.getClass().getName()+” Received @dataObjectName: “+data);



Practical Instructions for use:


  1. Run the command(s) to generate a publisher, poller, or listener processing unit project supplying args as you see fit. (see example commands in this and earlier posts)
  2. Import the project(s) into eclipse
  3. Uncomment the code in your publisher execute method to see the default behavior
  4. Run the project that declares an embedded space by right-clicking it in eclipse and selecting ‘Run As’ | ‘Open Run Dialog…’ Then select the configuration with the same name as the project you right-clicked and click ‘Run’
  5. Run any other projects that share that space - you may want to wait to start the publisher until after all listeners and pollers are started.
  6. Watch as the default print Statements prove the various pieces are communicating.
  7. Edit the java files so they perform some real logic and process real information. be sure to keep your common libraries in sync — I will provide a simpler way to manage as part of this utility in the future.

Cheers,

Owen.

« Previous PageNext Page »