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 static short ID  
      protected java.lang.reflect.Method method  
      protected static short METHOD  
      protected short method_id  
      protected java.lang.String method_name  
      protected short mode  
      protected java.lang.Class[] types  
      protected static short TYPES  
    • Constructor Summary

      Constructors 
      Constructor Description
      MethodCall()
      Needed for deserialization
      MethodCall​(short method_id, java.lang.Object... args)  
      MethodCall​(java.lang.reflect.Method method, 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
      java.lang.Object[] args()  
      MethodCall args​(java.lang.Object... args)  
      java.util.function.Supplier<? extends MethodCall> create()
      Creates an instance of the class implementing this interface
      static java.lang.reflect.Method findMethod​(java.lang.Class target_class, java.lang.String method_name, java.lang.Object[] args)
      Called by the ProbeHandler impl.
      protected static java.lang.reflect.Method[] getAllMethods​(java.lang.Class target)
      The method walks up the class hierarchy and returns all methods of this class and those inherited from superclasses and superinterfaces.
      java.lang.Object[] getArgs()  
      java.lang.reflect.Method getMethod()  
      protected static java.lang.reflect.Method getMethod​(java.lang.Class target, java.lang.String methodName, java.lang.Class[] types)
      Returns the first method that matches the specified name and parameter types.
      short getMethodId()  
      java.lang.String getMethodName()  
      int getMode()  
      protected void init​(java.lang.reflect.Method method)  
      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 static boolean isPrimitiveType​(java.lang.Class<?> type)  
      java.lang.reflect.Method method()  
      MethodCall method​(java.lang.reflect.Method m)  
      short methodId()  
      MethodCall methodId​(short id)  
      java.lang.String methodName()  
      MethodCall methodName​(java.lang.String n)  
      int mode()  
      protected void readArgs​(java.io.DataInput in, Marshaller marshaller)  
      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
      void readFrom​(java.io.DataInput in, Marshaller marshaller)  
      protected void readMethod​(java.io.DataInput in)  
      protected void readTypes​(java.io.DataInput in)  
      MethodCall setArgs​(java.lang.Object... args)  
      MethodCall setMethod​(java.lang.reflect.Method m)  
      MethodCall setMethodId​(short id)  
      MethodCall setMethodName​(java.lang.String n)  
      java.lang.String toString()  
      java.lang.String toStringDetails()  
      protected void writeArgs​(java.io.DataOutput out, Marshaller marshaller)  
      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.
      void writeTo​(java.io.DataOutput out, Marshaller marshaller)  
      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

      • mode

        protected short mode
      • 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 method,
                          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

      • getMode

        public int getMode()
      • mode

        public int mode()
      • getMethodName

        public java.lang.String getMethodName()
      • methodName

        public java.lang.String methodName()
      • setMethodName

        public MethodCall setMethodName​(java.lang.String n)
      • methodName

        public MethodCall methodName​(java.lang.String n)
      • getMethodId

        public short getMethodId()
      • methodId

        public short methodId()
      • setMethodId

        public MethodCall setMethodId​(short id)
      • methodId

        public MethodCall methodId​(short id)
      • getArgs

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

        public java.lang.Object[] args()
      • args

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

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

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

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

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

        public MethodCall method​(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
      • findMethod

        public static java.lang.reflect.Method findMethod​(java.lang.Class target_class,
                                                          java.lang.String method_name,
                                                          java.lang.Object[] args)
                                                   throws java.lang.Exception
        Called by the ProbeHandler impl. All args are strings. Needs to find a method where all parameter types are primitive types, so the strings can be converted
        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
      • writeTo

        public void writeTo​(java.io.DataOutput out,
                            Marshaller marshaller)
                     throws java.io.IOException
        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
      • readFrom

        public void readFrom​(java.io.DataInput in,
                             Marshaller marshaller)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • init

        protected void init​(java.lang.reflect.Method method)
      • getMethod

        protected static java.lang.reflect.Method getMethod​(java.lang.Class target,
                                                            java.lang.String methodName,
                                                            java.lang.Class[] types)
        Returns the first method that matches the specified name and parameter types. The overriding methods have priority. The method is chosen from all the methods of the current class and all its superclasses and superinterfaces.
        Returns:
        the matching method or null if no matching method has been found.
      • writeArgs

        protected void writeArgs​(java.io.DataOutput out,
                                 Marshaller marshaller)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readArgs

        protected void readArgs​(java.io.DataInput in,
                                Marshaller marshaller)
                         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
      • readMethod

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

        protected static java.lang.reflect.Method[] getAllMethods​(java.lang.Class target)
        The method walks up the class hierarchy and returns all methods of this class and those inherited from superclasses and superinterfaces.
      • isPrimitiveType

        protected static boolean isPrimitiveType​(java.lang.Class<?> type)