Package de.netseeker.ejoe

Examples of de.netseeker.ejoe.EJClient


public class EchoClient
{

    public static void main( String[] args )
    {
        EJClient client = new EJClient( "localhost", 9999, new UTF8StringAdapter() );
        client.enablePersistentConnection( true );

        try
        {
            BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
            String str = "", result = null;

            while ( str != null )
            {
                System.out.print( "> type your message: " );
                str = in.readLine();

                if ( str != null )
                {
                    if ( str.equalsIgnoreCase( "exit" ) )
                    {
                        System.out.println( "Bye." );
                        client.close();
                        System.exit( 1 );
                    }

                    if ( str.length() > 0 )
                    {
                        result = (String) client.execute( str );
                        System.out.println( "Server returned: " + result );
                    }
                }
            }
        }
View Full Code Here


     */
    protected void setUp() throws Exception
    {
        super.setUp();
        super.setUp();
        client = new EJClient( "127.0.0.1", EJConstants.EJOE_PORT,
                               new XStreamAdapter( true ) );
        client.enableRemoteClassloading();
        client.enablePersistentConnection( true );
    }
View Full Code Here

    /**
     * @return
     */
    public EJClient getEJClient()
    {
        EJClient client = getEJClientFromCache();
        if ( client == null )
        {
            String address[] = ejoeAddress.getEjoeServerURL().split( "://" );
            boolean isHttp = address[0].equalsIgnoreCase( "http" );
            int index = address[1].lastIndexOf( ':' );
            String host = address[1].substring( 0, index );
            String sPort = address[1].substring( index + 1 );
            int port = Integer.parseInt( sPort );
            client = new EJClient( host, port, ejoeAdapter, ejoeAddress.getUsePersistentConnection(), isHttp,
                                   ejoeAddress.getUseCompression() );

            if ( ejoeAddress.getTimeout() > 0 )
            {
                client.setConnectionTimeout( ejoeAddress.getTimeout() );
            }
        }

        return client;
    }
View Full Code Here

        return buf.toString();
    }

    private EJClient getEJClientFromCache()
    {
        EJClient client = null;

        if ( this.ejClientInstances.size() > 0 )
        {
            synchronized ( _mutex )
            {
View Full Code Here

     * @see BaseTest#setUp()
     */
    protected void setUp() throws Exception
    {
        super.setUp();
        client = new EJClient( "127.0.0.1", EJConstants.EJOE_PORT,
                               new XStreamAdapter( true ) );
        client.enableRemoteClassloading();
        client.enablePersistentConnection( true );
    }
View Full Code Here

        }

        public void run()
        {
            log.log( Level.FINEST, System.currentTimeMillis() + " -- ClientThread" + number + " started" );
            EJClient ejclient = new EJClient( "127.0.0.1", EJConstants.EJOE_PORT, adapter );
            ejclient.enablePersistentConnection( true );
            ejclient.setConnectionTimeout( 60000 );

            Map result = null;
            Map input = new HashMap();
            input.put( "KEY1", "Hello" );
            input.put( "KEY2", Integer.valueOf( 101 ) );
            input.put( "KEY3", BigDecimal.valueOf( 102 ) );

            try
            {
                for ( int i = 0; i < 5; i++ )
                {
                    result = (Map) ejclient.execute( input );
                    if ( result == null ) fail( "Result was null!" );
                    if ( result.get( "KEY4" ) == null )
                        fail( "Additional key which should be set by EJServer was not found!" );
                    log.log( Level.FINEST, System.currentTimeMillis() + " -- ClientThread" + number
                            + " return map contains " + result.size() + " entries." );
                }
            }
            catch ( Exception e )
            {
                log.log( Level.SEVERE, "Test failed!", e );
            }
            finally
            {
                if ( result != null )
                {
                    successCount.getAndIncrement();
                }
                activeCount.getAndDecrement();

                ejclient.close();
            }

            log.log( Level.FINEST, System.currentTimeMillis() + " -- ClientThread" + number + " finished" );
        }
View Full Code Here

    public boolean executeRequestResponseOperation( WSIFMessage input, WSIFMessage output, WSIFMessage fault )
            throws WSIFException
    {
        Trc.entry( this, input, output, fault );

        EJClient client = this.fieldPort.getEJClient();

        try
        {
            Object[] arguments = null;
            Object part = null;
            Object result = null;

            if ( (fieldInParameterNames != null) && (fieldInParameterNames.length > 0) )
            {
                arguments = new Object[fieldInParameterNames.length];
                for ( int i = 0; i < fieldInParameterNames.length; i++ )
                {
                    try
                    {
                        part = input.getObjectPart( fieldInParameterNames[i] );
                        arguments[i] = part;
                    }
                    catch ( WSIFException e )
                    {
                        Trc.exception( e );
                        arguments[i] = null;
                    }
                }
            }

            try
            {
                if ( fieldEJOEOperationModel.getInvocationType().equalsIgnoreCase( "reflection" ) )
                {
                    RemotingRequest request = new RemotingRequest( fieldEJOEOperationModel.getClassName(),
                                                                   fieldEJOEOperationModel.getMethodName(), arguments );
                    Trc.event( this, "Processing remoting request ", request );
                    result = client.execute( request );
                }
                else
                {
                    Trc.event( this, "Processing default request with arguments ", ContentStringBuilder
                            .toString( arguments ) );
                    result = client.execute( arguments );
                }
                Trc.event( this, "Result from EJOE server is ", result );

            }
            catch ( Exception e )
View Full Code Here

            int index = address[1].lastIndexOf( ':' );
            String host = address[1].substring( 0, index );
            String sPort = address[1].substring( index + 1 );
            int port = Integer.parseInt( sPort );
            _ejclient = new EJClient( host, port, adapter, persistent, isHttp, compression );

            if ( classloading )
            {
                _ejclient.enableRemoteClassloading();
            }
View Full Code Here

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();
View Full Code Here

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 )
        {
View Full Code Here

TOP

Related Classes of de.netseeker.ejoe.EJClient

Copyright © 2018 www.massapicom. 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.