Summary: How to migrate from Outrigger with no re-compilation or re-deployment of code to clients.
Overview
In general, migrating from one implementation of a Jini service interface to another should be easy and transparent to applications. This is one of the key edges of Jini. Since both Outrigger and GigaSpaces implement the JavaSpaces Jini service, one can migrate from Outrigger to GigaSpaces with no re-compilation or re-deployment of code to clients. In other words, working with GigaSpaces or Outrigger should be transparent (no code changes, no need to include other classes in the classpath, etc).
The GigaSpaces default installation launches the relevant Jini services upon server startup. If you already have an established Jini environment, you may consider disabling the embedded services.
See below a code example for a simple application accessing GigaSpaces space via the standard Jini API.
The findSpace method can be replaced by the GigaSpaces SpaceFinder.find method when using GigaSpaces advanced options.
package com.j_spaces.examples.helloworldoutrigger;
import java.rmi.RMISecurityManager;
import net.jini.core.discovery.LookupLocator;
import net.jini.core.entry.Entry;
import net.jini.core.lookup.ServiceRegistrar;
import net.jini.core.lookup.ServiceTemplate;
import net.jini.lookup.entry.Name;
import net.jini.core.lease.Lease;
import net.jini.space.JavaSpace;
public class HelloWorld
{
static public JavaSpace findSpace(String spaceName)
throws Exception
{
if ( System.getSecurityManager() == null )
System.setSecurityManager( new RMISecurityManager() );
Class [] classes = new Class[]{net.jini.space.JavaSpace.class};
Name sn = new Name( spaceName );
ServiceTemplate tmpl = new ServiceTemplate(null,classes, new Entry[] { sn } );
LookupLocator locator = new LookupLocator("jini:);
ServiceRegistrar sr = locator.getRegistrar();
JavaSpace space = (JavaSpace)sr.lookup(tmpl);
return space;
}
static public void main(String[] args)
throws Exception
{
JavaSpace space = findSpace(args[0]);
if ( space == null )
{
System.err.println("Space not found...");
System.exit(-1);
}
System.out.println("Found space: " + args[0]);
Message msg = new Message();
msg.content = "Hello World";
space.write(msg, null, Lease.FOREVER);
Message template = new Message();
Message result = (Message)space.read(template, null, JavaSpace.NO_WAIT);
System.out.println(result.content);
System.exit(0);
}
}