public class AddressClient
{
public static void main( String[] args )
{
EJClient client = new EJClient( "localhost", EJConstants.EJOE_PORT );
client.enablePersistentConnection( true );
try
{
// create an address object for Jimmy Who
Address address = new Address();
address.setStreetNum( 20 );
address.setStreetName( "Peachtree Avenue" );
address.setCity( "Atlanta" );
address.setState( "GA" );
address.setZip( 39892 );
//create a RemotingRequest to invoke the remote AddressBook
RemotingRequest request = new RemotingRequest( AddressBook.class.getName(), "addEntry", new Object[] {
"Jimmy Who", address } );
//add Jimmys address
System.out.println("adding Jimmys address...");
client.execute( request );
// create an address object for Jane Who
address.setStreetNum( 21 );
address.setStreetName( "Peachtree Avenue" );
address.setCity( "Atlanta" );
address.setState( "GA" );
address.setZip( 39892 );
//add Janes address
request.setArgs( new Object[] { "Jane", "Who", address } );
System.out.println("adding Janes address...");
client.execute( request );
// now query both addresses
request.setMethod( "getAddressFromName" );
request.setArgs( new Object[] { "Jimmy Who" } );
System.out.println("querying Jimmys address...");
Address adrJimmy = (Address) client.execute( request );
System.out.println("Jimmys address: ");
XStream xstream = new XStream();
System.out.println( xstream.toXML( adrJimmy ));
System.out.println("");
request.setArgs( new Object[] { "Jane Who" } );
System.out.println("querying Janes address...");
Address adrJane = (Address) client.execute( request );
System.out.println("Janes address: ");
System.out.println( xstream.toXML( adrJane ));
}
catch ( IOException e )
{