Package de.netseeker.ejoe.examples.remoting

Source Code of de.netseeker.ejoe.examples.remoting.AddressClientWithJdkProxy

/*********************************************************************
* AddressClient.java
* created on 17.03.2005 by netseeker
* $Source: /cvsroot/ejoe/EJOE/examples/de/netseeker/ejoe/examples/remoting/AddressClientWithJdkProxy.java,v $
* $Date: 2007/03/28 08:18:26 $
* $Revision: 1.2 $
*********************************************************************/
package de.netseeker.ejoe.examples.remoting;

import com.thoughtworks.xstream.XStream;

import de.netseeker.ejoe.EJClient;
import de.netseeker.ejoe.EJConstants;
import de.netseeker.ejoe.RemotingService;

/**
* Simple example showing how to implement a basic address management client using remote reflection with EJOE.
*
* @author netseeker
*/
public class AddressClientWithJdkProxy
{

    public static void main( String[] args )
    {
        EJClient client = new EJClient( "localhost", EJConstants.EJOE_PORT );
        client.enablePersistentConnection( true );
        IAddressBook addressBook = (IAddressBook) RemotingService.createService( AddressBook.class.getName(),
                                                                                 IAddressBook.class, client );

        // 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 );

        // add Jimmys address
        System.out.println( "adding Jimmys address..." );
        addressBook.addEntry( "Jimmy Who", address );

        // 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
        System.out.println( "adding Janes address..." );
        addressBook.addEntry( "Jane", "Who", address );

        // now query both addresses
        System.out.println( "querying Jimmys address..." );
        Address adrJimmy = addressBook.getAddressFromName( "Jimmy Who" );
        System.out.println( "Jimmys address: " );
        XStream xstream = new XStream();
        System.out.println( xstream.toXML( adrJimmy ) );

        System.out.println( "" );

        System.out.println( "querying Janes address..." );
        Address adrJane = addressBook.getAddressFromName( "Jane Who" );
        System.out.println( "Janes address: " );
        System.out.println( xstream.toXML( adrJane ) );
    }
}
TOP

Related Classes of de.netseeker.ejoe.examples.remoting.AddressClientWithJdkProxy

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.