Class MethodCall

  • All Implemented Interfaces:
    Constructable<MethodCall>, Streamable

    public class MethodCall
    extends java.lang.Object
    implements Streamable, Constructable<MethodCall>
    A method call is the JGroups representation of a remote method. It includes the name of the method (case sensitive) and a list of arguments. A method call is serializable and can be passed over the wire.
    Author:
    Bela Ban
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Object[] args  
      protected java.lang.reflect.Method method  
      protected short method_id  
      protected java.lang.String method_name  
      protected java.lang.Class<?>[] types  
    • Constructor Summary

      Constructors 
      Constructor Description
      MethodCall()
      Needed for deserialization
      MethodCall​(short method_id, java.lang.Object... args)  
      MethodCall​(java.lang.reflect.Method m, java.lang.Object... arguments)  
      MethodCall​(java.lang.String method_name, java.lang.Object[] args, java.lang.Class<?>[] types)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static short assertNotNegative​(short num)  
      java.util.function.Supplier<? extends MethodCall> create()
      Creates an instance of the class implementing this interface
      java.lang.Object[] getArgs()  
      java.lang.reflect.Method getMethod()  
      short getMethodId()  
      java.lang.String getMethodName()  
      java.lang.Object invoke​(java.lang.Object target)
      Invokes the method with the supplied arguments against the target object.
      java.lang.Object invoke​(java.lang.Object target, java.lang.Object[] args)  
      protected java.lang.Object readArg​(java.io.DataInput in)  
      protected void readArgs​(java.io.DataInput in)  
      void readFrom​(java.io.DataInput in)
      Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
      protected void readTypes​(java.io.DataInput in)  
      MethodCall setArgs​(java.lang.Object... args)  
      MethodCall setMethod​(java.lang.reflect.Method m)  
      MethodCall setMethodId​(short id)  
      java.lang.String toString()  
      java.lang.String toStringDetails()  
      boolean useIds()  
      protected void writeArg​(java.io.DataOutput out, java.lang.Object obj)  
      protected void writeArgs​(java.io.DataOutput out)  
      protected void writeMethod​(java.io.DataOutput out)  
      void writeTo​(java.io.DataOutput out)
      Write the entire state of the current object (including superclasses) to outstream.
      protected void writeTypes​(java.io.DataOutput out)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • method_name

        protected java.lang.String method_name
      • method_id

        protected short method_id
      • args

        protected java.lang.Object[] args
      • types

        protected java.lang.Class<?>[] types
      • method

        protected java.lang.reflect.Method method
    • Constructor Detail

      • MethodCall

        public MethodCall()
        Needed for deserialization
      • MethodCall

        public MethodCall​(java.lang.reflect.Method m,
                          java.lang.Object... arguments)
      • MethodCall

        public MethodCall​(short method_id,
                          java.lang.Object... args)
      • MethodCall

        public MethodCall​(java.lang.String method_name,
                          java.lang.Object[] args,
                          java.lang.Class<?>[] types)
    • Method Detail

      • useIds

        public boolean useIds()
      • getMethodName

        public java.lang.String getMethodName()
      • getMethodId

        public short getMethodId()
      • setMethodId

        public MethodCall setMethodId​(short id)
      • getArgs

        public java.lang.Object[] getArgs()
      • setArgs

        public MethodCall setArgs​(java.lang.Object... args)
      • getMethod

        public java.lang.reflect.Method getMethod()
      • setMethod

        public MethodCall setMethod​(java.lang.reflect.Method m)
      • invoke

        public java.lang.Object invoke​(java.lang.Object target)
                                throws java.lang.Exception
        Invokes the method with the supplied arguments against the target object.
        Parameters:
        target - - the object that you want to invoke the method on
        Returns:
        the result
        Throws:
        java.lang.Exception
      • invoke

        public java.lang.Object invoke​(java.lang.Object target,
                                       java.lang.Object[] args)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toStringDetails

        public java.lang.String toStringDetails()
      • writeTo

        public void writeTo​(java.io.DataOutput out)
                     throws java.io.IOException
        Description copied from interface: Streamable
        Write the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed
        Specified by:
        writeTo in interface Streamable
        Throws:
        java.io.IOException
      • readFrom

        public void readFrom​(java.io.DataInput in)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException
        Description copied from interface: Streamable
        Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
        Specified by:
        readFrom in interface Streamable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeArgs

        protected void writeArgs​(java.io.DataOutput out)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • writeArg

        protected void writeArg​(java.io.DataOutput out,
                                java.lang.Object obj)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readArgs

        protected void readArgs​(java.io.DataInput in)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • readArg

        protected java.lang.Object readArg​(java.io.DataInput in)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeTypes

        protected void writeTypes​(java.io.DataOutput out)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readTypes

        protected void readTypes​(java.io.DataInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeMethod

        protected void writeMethod​(java.io.DataOutput out)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • assertNotNegative

        protected static short assertNotNegative​(short num)