Examples of MethodInvocationResult


Examples of org.jboss.mx.remote.MethodInvocationResult

        byte lenbuf[] = new byte[10];
        int maxrecv = socket.getSendBufferSize();
        int maxsend = socket.getReceiveBufferSize();

        MethodInvocationResult result = null;
        synchronized (invokeLock)
        {


            // write the method invocation to the output stream
            try
            {
                // first write out the buffer with the length
                SocketAcceptor.fill(lenbuf, buf.length);

                out.write(lenbuf, 0, 10);
                out.flush();

                int count = 0;
                int left = buf.length;

                // write out our invocation request buffer
                while (left > 0)
                {
                    int total = Math.min(left, maxsend);
                    out.write(buf, count, total);
                    count += total;
                    left -= total;
                }

                out.flush();

                // read in our response
                SocketAcceptor.zero(lenbuf);

                // read in the response's length
                in.read(lenbuf, 0, 10);

                int length = Integer.valueOf(new String(lenbuf)).intValue();

                ByteArrayOutputStream input = new ByteArrayOutputStream(length);

                count = 0;
                left = length;

                buf = new byte[Math.min(length, maxrecv)];

                while (left > 0)
                {
                    int amt = in.read(buf, 0, buf.length);
                    if (amt == -1)
                    {
                        break;
                    }
                    count += amt;
                    left -= amt;
                    input.write(buf, 0, amt);
                }

                // de-serialize the method invocation result
                result = (MethodInvocationResult) SerializationHelper.deserialize(input.toByteArray(),ccl);
                if (logMethod&&log.isDebugEnabled())
                {
                    log.debug("method returned result ... "+result+" for operation: "+name);
                }
            }
            catch (Throwable t)
            {
                if (t instanceof SocketException)
                {
                    try
                    {
                        stop();
                    }
                    catch (Exception ex)
                    {
                        if (log.isDebugEnabled())
                        {
                            log.warn("Exception stopping socket on SocketException", ex);
                        }
                    }
                    throw new ConnectionException("Connection has been closed",t);
                }
                throw t;
            }
            if (result.hasException())
            {
                throw result.getException();
            }
            else
            {
                return result.getResult();
            }
        }
    }
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.