Examples of RemotingRequest


Examples of de.netseeker.ejoe.request.RemotingRequest

            // static method invocation
            try
            {
                Object[] args = new Object[] { "This", " is", " a", " remoting", " test" };
                RemotingRequest request = new RemotingRequest( RemoteTestMethods.class.getName(), "buildStaticString",
                                                               new Object[] { args } );
                Object result = client.execute( request );
                assertNotNull( result );
                assertEquals( ContentStringBuilder.toString( args ), result );
            }
            catch ( IOException e )
            {
                e.printStackTrace();
                fail( e.getMessage() );
            }

            // instance method invocations
            try
            {
                Object[] args = new Object[] { "This", " is", " a", " remoting", " test" };
                RemotingRequest request = new RemotingRequest( RemoteTestMethods.class.getName(), "buildString",
                                                               new Object[] { args } );
                Object result = client.execute( request );
                assertNotNull( result );
                assertEquals( ContentStringBuilder.toString( args ), result );

                Integer sum = Integer.valueOf( 3 );

                request = new RemotingRequest( RemoteTestMethods.class.getName(), "add", new Object[] {
                        Integer.valueOf( 1 ), Integer.valueOf( 2 ) } );
                result = client.execute( request );
                assertNotNull( result );
                assertEquals( sum, result );

                request = new RemotingRequest( RemoteTestMethods.class.getName(), "add", new Object[] {
                        Integer.valueOf( 1 ), Integer.valueOf( 2 ) } );
                result = client.execute( request );
                assertNotNull( result );
                assertEquals( sum, result );

                request = new RemotingRequest( RemoteTestMethods.class.getName(), "subtract", new Object[] {
                        Integer.valueOf( 3 ), Integer.valueOf( 1 ) } );
                result = client.execute( request );
                assertNotNull( result );
                assertEquals( Integer.valueOf( 2 ), result );

            }
            catch ( IOException e )
            {
                e.printStackTrace();
                fail( e.getMessage() );
            }

            // default constructor invocation
            try
            {
                RemotingRequest request = new RemotingRequest( RemoteTestMethods.class.getName(), "RemoteTestMethods",
                                                               new Object[] {} );
                Object result = client.execute( request );
                assertNotNull( result );
                assertTrue( result instanceof RemoteTestMethods );
            }
            catch ( IOException e )
            {
                e.printStackTrace();
                fail( e.getMessage() );
            }

            // parameterized constructor invocation
            try
            {
                RemotingRequest request = new RemotingRequest( RemoteTestMethods.class.getName(), "RemoteTestMethods",
                                                               new Object[] { Boolean.TRUE } );
                Object result = client.execute( request );
                assertNotNull( result );
                assertTrue( result instanceof RemoteTestMethods );

                request = new RemotingRequest( RemoteTestMethods.class.getName(), "RemoteTestMethods",
                                               new Object[] { Boolean.FALSE } );
                result = client.execute( request );
                assertNotNull( result );
                assertTrue( result instanceof RemoteTestMethods );

                request = new RemotingRequest( RemoteTestMethods.class.getName(), "RemoteTestMethods", new Object[] {
                        Boolean.TRUE, Boolean.FALSE } );
                result = client.execute( request );
                assertNotNull( result );
                assertTrue( result instanceof RemoteTestMethods );
            }
View Full Code Here

Examples of de.netseeker.ejoe.request.RemotingRequest

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

Examples of de.netseeker.ejoe.request.RemotingRequest

                _ejclient.setInJVM( true );
            }
        }

        Object ret = null;
        RemotingRequest lvStrService = (RemotingRequest) getInvocationStrategy();
        lvStrService.setArgs( pvArgs );

        if ( log.isDebugEnabled() )
        {
            log.debug( "Invocation target: " + lvStrService.toString() );
        }

        try
        {
            ret = _ejclient.execute( lvStrService );
        }
        catch ( Exception e )
        {
            Throwable t = e;
            if ( e.getCause() != null )
            {
                t = e.getCause();
            }

            throw new InvocationException( "Error by execute service: " + lvStrService.toString() + " -- "
                    + t.getMessage(), t );
        }

        return ret;
    }
View Full Code Here

Examples of de.netseeker.ejoe.request.RemotingRequest

        {
            throw new InvocationException( "Error in the InvocationStrategy " + this.getClass().getName() + ". "
                    + "The class: " + lvClass + " and the method: " + lvMethod + " must be unequal null!" );
        }

        RemotingRequest request = new RemotingRequest();
        request.setClazz( lvClass );
        request.setMethod( lvMethod );

        return request;
    }
View Full Code Here

Examples of de.netseeker.ejoe.request.RemotingRequest

     *
     * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
     */
    public Object invoke( Object proxy, Method method, Object[] args ) throws Throwable
    {
        RemotingRequest request = new RemotingRequest( this._remoteClassName, method.getName(), args );
        if ( this._callback == null )
        {
            return this._client.execute( request );
        }
        else
View Full Code Here

Examples of de.netseeker.ejoe.request.RemotingRequest

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

Examples of de.netseeker.ejoe.request.RemotingRequest

    }   
   

    protected Object processRequest( String mtd, Object data ) throws IOException
    {
        RemotingRequest request = new RemotingRequest( SimpleTypes.class.getName(), mtd, new Object[] { data } );
        return client.execute( request );
    }   
View Full Code Here

Examples of de.netseeker.ejoe.request.RemotingRequest

     *
     * @see de.netseeker.ejoe.handler.ServerHandler#handle(java.lang.Object)
     */
    public Object handle( Object params ) throws Exception
    {
        RemotingRequest request = (RemotingRequest) params;

        if ( request.getClazz() == null )
        {
            throw new IllegalArgumentException( "Parameter \"targetClass\" not found in request!" );
        }

        if ( request.getMethod() == null )
        {
            throw new IllegalArgumentException( "Parameter \"targetMethod\" not found in request!" );
        }

        Class clazz = getClassByName( request.getClazz() );

        if ( clazz.isInterface() )
        {
            throw new IllegalArgumentException( "Parameter \"targetClass\" must not be an interface!" );
        }
        else if ( clazz.isPrimitive() )
        {
            throw new IllegalArgumentException( "Parameter \"targetClass\" must not be an primitive!" );
        }

        return handle( clazz, request.getMethod(), request.getArgs() );
    }
View Full Code Here
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.