Starting a JavaSpaces Service
Now that you've started all the supporting services (HTTP Server, RMI Activation
Daemon, Jini Lookup Service, and Transaction Manager Service), you can finally
start
a JavaSpaces service (Sun's implementation is known as "outrigger").
You can
choose to start either a JavaSpaces service called TransientSpace
(one that doesn't maintain data across crashes and restarts of the space) or a
persistent JavaSpaces service called FrontEndSpace (one that does
maintain data across crashes and restarts).
Starting a Transient JavaSpace
To start a TransientSpace JavaSpaces service, given that you're
running a
Jini Lookup Service, the command takes the following form:
java -Djava.security.policy=security-policy-file
-Djava.rmi.server.codebase=javaspace-codebase
-Dcom.sun.jini.outrigger.spaceName=space-name
-jar C:\jini1_0_1\lib\transient-outrigger.jar
[lookup-group]
(Refer to
C:\jini1_0_1\doc\example\StartingService.html for the details
of formatting the command if you're using an RMI registry instead.)
Let's examine the parameters. The security-policy-file
option
governs the permissions the JVM uses when running the JavaSpaces service. The
javaspace-codebase option specifies a URL that points to the
outrigger-dl.jar code that clients must download in order to use
the
JavaSpaces service. The -Dcom.sun.jini.outrigger.spaceName
option is used to specify a name for the JavaSpaces service (for example,
"JavaSpaces").
And as you saw with the transaction manager service, you can optionally specify
the
name of a Jini community for this service to join.
It's worth noting here that a transient JavaSpace service is not an activatable
service,
and the command above is handled by just a single JVM. This is why you don't
need
to pass additional arguments (codebase,
security-policy-file,
log-directory) at the end of the command as you did for the
lookup
service and transaction manager service. The JVM that executes the command will
continue to run until the JavaSpaces service exits or gets killed, so unlike the
activatable services, you will not be returned to the command prompt while the
space is running.
Here's an example of starting a transient JavaSpace, using the Jini Lookup
service,
on Windows:
java -Djava.security.policy=C:\jini1_0_1\example\books\policy.all
-Djava.rmi.server.codebase=http://hostname:8081/outrigger-dl.jar
-Dcom.sun.jini.outrigger.spaceName=JavaSpaces
-jar C:\jini1_0_1\lib\transient-outrigger.jar
public
On the Solaris platform, the equivalent command looks like this:
java -Djava.security.policy=/jini1_0_1/example/books/policy.all
-Djava.rmi.server.codebase=http://hostname:8081/outrigger-dl.jar
-Dcom.sun.jini.outrigger.spaceName=JavaSpaces
-jar /jini1_0_1/lib/transient-outrigger.jar
public
Again, you should note that the policy.all file is fine for your
code
experimentation, but you should revisit the security policy issue when you
deploy
your code in a production environment (see the Resources
section).
Starting a Persistent Javaspace
In a deployment environment, you're likely going to want to run a persistent
FrontEndSpace JavaSpaces service rather than a transient JavaSpaces
service. A FrontEndSpace is able to maintain its data, even through
crashes
and restarts of the space.
To start a FrontEndSpace JavaSpaces service, given that you're
running
a Jini Lookup Service, the command takes the following form:
java -Djava.security.policy=security-policy-file
-Dcom.sun.jini.outrigger.spaceName=space-name
-jar C:\jini1_0_1\lib\outrigger.jar
javaspace-codebase
security-policy-file
log-directory
[lookup-group]
Since FrontEndSpace is an activatable JavaSpaces service, you'll
notice
some differences from starting a transient space. First, the codebase is
specified
differently. Second, you must supply a second security policy file (as you did
when
starting the lookup service and the transaction manager, to be used when the
service
is reactivated by the RMI Activation Daemon). Last, you must supply an absolute
path name to a directory where the JavaSpaces service writes log files.
Note that outrigger.jar contains all the classes needed for the
JavaSpaces
service to run a FrontEndSpace. Here's an example of starting a
FrontEndSpace, using a Jini Lookup service, on the Windows
platform:
java -Djava.security.policy=C:\jini1_0_1\example\books\policy.all
-jar C:\jini1_0_1\lib\outrigger.jar
http://hostname:8081/outrigger-dl.jar
-Dcom.sun.jini.outrigger.spaceName=JavaSpaces
C:\jini1_0_1\example\books\policy.all
C:\tmp\js_log
public
Here's an example of starting a FrontEndSpace on Solaris:
java -Djava.security.policy=/jini1_0_1/example/books/policy.all
-jar /jini1_0_1/lib/outrigger.jar
http://hostname:8081/outrigger-dl.jar
-Dcom.sun.jini.outrigger.spaceName=JavaSpaces
/jini1_0_1/example/books/policy.all
/tmp/js_log
public
As you saw with other activatable services, issuing these commands returns
a command prompt.
Back to the Top