Using JavaSpaces in Orc#
JavaSpaces is Sun's distributed tuple space service. JavaSpaces is now part of Apache River
.
This page supplies a simple example of using JavaSpaces in Orc, based the SDN article Getting Started With JavaSpaces Technology: Beyond Conventional Distributed Programming Paradigms by Q. H. Mamoud.
Installing Apache River#
- Download the Apache River binary release from URL: http://river.apache.org/downloads.html
- Expand the downloaded ZIP/GZIP file into a directory, which we will refer to hereinafter as ${RIVER_HOME} .
Installing the example#
- Download two utility classes from the JavaSpaces article: MessageEntry.java
and Lookup.java
.
- Compile them: javac -classpath ${RIVER_HOME}/lib/jini-ext.jar MessageEntry.java Lookup.java
- Download the Orc program SpaceClient.orc
- Download a temporary fix needed until Orc issue 84
is fixed: TempHack.java
.
- Compile with: javac -classpath ${RIVER_HOME}/lib/jini-ext.jar TempHack.java
The Orc program#
Contents of SpaceClient.orc:
-- Translation into Orc of SpaceClient.java from -- Mamoud, Q. H. 2005. Getting Started With JavaSpaces Technology: Beyond -- Conventional Distributed Programming Paradigms. Sun Developer Network. -- http://java.sun.com/developer/technicalArticles/tools/JavaSpaces/ import class MessageEntry = "MessageEntry" import class Lookup = "Lookup" import class Class = "java.lang.Class" import class Long = "java.lang.Long" import class JavaSpace = "net.jini.space.JavaSpace" MessageEntry() >msg> msg.content := "Hello there" >> Println("Searching for a JavaSpace...") >> Lookup(Class.forName("net.jini.space.JavaSpace")) >finder> finder.getService() >space> Println("A JavaSpace has been discovered. ") >> Println("Writing a message into the space...") >> space.write(msg, null, 60*60*1000) >> MessageEntry() >template> Println("Reading a message from the space...") >> space.read(template, null, Long.MAX_VALUE?) >result> Println("The message read is: "+result.content?)
Running Apache River JavaSpaces#
Open three shells and run each of the following, one per shell:
cd ${RIVER_HOME}/examples/hello ./scripts/httpd.sh
cd ${RIVER_HOME}/examples/hello ./scripts/jrmp-reggie.sh
cd ${RIVER_HOME}/examples/hello java -Djava.security.policy=config/outrigger.policy -jar ../../lib/start.jar config/start-outrigger-group.config
Running the Orc program#
In the directory with the SpaceClient.orc and the compiled MessageEntry and Lookup classfiles, run the Orc example:
java -cp ${ORC_HOME}/orc-2.0.2.jar:${ORC_HOME}/lib/\*:${RIVER_HOME}/lib/jini-ext.jar:${RIVER_HOME}/lib/reggie.jar:${RIVER_HOME}/lib/outrigger.jar:. orc.Main SpaceClient.orc
Add new attachment
Only authorized users are allowed to upload new attachments.
List of attachments
Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
---|---|---|---|---|---|---|
java |
Lookup.java | 4.7 kB | 1 | 26-Aug-2011 12:57 | JohnThywissen | |
java |
MessageEntry.java | 0.3 kB | 1 | 26-Aug-2011 12:57 | JohnThywissen | |
orc |
SpaceClient.orc | 1.0 kB | 1 | 26-Aug-2011 12:58 | JohnThywissen | |
java |
TempHack.java | 0.8 kB | 1 | 26-Aug-2011 13:06 | JohnThywissen |